LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FindUnsafePointerTypes.h

Go to the documentation of this file.
00001 //===- llvm/Analysis/FindUnsafePointerTypes.h - Unsafe pointers -*- 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 file defines a pass that can be used to determine, interprocedurally, 
00011 // which pointer types are accessed unsafely in a program.  If there is an
00012 // "unsafe" access to a specific pointer type, transformations that depend on
00013 // type safety cannot be permitted.
00014 //
00015 // The result of running this analysis over a program is a set of unsafe pointer
00016 // types that cannot be transformed.  Safe pointer types are not tracked.
00017 //
00018 // Additionally, this analysis exports a hidden command line argument that (when
00019 // enabled) prints out the reasons a type was determined to be unsafe.  Just add
00020 // -printunsafeptrinst to the command line of the tool you want to get it.
00021 // 
00022 //===----------------------------------------------------------------------===//
00023 
00024 #ifndef LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
00025 #define LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
00026 
00027 #include "llvm/Pass.h"
00028 #include <set>
00029 
00030 namespace llvm {
00031 
00032 class PointerType;
00033 
00034 struct FindUnsafePointerTypes : public ModulePass {
00035   // UnsafeTypes - Set of types that are not safe to transform.
00036   std::set<PointerType*> UnsafeTypes;
00037 public:
00038   // Accessor for underlying type set...
00039   inline const std::set<PointerType*> &getUnsafeTypes() const {
00040     return UnsafeTypes;
00041   }
00042 
00043   /// run - Inspect the operations that the specified module does on
00044   /// values of various types.  If they are deemed to be 'unsafe' note that the
00045   /// type is not safe to transform.
00046   ///
00047   virtual bool runOnModule(Module &M);
00048 
00049   /// print - Loop over the results of the analysis, printing out unsafe types.
00050   ///
00051   void print(std::ostream &o, const Module *Mod) const;
00052 
00053   /// getAnalysisUsage - Of course, we provide ourself...
00054   ///
00055   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
00056     AU.setPreservesAll();
00057   }
00058 };
00059 
00060 } // End llvm namespace
00061 
00062 #endif