* Rename MethodPass class to FunctionPass
[oota-llvm.git] / include / llvm / Analysis / FindUnsafePointerTypes.h
1 //===- llvm/Analysis/FindUnsafePointerTypes.h - Unsafe pointers ---*- C++ -*-=//
2 //
3 // This file defines a pass that can be used to determine, interprocedurally, 
4 // which pointer types are accessed unsafely in a program.  If there is an
5 // "unsafe" access to a specific pointer type, transformations that depend on
6 // type safety cannot be permitted.
7 //
8 // The result of running this analysis over a program is a set of unsafe pointer
9 // types that cannot be transformed.  Safe pointer types are not tracked.
10 //
11 // Additionally, this analysis exports a hidden command line argument that (when
12 // enabled) prints out the reasons a type was determined to be unsafe.  Just add
13 // -printunsafeptrinst to the command line of the tool you want to get it.
14 // 
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
18 #define LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
19
20 #include "llvm/Pass.h"
21 #include <set>
22
23 class PointerType;
24
25 struct FindUnsafePointerTypes : public Pass {
26   // UnsafeTypes - Set of types that are not safe to transform.
27   std::set<PointerType*> UnsafeTypes;
28 public:
29   static AnalysisID ID;    // We are an analysis, we must have an ID
30
31   FindUnsafePointerTypes(AnalysisID id) { assert(ID == id); }
32
33   // Accessor for underlying type set...
34   inline const std::set<PointerType*> &getUnsafeTypes() const {
35     return UnsafeTypes;
36   }
37
38   // run - Inspect the operations that the specified module does on
39   // values of various types.  If they are deemed to be 'unsafe' note that the
40   // type is not safe to transform.
41   //
42   virtual bool run(Module *M);
43
44   // printResults - Loop over the results of the analysis, printing out unsafe
45   // types.
46   //
47   void printResults(const Module *Mod, std::ostream &o) const;
48
49   // getAnalysisUsage - Of course, we provide ourself...
50   //
51   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
52     AU.setPreservesAll();
53     AU.addProvided(ID);
54   }
55 };
56
57 #endif