clang API Documentation

SimpleConstraintManager.h
Go to the documentation of this file.
00001 //== SimpleConstraintManager.h ----------------------------------*- C++ -*--==//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  Code shared between BasicConstraintManager and RangeConstraintManager.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
00015 #define LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
00016 
00017 #include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h"
00018 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
00019 
00020 namespace clang {
00021 
00022 namespace ento {
00023 
00024 class SimpleConstraintManager : public ConstraintManager {
00025   SubEngine &SU;
00026   BasicValueFactory &BVF;
00027 public:
00028   SimpleConstraintManager(SubEngine &subengine, BasicValueFactory &BV)
00029     : SU(subengine), BVF(BV) {}
00030   virtual ~SimpleConstraintManager();
00031 
00032   //===------------------------------------------------------------------===//
00033   // Common implementation for the interface provided by ConstraintManager.
00034   //===------------------------------------------------------------------===//
00035 
00036   ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond,
00037                         bool Assumption);
00038 
00039   ProgramStateRef assume(ProgramStateRef state, Loc Cond, bool Assumption);
00040 
00041   ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption);
00042 
00043   ProgramStateRef assumeSymRel(ProgramStateRef state,
00044                               const SymExpr *LHS,
00045                               BinaryOperator::Opcode op,
00046                               const llvm::APSInt& Int);
00047 
00048 protected:
00049 
00050   //===------------------------------------------------------------------===//
00051   // Interface that subclasses must implement.
00052   //===------------------------------------------------------------------===//
00053 
00054   // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison
00055   // operation for the method being invoked.
00056   virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym,
00057                                      const llvm::APSInt& V,
00058                                      const llvm::APSInt& Adjustment) = 0;
00059 
00060   virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym,
00061                                      const llvm::APSInt& V,
00062                                      const llvm::APSInt& Adjustment) = 0;
00063 
00064   virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym,
00065                                      const llvm::APSInt& V,
00066                                      const llvm::APSInt& Adjustment) = 0;
00067 
00068   virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym,
00069                                      const llvm::APSInt& V,
00070                                      const llvm::APSInt& Adjustment) = 0;
00071 
00072   virtual ProgramStateRef assumeSymLE(ProgramStateRef state, SymbolRef sym,
00073                                      const llvm::APSInt& V,
00074                                      const llvm::APSInt& Adjustment) = 0;
00075 
00076   virtual ProgramStateRef assumeSymGE(ProgramStateRef state, SymbolRef sym,
00077                                      const llvm::APSInt& V,
00078                                      const llvm::APSInt& Adjustment) = 0;
00079 
00080   //===------------------------------------------------------------------===//
00081   // Internal implementation.
00082   //===------------------------------------------------------------------===//
00083 
00084   BasicValueFactory &getBasicVals() const { return BVF; }
00085 
00086   bool canReasonAbout(SVal X) const;
00087 
00088   ProgramStateRef assumeAux(ProgramStateRef state,
00089                                 Loc Cond,
00090                                 bool Assumption);
00091 
00092   ProgramStateRef assumeAux(ProgramStateRef state,
00093                                 NonLoc Cond,
00094                                 bool Assumption);
00095 
00096   ProgramStateRef assumeAuxForSymbol(ProgramStateRef State,
00097                                          SymbolRef Sym,
00098                                          bool Assumption);
00099 };
00100 
00101 } // end GR namespace
00102 
00103 } // end clang namespace
00104 
00105 #endif