]> granicus.if.org Git - clang/commitdiff
Discard qualifiers for ElementRegions so that a 'const' doesn't change the lookup...
authorTed Kremenek <kremenek@apple.com>
Thu, 27 May 2010 00:29:00 +0000 (00:29 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 27 May 2010 00:29:00 +0000 (00:29 +0000)
in the symbol store.  We may wish to push this down into the StoreManager itself.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104788 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Checker/MemRegion.cpp
test/Analysis/misc-ps-region-store.m

index 9a664c78a77c0dd98b8aec4fe4666705edd8d23a..575458c9dc798762c9d9d1f57a093be71b750e7b 100644 (file)
@@ -539,7 +539,7 @@ MemRegionManager::getElementRegion(QualType elementType, SVal Idx,
                                    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);
index 42551417a2a5791b152852dfece42b35d440659b..52516abc397bd89f2073d81d369b1df65fbbf81c 100644 (file)
@@ -1014,3 +1014,22 @@ void pr6854(void * arg) {
   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;
+}
+