From: Artem Dergachev Date: Tue, 2 Oct 2018 20:48:12 +0000 (+0000) Subject: [analyzer] Fix symbol discovery in nonloc::LocAsInteger values. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88f8d0b7bde3dd01632109249802bdccd348ceb6;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343631 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/SVals.cpp b/lib/StaticAnalyzer/Core/SVals.cpp index 559ca2c984..b32be9e82d 100644 --- a/lib/StaticAnalyzer/Core/SVals.cpp +++ b/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 X = getAs()) - return X->getLoc().getAsLocSymbol(); + return X->getLoc().getAsLocSymbol(IncludeBaseRegions); if (Optional X = getAs()) { const MemRegion *R = X->getRegion(); diff --git a/test/Analysis/symbol-reaper.c b/test/Analysis/symbol-reaper.c index a47161bea2..ef8ff18a2d 100644 --- a/test/Analysis/symbol-reaper.c +++ b/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.