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_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H
00015 #define LLVM_CLANG_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_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   SValBuilder &SVB;
00027 public:
00028   SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB)
00029     : SU(subengine), SVB(SB) {}
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) override;
00038 
00039   ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption);
00040 
00041   ProgramStateRef assumeSymRel(ProgramStateRef state,
00042                               const SymExpr *LHS,
00043                               BinaryOperator::Opcode op,
00044                               const llvm::APSInt& Int);
00045 
00046 protected:
00047 
00048   //===------------------------------------------------------------------===//
00049   // Interface that subclasses must implement.
00050   //===------------------------------------------------------------------===//
00051 
00052   // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison
00053   // operation for the method being invoked.
00054   virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym,
00055                                      const llvm::APSInt& V,
00056                                      const llvm::APSInt& Adjustment) = 0;
00057 
00058   virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym,
00059                                      const llvm::APSInt& V,
00060                                      const llvm::APSInt& Adjustment) = 0;
00061 
00062   virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym,
00063                                      const llvm::APSInt& V,
00064                                      const llvm::APSInt& Adjustment) = 0;
00065 
00066   virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym,
00067                                      const llvm::APSInt& V,
00068                                      const llvm::APSInt& Adjustment) = 0;
00069 
00070   virtual ProgramStateRef assumeSymLE(ProgramStateRef state, SymbolRef sym,
00071                                      const llvm::APSInt& V,
00072                                      const llvm::APSInt& Adjustment) = 0;
00073 
00074   virtual ProgramStateRef assumeSymGE(ProgramStateRef state, SymbolRef sym,
00075                                      const llvm::APSInt& V,
00076                                      const llvm::APSInt& Adjustment) = 0;
00077 
00078   //===------------------------------------------------------------------===//
00079   // Internal implementation.
00080   //===------------------------------------------------------------------===//
00081 
00082   BasicValueFactory &getBasicVals() const { return SVB.getBasicValueFactory(); }
00083   SymbolManager &getSymbolManager() const { return SVB.getSymbolManager(); }
00084 
00085   bool canReasonAbout(SVal X) const override;
00086 
00087   ProgramStateRef assumeAux(ProgramStateRef state,
00088                                 NonLoc Cond,
00089                                 bool Assumption);
00090 
00091   ProgramStateRef assumeAuxForSymbol(ProgramStateRef State,
00092                                          SymbolRef Sym,
00093                                          bool Assumption);
00094 };
00095 
00096 } // end GR namespace
00097 
00098 } // end clang namespace
00099 
00100 #endif