clang  7.0.0svn
ConstraintManager.cpp
Go to the documentation of this file.
1 //===- ConstraintManager.cpp - Constraints on symbolic values. ------------===//
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 #include "clang/AST/Type.h"
20 
21 using namespace clang;
22 using namespace ento;
23 
25 
27  SymbolRef Sym) {
28  const MemRegion *R =
29  State->getStateManager().getRegionManager().getSymbolicRegion(Sym);
30  return loc::MemRegionVal(R);
31 }
32 
34  SymbolRef Sym) {
35  QualType Ty = Sym->getType();
36  DefinedSVal V = Loc::isLocType(Ty) ? getLocFromSymbol(State, Sym)
37  : nonloc::SymbolVal(Sym);
38  const ProgramStatePair &P = assumeDual(State, V);
39  if (P.first && !P.second)
40  return ConditionTruthVal(false);
41  if (!P.first && P.second)
42  return ConditionTruthVal(true);
43  return {};
44 }
A (possibly-)qualified type.
Definition: Type.h:655
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:94
C Language Family Type Representation.
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:30
LineState State
static bool isLocType(QualType T)
Definition: SVals.h:327
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)
Dataflow Directional Tag Classes.
Represents symbolic expression that isn't a location.
Definition: SVals.h:347
std::pair< ProgramStateRef, ProgramStateRef > ProgramStatePair