Fix some null checks to actually test the part that needs checking.
[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
20 namespace llvm {
21
22 class Type;
23
24 class FindUsedTypes : public ModulePass {
25   std::set<const Type *> UsedTypes;
26 public:
27   /// getTypes - After the pass has been run, return the set containing all of
28   /// the types used in the module.
29   ///
30   const std::set<const Type *> &getTypes() const { return UsedTypes; }
31
32   /// Print the types found in the module.  If the optional Module parameter is
33   /// passed in, then the types are printed symbolically if possible, using the
34   /// symbol table from the module.
35   ///
36   void print(std::ostream &o, const Module *M) const;
37   void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
38
39 private:
40   /// IncorporateType - Incorporate one type and all of its subtypes into the
41   /// collection of used types.
42   ///
43   void IncorporateType(const Type *Ty);
44
45   /// IncorporateValue - Incorporate all of the types used by this value.
46   ///
47   void IncorporateValue(const Value *V);
48
49 public:
50   /// run - This incorporates all types used by the specified module
51   bool runOnModule(Module &M);
52
53   /// getAnalysisUsage - We do not modify anything.
54   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
55     AU.setPreservesAll();
56   }
57 };
58
59 } // End llvm namespace
60
61 // Make sure that any clients of this file link in PostDominators.cpp
62 FORCE_DEFINING_FILE_TO_BE_LINKED(FindUsedTypes)
63
64 #endif