NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, 
rnkovacs.
Herald added subscribers: cfe-commits, Szelethus, mikhail.ramalho, 
baloghadamsoftware.

The thing i promised to fix in the last bullet of 
https://reviews.llvm.org/D44347:

> `SymbolReaper::markElementIndicesLive()` scans an array symbol, which is 
> always a NonLoc. However, it may still be a nonloc::LocAsInteger, and in this 
> case descend to the symbolic base would be necessary, as demonstrated by 
> `test_loc_as_integer_element_index_lifetime()`. This test, however, is not 
> fixed by the current patch, due to `getAsLocSymbol()` incorrectly failing to 
> pass its IncludeBaseRegions argument into the recursive call. But i decided 
> not to investigate it further today, because, well, enough is enough.


Repository:
  rC Clang

https://reviews.llvm.org/D52667

Files:
  lib/StaticAnalyzer/Core/SVals.cpp
  test/Analysis/symbol-reaper.c


Index: test/Analysis/symbol-reaper.c
===================================================================
--- test/Analysis/symbol-reaper.c
+++ test/Analysis/symbol-reaper.c
@@ -85,8 +85,7 @@
     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.
Index: lib/StaticAnalyzer/Core/SVals.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SVals.cpp
+++ lib/StaticAnalyzer/Core/SVals.cpp
@@ -85,7 +85,7 @@
 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();


Index: test/Analysis/symbol-reaper.c
===================================================================
--- test/Analysis/symbol-reaper.c
+++ test/Analysis/symbol-reaper.c
@@ -85,8 +85,7 @@
     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.
Index: lib/StaticAnalyzer/Core/SVals.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SVals.cpp
+++ lib/StaticAnalyzer/Core/SVals.cpp
@@ -85,7 +85,7 @@
 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();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D52667: [analyzer]... Artem Dergachev via Phabricator via cfe-commits

Reply via email to