/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===- ConstraintManager.cpp - Constraints on symbolic values. ------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // |
9 | | // This file defined the interface to manage constraints on symbolic values. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h" |
14 | | #include "clang/AST/Type.h" |
15 | | #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" |
16 | | #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" |
17 | | #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h" |
18 | | #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" |
19 | | |
20 | | using namespace clang; |
21 | | using namespace ento; |
22 | | |
23 | 13.8k | ConstraintManager::~ConstraintManager() = default; |
24 | | |
25 | | static DefinedSVal getLocFromSymbol(const ProgramStateRef &State, |
26 | 0 | SymbolRef Sym) { |
27 | 0 | const MemRegion *R = |
28 | 0 | State->getStateManager().getRegionManager().getSymbolicRegion(Sym); |
29 | 0 | return loc::MemRegionVal(R); |
30 | 0 | } |
31 | | |
32 | | ConditionTruthVal ConstraintManager::checkNull(ProgramStateRef State, |
33 | 0 | SymbolRef Sym) { |
34 | 0 | QualType Ty = Sym->getType(); |
35 | 0 | DefinedSVal V = Loc::isLocType(Ty) ? getLocFromSymbol(State, Sym) |
36 | 0 | : nonloc::SymbolVal(Sym); |
37 | 0 | const ProgramStatePair &P = assumeDual(State, V); |
38 | 0 | if (P.first && !P.second) |
39 | 0 | return ConditionTruthVal(false); |
40 | 0 | if (!P.first && P.second) |
41 | 0 | return ConditionTruthVal(true); |
42 | 0 | return {}; |
43 | 0 | } |