LLVM API Documentation

FindUsedTypes.h

Go to the documentation of this file.
00001 //===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This pass is used to seek out all of the types in use by the program.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H
00015 #define LLVM_ANALYSIS_FINDUSEDTYPES_H
00016 
00017 #include "llvm/Pass.h"
00018 #include <set>
00019 
00020 namespace llvm {
00021 
00022 class Type;
00023 class Value;
00024 
00025 class FindUsedTypes : public ModulePass {
00026   std::set<const Type *> UsedTypes;
00027 public:
00028   static char ID; // Pass identification, replacement for typeid
00029   FindUsedTypes() : ModulePass(&ID) {}
00030 
00031   /// getTypes - After the pass has been run, return the set containing all of
00032   /// the types used in the module.
00033   ///
00034   const std::set<const Type *> &getTypes() const { return UsedTypes; }
00035 
00036   /// Print the types found in the module.  If the optional Module parameter is
00037   /// passed in, then the types are printed symbolically if possible, using the
00038   /// symbol table from the module.
00039   ///
00040   void print(std::ostream &o, const Module *M) const;
00041   void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
00042 
00043 private:
00044   /// IncorporateType - Incorporate one type and all of its subtypes into the
00045   /// collection of used types.
00046   ///
00047   void IncorporateType(const Type *Ty);
00048 
00049   /// IncorporateValue - Incorporate all of the types used by this value.
00050   ///
00051   void IncorporateValue(const Value *V);
00052 
00053 public:
00054   /// run - This incorporates all types used by the specified module
00055   bool runOnModule(Module &M);
00056 
00057   /// getAnalysisUsage - We do not modify anything.
00058   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
00059     AU.setPreservesAll();
00060   }
00061 };
00062 
00063 } // End llvm namespace
00064 
00065 #endif



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.