r343631 - [analyzer] Fix symbol discovery in nonloc::LocAsInteger values.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 2 13:48:12 PDT 2018


Author: dergachev
Date: Tue Oct  2 13:48:12 2018
New Revision: 343631

URL: http://llvm.org/viewvc/llvm-project?rev=343631&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
    cfe/trunk/test/Analysis/symbol-reaper.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp?rev=343631&r1=343630&r2=343631&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp Tue Oct  2 13:48:12 2018
@@ -85,7 +85,7 @@ const FunctionDecl *SVal::getAsFunctionD
 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();

Modified: cfe/trunk/test/Analysis/symbol-reaper.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/symbol-reaper.c?rev=343631&r1=343630&r2=343631&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/symbol-reaper.c (original)
+++ cfe/trunk/test/Analysis/symbol-reaper.c Tue Oct  2 13:48:12 2018
@@ -85,8 +85,7 @@ void test_loc_as_integer_element_index_l
     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.




More information about the cfe-commits mailing list