1 //===- llvm/Analysis/FindUsedTypes.h - Find all Types in use -----*- C++ -*--=//
3 // This pass is used to seek out all of the types in use by the program.
5 //===----------------------------------------------------------------------===//
7 #ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H
8 #define LLVM_ANALYSIS_FINDUSEDTYPES_H
10 #include "llvm/Pass.h"
15 class FindUsedTypes : public Pass {
16 std::set<const Type *> UsedTypes;
18 bool IncludeSymbolTables;
20 // FindUsedTypes ctor - This pass can optionally include types that are
21 // referenced only in symbol tables, but the default is not to.
24 static AnalysisID IncludeSymbolTableID;
26 FindUsedTypes(AnalysisID id) : IncludeSymbolTables(id != ID) {}
28 // getTypes - After the pass has been run, return the set containing all of
29 // the types used in the module.
31 inline const std::set<const Type *> &getTypes() const { return UsedTypes; }
33 // Print the types found in the module. If the optional Module parameter is
34 // passed in, then the types are printed symbolically if possible, using the
35 // symbol table from the module.
37 void printTypes(std::ostream &o, const Module *M = 0) const;
40 // IncorporateType - Incorporate one type and all of its subtypes into the
41 // collection of used types.
43 void IncorporateType(const Type *Ty);
45 // IncorporateSymbolTable - Add all types referenced by the specified symtab
46 // into the collection of used types.
48 void IncorporateSymbolTable(const SymbolTable *ST);
51 // run - This incorporates all types used by the specified module
55 // getAnalysisUsage - Of course, we provide ourself...
57 virtual void getAnalysisUsage(AnalysisUsage &AU) const {