1 //===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This pass is used to seek out all of the types in use by the program.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H
15 #define LLVM_ANALYSIS_FINDUSEDTYPES_H
17 #include "llvm/Pass.h"
25 class FindUsedTypes : public ModulePass {
26 std::set<const Type *> UsedTypes;
28 static char ID; // Pass identification, replacement for typeid
29 FindUsedTypes() : ModulePass(&ID) {}
31 /// getTypes - After the pass has been run, return the set containing all of
32 /// the types used in the module.
34 const std::set<const Type *> &getTypes() const { return UsedTypes; }
36 /// Print the types found in the module. If the optional Module parameter is
37 /// passed in, then the types are printed symbolically if possible, using the
38 /// symbol table from the module.
40 void print(std::ostream &o, const Module *M) const;
41 void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
44 /// IncorporateType - Incorporate one type and all of its subtypes into the
45 /// collection of used types.
47 void IncorporateType(const Type *Ty);
49 /// IncorporateValue - Incorporate all of the types used by this value.
51 void IncorporateValue(const Value *V);
54 /// run - This incorporates all types used by the specified module
55 bool runOnModule(Module &M);
57 /// getAnalysisUsage - We do not modify anything.
58 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
63 } // End llvm namespace