Including the symbol table in the FindUsedTypes analysis was the WRONG way
[oota-llvm.git] / include / llvm / Analysis / FindUsedTypes.h
1 //===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This pass is used to seek out all of the types in use by the program.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H
15 #define LLVM_ANALYSIS_FINDUSEDTYPES_H
16
17 #include "llvm/Pass.h"
18 #include <set>
19 class Type;
20
21 class FindUsedTypes : public Pass {
22   std::set<const Type *> UsedTypes;
23 public:
24   /// getTypes - After the pass has been run, return the set containing all of
25   /// the types used in the module.
26   ///
27   const std::set<const Type *> &getTypes() const { return UsedTypes; }
28
29   /// Print the types found in the module.  If the optional Module parameter is
30   /// passed in, then the types are printed symbolically if possible, using the
31   /// symbol table from the module.
32   ///
33   void print(std::ostream &o, const Module *M) const;
34
35 private:
36   /// IncorporateType - Incorporate one type and all of its subtypes into the
37   /// collection of used types.
38   ///
39   void IncorporateType(const Type *Ty);
40
41   /// IncorporateValue - Incorporate all of the types used by this value.
42   ///
43   void IncorporateValue(const Value *V);
44
45 public:
46   /// run - This incorporates all types used by the specified module
47   bool run(Module &M);
48
49   /// getAnalysisUsage - We do not modify anything.
50   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
51     AU.setPreservesAll();
52   }
53
54   // stub - dummy function, just ignore it
55   static void stub();
56 };
57
58 // Make sure that any clients of this file link in PostDominators.cpp
59 static IncludeFile
60 FIND_USED_TYPES_INCLUDE_FILE((void*)&FindUsedTypes::stub);
61
62 #endif