1 //== ConstraintManager.cpp - Constraints on symbolic values -----*- C++ -*--==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defined the interface to manage constraints on symbolic values.
12 //===----------------------------------------------------------------------===//
14 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
16 using namespace clang;
19 ConstraintManager::~ConstraintManager() {}
21 static DefinedSVal getLocFromSymbol(const ProgramStateRef &State,
23 const MemRegion *R = State->getStateManager().getRegionManager()
24 .getSymbolicRegion(Sym);
25 return loc::MemRegionVal(R);
28 ConditionTruthVal ConstraintManager::checkNull(ProgramStateRef State,
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();