FindUsedTypes.h revision 198090
1193323Sed//===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- C++ -*-===// 2193323Sed// 3193323Sed// The LLVM Compiler Infrastructure 4193323Sed// 5193323Sed// This file is distributed under the University of Illinois Open Source 6193323Sed// License. See LICENSE.TXT for details. 7193323Sed// 8193323Sed//===----------------------------------------------------------------------===// 9193323Sed// 10193323Sed// This pass is used to seek out all of the types in use by the program. 11193323Sed// 12193323Sed//===----------------------------------------------------------------------===// 13193323Sed 14193323Sed#ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H 15193323Sed#define LLVM_ANALYSIS_FINDUSEDTYPES_H 16193323Sed 17193323Sed#include "llvm/Pass.h" 18193323Sed#include <set> 19193323Sed 20193323Sednamespace llvm { 21193323Sed 22193323Sedclass Type; 23193323Sedclass Value; 24193323Sed 25193323Sedclass FindUsedTypes : public ModulePass { 26193323Sed std::set<const Type *> UsedTypes; 27193323Sedpublic: 28193323Sed static char ID; // Pass identification, replacement for typeid 29193323Sed FindUsedTypes() : ModulePass(&ID) {} 30193323Sed 31193323Sed /// getTypes - After the pass has been run, return the set containing all of 32193323Sed /// the types used in the module. 33193323Sed /// 34193323Sed const std::set<const Type *> &getTypes() const { return UsedTypes; } 35193323Sed 36193323Sed /// Print the types found in the module. If the optional Module parameter is 37193323Sed /// passed in, then the types are printed symbolically if possible, using the 38193323Sed /// symbol table from the module. 39193323Sed /// 40198090Srdivacky void print(raw_ostream &o, const Module *M) const; 41193323Sed 42193323Sedprivate: 43193323Sed /// IncorporateType - Incorporate one type and all of its subtypes into the 44193323Sed /// collection of used types. 45193323Sed /// 46193323Sed void IncorporateType(const Type *Ty); 47193323Sed 48193323Sed /// IncorporateValue - Incorporate all of the types used by this value. 49193323Sed /// 50193323Sed void IncorporateValue(const Value *V); 51193323Sed 52193323Sedpublic: 53193323Sed /// run - This incorporates all types used by the specified module 54193323Sed bool runOnModule(Module &M); 55193323Sed 56193323Sed /// getAnalysisUsage - We do not modify anything. 57193323Sed virtual void getAnalysisUsage(AnalysisUsage &AU) const { 58193323Sed AU.setPreservesAll(); 59193323Sed } 60193323Sed}; 61193323Sed 62193323Sed} // End llvm namespace 63193323Sed 64193323Sed#endif 65