1 //===- llvm/Analysis/SafePointerAccess.h - Check pointer safety ---*- C++ -*-=//
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.
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.
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 // -unsafeptrinst to the command line of the tool you want to get it.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_ANALYSIS_SAFEPOINTERACCESS_H
18 #define LLVM_ANALYSIS_SAFEPOINTERACCESS_H
20 #include "llvm/Pass.h"
25 struct FindUnsafePointerTypes : public MethodPass {
26 // UnsafeTypes - Set of types that are not safe to transform.
27 std::set<PointerType*> UnsafeTypes;
30 // Accessor for underlying type set...
31 inline const std::set<PointerType*> &getUnsafeTypes() const {
35 // runOnMethod - Inspect the operations that the specified method does on
36 // values of various types. If they are deemed to be 'unsafe' note that the
37 // type is not safe to transform.
39 virtual bool runOnMethod(Method *M);
41 // printResults - Loop over the results of the analysis, printing out unsafe
44 void printResults(const Module *Mod, std::ostream &o);