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 was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source 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 
00024 class FindUsedTypes : public ModulePass {
00025   std::set<const Type *> UsedTypes;
00026 public:
00027   /// getTypes - After the pass has been run, return the set containing all of
00028   /// the types used in the module.
00029   ///
00030   const std::set<const Type *> &getTypes() const { return UsedTypes; }
00031 
00032   /// Print the types found in the module.  If the optional Module parameter is
00033   /// passed in, then the types are printed symbolically if possible, using the
00034   /// symbol table from the module.
00035   ///
00036   void print(std::ostream &o, const Module *M) const;
00037 
00038 private:
00039   /// IncorporateType - Incorporate one type and all of its subtypes into the
00040   /// collection of used types.
00041   ///
00042   void IncorporateType(const Type *Ty);
00043 
00044   /// IncorporateValue - Incorporate all of the types used by this value.
00045   ///
00046   void IncorporateValue(const Value *V);
00047 
00048 public:
00049   /// run - This incorporates all types used by the specified module
00050   bool runOnModule(Module &M);
00051 
00052   /// getAnalysisUsage - We do not modify anything.
00053   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
00054     AU.setPreservesAll();
00055   }
00056 };
00057 
00058 } // End llvm namespace
00059 
00060 // Make sure that any clients of this file link in PostDominators.cpp
00061 FORCE_DEFINING_FILE_TO_BE_LINKED(FindUsedTypes)
00062 
00063 #endif