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