1 //===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source 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"
24 class FindUsedTypes : public ModulePass {
25 std::set<const Type *> UsedTypes;
27 static const char ID; // Pass identifcation, replacement for typeid
28 FindUsedTypes() : ModulePass((intptr_t)&ID) {}
30 /// getTypes - After the pass has been run, return the set containing all of
31 /// the types used in the module.
33 const std::set<const Type *> &getTypes() const { return UsedTypes; }
35 /// Print the types found in the module. If the optional Module parameter is
36 /// passed in, then the types are printed symbolically if possible, using the
37 /// symbol table from the module.
39 void print(std::ostream &o, const Module *M) const;
40 void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
43 /// IncorporateType - Incorporate one type and all of its subtypes into the
44 /// collection of used types.
46 void IncorporateType(const Type *Ty);
48 /// IncorporateValue - Incorporate all of the types used by this value.
50 void IncorporateValue(const Value *V);
53 /// run - This incorporates all types used by the specified module
54 bool runOnModule(Module &M);
56 /// getAnalysisUsage - We do not modify anything.
57 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
62 } // End llvm namespace
64 // Make sure that any clients of this file link in PostDominators.cpp
65 FORCE_DEFINING_FILE_TO_BE_LINKED(FindUsedTypes)