clang  6.0.0svn
ConstraintManager.cpp
Go to the documentation of this file.
1 //== ConstraintManager.cpp - Constraints on symbolic values -----*- C++ -*--==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defined the interface to manage constraints on symbolic values.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 
16 using namespace clang;
17 using namespace ento;
18 
20 
22  SymbolRef Sym) {
23  const MemRegion *R =
24  State->getStateManager().getRegionManager().getSymbolicRegion(Sym);
25  return loc::MemRegionVal(R);
26 }
27 
29  SymbolRef Sym) {
30  QualType Ty = Sym->getType();
31  DefinedSVal V = Loc::isLocType(Ty) ? getLocFromSymbol(State, Sym)
32  : nonloc::SymbolVal(Sym);
33  const ProgramStatePair &P = assumeDual(State, V);
34  if (P.first && !P.second)
35  return ConditionTruthVal(false);
36  if (!P.first && P.second)
37  return ConditionTruthVal(true);
38  return ConditionTruthVal();
39 }
A (possibly-)qualified type.
Definition: Type.h:653
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:79
StringRef P
virtual ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym)
Returns whether or not a symbol is known to be null ("true"), known to be non-null ("false")...
Symbolic value.
Definition: SymExpr.h:29
LineState State
static bool isLocType(QualType T)
Definition: SVals.h:308
virtual QualType getType() const =0
ProgramStatePair assumeDual(ProgramStateRef State, DefinedSVal Cond)
Returns a pair of states (StTrue, StFalse) where the given condition is assumed to be true or false...
static DefinedSVal getLocFromSymbol(const ProgramStateRef &State, SymbolRef Sym)
std::pair< ProgramStateRef, ProgramStateRef > ProgramStatePair
Dataflow Directional Tag Classes.
Represents symbolic expression.
Definition: SVals.h:327