2009-02-14 17:08:39 +00: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-22 18:53:20 +00:00
|
|
|
#ifndef LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
|
|
|
|
#define LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2011-02-10 01:03:03 +00:00
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h"
|
2011-08-15 22:09:50 +00:00
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
|
2009-02-14 17:08:39 +00:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
|
2010-12-23 07:20:52 +00:00
|
|
|
namespace ento {
|
2010-12-22 18:53:20 +00:00
|
|
|
|
2009-02-14 17:08:39 +00:00
|
|
|
class SimpleConstraintManager : public ConstraintManager {
|
2010-12-22 18:53:44 +00:00
|
|
|
SubEngine &SU;
|
2009-02-14 17:08:39 +00:00
|
|
|
public:
|
2010-12-22 18:53:44 +00:00
|
|
|
SimpleConstraintManager(SubEngine &subengine) : SU(subengine) {}
|
2009-09-09 15:08:12 +00:00
|
|
|
virtual ~SimpleConstraintManager();
|
|
|
|
|
2009-06-18 22:57:13 +00:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Common implementation for the interface provided by ConstraintManager.
|
|
|
|
//===------------------------------------------------------------------===//
|
2009-06-18 23:20:05 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
const ProgramState *assume(const ProgramState *state, DefinedSVal Cond,
|
2009-09-11 22:07:28 +00:00
|
|
|
bool Assumption);
|
2009-06-18 23:20:05 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
const ProgramState *assume(const ProgramState *state, Loc Cond, bool Assumption);
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
const ProgramState *assume(const ProgramState *state, NonLoc Cond, bool Assumption);
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
const ProgramState *assumeSymRel(const ProgramState *state,
|
2010-06-18 22:49:11 +00:00
|
|
|
const SymExpr *LHS,
|
|
|
|
BinaryOperator::Opcode op,
|
|
|
|
const llvm::APSInt& Int);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-06-18 22:57:13 +00:00
|
|
|
protected:
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-06-18 22:57:13 +00:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Interface that subclasses must implement.
|
|
|
|
//===------------------------------------------------------------------===//
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2010-06-18 22:49:11 +00:00
|
|
|
// Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison
|
|
|
|
// operation for the method being invoked.
|
2011-08-15 22:09:50 +00:00
|
|
|
virtual const ProgramState *assumeSymNE(const ProgramState *state, SymbolRef sym,
|
2010-06-18 22:49:11 +00:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
virtual const ProgramState *assumeSymEQ(const ProgramState *state, SymbolRef sym,
|
2010-06-18 22:49:11 +00:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
virtual const ProgramState *assumeSymLT(const ProgramState *state, SymbolRef sym,
|
2010-06-18 22:49:11 +00:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
virtual const ProgramState *assumeSymGT(const ProgramState *state, SymbolRef sym,
|
2010-06-18 22:49:11 +00:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
virtual const ProgramState *assumeSymLE(const ProgramState *state, SymbolRef sym,
|
2010-06-18 22:49:11 +00:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2011-08-15 22:09:50 +00:00
|
|
|
virtual const ProgramState *assumeSymGE(const ProgramState *state, SymbolRef sym,
|
2010-06-18 22:49:11 +00:00
|
|
|
const llvm::APSInt& V,
|
|
|
|
const llvm::APSInt& Adjustment) = 0;
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-06-18 22:57:13 +00:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Internal implementation.
|
|
|
|
//===------------------------------------------------------------------===//
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2011-12-05 21:33:06 +00:00
|
|
|
bool canReasonAbout(SVal X) const;
|
|
|
|
|
2011-12-05 18:58:19 +00:00
|
|
|
const ProgramState *assumeAux(const ProgramState *state,
|
|
|
|
Loc Cond,
|
|
|
|
bool Assumption);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2011-12-05 18:58:19 +00:00
|
|
|
const ProgramState *assumeAux(const ProgramState *state,
|
|
|
|
NonLoc Cond,
|
|
|
|
bool Assumption);
|
|
|
|
|
|
|
|
const ProgramState *assumeAuxForSymbol(const ProgramState *State,
|
|
|
|
SymbolRef Sym,
|
|
|
|
bool Assumption);
|
2009-02-14 17:08:39 +00:00
|
|
|
};
|
|
|
|
|
2010-12-22 18:53:20 +00:00
|
|
|
} // end GR namespace
|
|
|
|
|
|
|
|
} // end clang namespace
|
2009-02-14 17:08:39 +00:00
|
|
|
|
2009-02-15 18:24:51 +00:00
|
|
|
#endif
|