diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-07-17 00:22:27 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-07-17 00:22:27 +0000 |
commit | d1163790c363bb47c4b072dc679522941ebf55ca (patch) | |
tree | c50beddb06bc58c315b4478a9a9b56c71847d397 | |
parent | 0a9969b36b16307e6cf60004b108be972c93d336 (diff) | |
download | bcm5719-llvm-d1163790c363bb47c4b072dc679522941ebf55ca.tar.gz bcm5719-llvm-d1163790c363bb47c4b072dc679522941ebf55ca.zip |
[analyzer] Assert that nonloc::SymbolVal always wraps a non-Loc-type symbol.
In the current SVal hierarchy there are multiple ways of representing certain
values but few are actually used and expected to be seen by the code.
In particular, a value of a symbolic pointer is always represented by a
loc::MemRegionVal that wraps a SymbolicRegion that wraps the pointer symbol
and never by a nonloc::SymbolVal that wraps that symbol directly.
Assert the aforementioned fact. Fix one minor violation of it.
Differential Revision: https://reviews.llvm.org/D48205
llvm-svn: 337227
-rw-r--r-- | clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h | 7 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index f3f2aa3f8f5..0fde63e9eb0 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -343,11 +343,14 @@ private: namespace nonloc { -/// Represents symbolic expression. +/// Represents symbolic expression that isn't a location. class SymbolVal : public NonLoc { public: SymbolVal() = delete; - SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) { assert(sym); } + SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) { + assert(sym); + assert(!Loc::isLocType(sym->getType())); + } SymbolRef getSymbol() const { return (const SymExpr *) Data; diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp index a73ffd6ec19..c08cbb09ba8 100644 --- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -1238,7 +1238,7 @@ SVal SimpleSValBuilder::simplifySVal(ProgramStateRef State, SVal V) { SVal VisitSymbolData(const SymbolData *S) { if (const llvm::APSInt *I = - SVB.getKnownValue(State, nonloc::SymbolVal(S))) + SVB.getKnownValue(State, SVB.makeSymbolVal(S))) return Loc::isLocType(S->getType()) ? (SVal)SVB.makeIntLocVal(*I) : (SVal)SVB.makeIntVal(*I); return SVB.makeSymbolVal(S); |