diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-10-02 20:48:12 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-10-02 20:48:12 +0000 |
commit | d807f9065b43428f11da7b5e6a82a38a73286f5e (patch) | |
tree | 5fa4125be7c5b57b0b5c359788d2eef059d7ea90 | |
parent | be6edb3a700209c4e66bbd70ad9d70652a56efed (diff) | |
download | llvm-d807f9065b43428f11da7b5e6a82a38a73286f5e.zip llvm-d807f9065b43428f11da7b5e6a82a38a73286f5e.tar.gz llvm-d807f9065b43428f11da7b5e6a82a38a73286f5e.tar.bz2 |
[analyzer] Fix symbol discovery in nonloc::LocAsInteger values.
Doesn't do much despite sounding quite bad, but fixes an exotic test case where
liveness of a nonloc::LocAsInteger array index is now evaluated correctly.
Differential Revision: https://reviews.llvm.org/D52667
llvm-svn: 343631
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/SVals.cpp | 2 | ||||
-rw-r--r-- | clang/test/Analysis/symbol-reaper.c | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp index 559ca2c..b32be9e 100644 --- a/clang/lib/StaticAnalyzer/Core/SVals.cpp +++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp @@ -85,7 +85,7 @@ const FunctionDecl *SVal::getAsFunctionDecl() const { SymbolRef SVal::getAsLocSymbol(bool IncludeBaseRegions) const { // FIXME: should we consider SymbolRef wrapped in CodeTextRegion? if (Optional<nonloc::LocAsInteger> X = getAs<nonloc::LocAsInteger>()) - return X->getLoc().getAsLocSymbol(); + return X->getLoc().getAsLocSymbol(IncludeBaseRegions); if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) { const MemRegion *R = X->getRegion(); diff --git a/clang/test/Analysis/symbol-reaper.c b/clang/test/Analysis/symbol-reaper.c index a47161b..ef8ff18 100644 --- a/clang/test/Analysis/symbol-reaper.c +++ b/clang/test/Analysis/symbol-reaper.c @@ -85,8 +85,7 @@ void test_loc_as_integer_element_index_lifetime() { x = (int)&(s->field); ptr = &arr[x]; if (s) {} - // FIXME: Should not warn. The symbol is still alive within the ptr's index. - } while (0); // expected-warning{{SYMBOL DEAD}} + } while (0); } // Test below checks lifetime of SymbolRegionValue in certain conditions. |