[cfe-commits] r104788 - in /cfe/trunk: lib/Checker/MemRegion.cpp test/Analysis/misc-ps-region-store.m

Ted Kremenek kremenek at apple.com
Wed May 26 17:29:01 PDT 2010


Author: kremenek
Date: Wed May 26 19:29:00 2010
New Revision: 104788

URL: http://llvm.org/viewvc/llvm-project?rev=104788&view=rev
Log:
Discard qualifiers for ElementRegions so that a 'const' doesn't change the lookup semantics
in the symbol store.  We may wish to push this down into the StoreManager itself.

Modified:
    cfe/trunk/lib/Checker/MemRegion.cpp
    cfe/trunk/test/Analysis/misc-ps-region-store.m

Modified: cfe/trunk/lib/Checker/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/MemRegion.cpp?rev=104788&r1=104787&r2=104788&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/MemRegion.cpp (original)
+++ cfe/trunk/lib/Checker/MemRegion.cpp Wed May 26 19:29:00 2010
@@ -539,7 +539,7 @@
                                    const MemRegion* superRegion,
                                    ASTContext& Ctx){
 
-  QualType T = Ctx.getCanonicalType(elementType);
+  QualType T = Ctx.getCanonicalType(elementType).getUnqualifiedType();
 
   llvm::FoldingSetNodeID ID;
   ElementRegion::ProfileRegion(ID, T, Idx, superRegion);

Modified: cfe/trunk/test/Analysis/misc-ps-region-store.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.m?rev=104788&r1=104787&r2=104788&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.m Wed May 26 19:29:00 2010
@@ -1014,3 +1014,22 @@
   float f = *(float*) a;
 }
 
+// <rdar://problem/8032791> False positive due to symbolic store not find
+//  value because of 'const' qualifier
+double rdar_8032791_2();
+double rdar_8032791_1() {
+   struct R8032791 { double x[2]; double y; }
+   data[3] = {
+     {{1.0, 3.0}, 3.0},  //  1   2   3
+     {{1.0, 1.0}, 0.0},  // 1 1 2 2 3 3
+     {{1.0, 3.0}, 1.0}   //    1   2   3
+   };
+
+   double x = 0.0;
+   for (unsigned i = 0 ; i < 3; i++) {
+     const struct R8032791 *p = &data[i];
+     x += p->y + rdar_8032791_2(); // no-warning
+   }
+   return x;
+}
+





More information about the cfe-commits mailing list