[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
This commit is contained in:
Artem Dergachev 2018-10-02 20:48:12 +00:00
parent be6edb3a70
commit d807f9065b
2 changed files with 2 additions and 3 deletions

View File

@ -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();

View File

@ -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.