2009-02-15 01:08:39 +08:00
|
|
|
//== SimpleConstraintManager.h ----------------------------------*- C++ -*--==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Code shared between BasicConstraintManager and RangeConstraintManager.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-12-23 02:53:20 +08:00
|
|
|
#ifndef LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
|
|
|
|
#define LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2011-02-10 09:03:03 +08:00
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h"
|
2011-08-16 06:09:50 +08:00
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
|
2009-02-15 01:08:39 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
|
2010-12-23 15:20:52 +08:00
|
|
|
namespace ento {
|
2010-12-23 02:53:20 +08:00
|
|
|
|
2009-02-15 01:08:39 +08:00
|
|
|
class SimpleConstraintManager : public ConstraintManager {
|
2010-12-23 02:53:44 +08:00
|
|
|
SubEngine &SU;
|
2012-05-08 11:27:16 +08:00
|
|
|
BasicValueFactory &BVF;
|
2009-02-15 01:08:39 +08:00
|
|
|
public:
|
2012-05-08 11:27:16 +08:00
|
|
|
SimpleConstraintManager(SubEngine &subengine, BasicValueFactory &BV)
|
|
|
|
: SU(subengine), BVF(BV) {}
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual ~SimpleConstraintManager();
|
|
|
|
|
2009-06-19 06:57:13 +08:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Common implementation for the interface provided by ConstraintManager.
|
|
|
|
//===------------------------------------------------------------------===//
|
2009-06-19 07:20:05 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond,
|
2009-09-12 06:07:28 +08:00
|
|
|
bool Assumption);
|
2009-06-19 07:20:05 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
ProgramStateRef assume(ProgramStateRef state, Loc Cond, bool Assumption);
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption);
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
ProgramStateRef assumeSymRel(ProgramStateRef state,
|
2010-06-19 06:49:11 +08:00
|
|
|
const SymExpr *LHS,
|
|
|
|
BinaryOperator::Opcode op,
|
|
|
|
const llvm::APSInt& Int);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-19 06:57:13 +08:00
|
|
|
protected:
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-19 06:57:13 +08:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Interface that subclasses must implement.
|
|
|
|
//===------------------------------------------------------------------===//
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-19 06:49:11 +08:00
|
|
|
// Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison
|
|
|
|
// operation for the method being invoked.
|
2012-01-27 05:29:00 +08:00
|
|
|
virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym,
|
2010-06-19 06:49:11 +08:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym,
|
2010-06-19 06:49:11 +08:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym,
|
2010-06-19 06:49:11 +08:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym,
|
2010-06-19 06:49:11 +08:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
virtual ProgramStateRef assumeSymLE(ProgramStateRef state, SymbolRef sym,
|
2010-06-19 06:49:11 +08:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
virtual ProgramStateRef assumeSymGE(ProgramStateRef state, SymbolRef sym,
|
2010-06-19 06:49:11 +08:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-19 06:57:13 +08:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Internal implementation.
|
|
|
|
//===------------------------------------------------------------------===//
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2012-05-08 11:27:16 +08:00
|
|
|
BasicValueFactory &getBasicVals() const { return BVF; }
|
|
|
|
|
2011-12-06 05:33:06 +08:00
|
|
|
bool canReasonAbout(SVal X) const;
|
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
ProgramStateRef assumeAux(ProgramStateRef state,
|
2011-12-06 02:58:19 +08:00
|
|
|
Loc Cond,
|
|
|
|
bool Assumption);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
ProgramStateRef assumeAux(ProgramStateRef state,
|
2011-12-06 02:58:19 +08:00
|
|
|
NonLoc Cond,
|
|
|
|
bool Assumption);
|
|
|
|
|
2012-01-27 05:29:00 +08:00
|
|
|
ProgramStateRef assumeAuxForSymbol(ProgramStateRef State,
|
2011-12-06 02:58:19 +08:00
|
|
|
SymbolRef Sym,
|
|
|
|
bool Assumption);
|
2009-02-15 01:08:39 +08:00
|
|
|
};
|
|
|
|
|
2010-12-23 02:53:20 +08:00
|
|
|
} // end GR namespace
|
|
|
|
|
|
|
|
} // end clang namespace
|
2009-02-15 01:08:39 +08:00
|
|
|
|
2009-02-16 02:24:51 +08:00
|
|
|
#endif
|