[cfe-commits] r59943 - in /cfe/trunk: lib/Analysis/RegionStore.cpp test/Analysis/outofbound.c

Zhongxing Xu xuzhongxing at gmail.com
Sun Nov 23 21:16:02 PST 2008


Author: zhongxingxu
Date: Sun Nov 23 23:16:01 2008
New Revision: 59943

URL: http://llvm.org/viewvc/llvm-project?rev=59943&view=rev
Log:
Strings are NULL terminated. So the region size should plus one.

Modified:
    cfe/trunk/lib/Analysis/RegionStore.cpp
    cfe/trunk/test/Analysis/outofbound.c

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=59943&r1=59942&r2=59943&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Sun Nov 23 23:16:01 2008
@@ -275,7 +275,7 @@
     const StringLiteral* Str = SR->getStringLiteral();
     // We intentionally made the size value signed because it participates in 
     // operations with signed indices.
-    return NonLoc::MakeVal(getBasicVals(), Str->getByteLength(), false);
+    return NonLoc::MakeVal(getBasicVals(), Str->getByteLength() + 1, false);
   }
 
   if (const AnonTypedRegion* ATR = dyn_cast<AnonTypedRegion>(R)) {

Modified: cfe/trunk/test/Analysis/outofbound.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/outofbound.c?rev=59943&r1=59942&r2=59943&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/outofbound.c (original)
+++ cfe/trunk/test/Analysis/outofbound.c Sun Nov 23 23:16:01 2008
@@ -2,5 +2,5 @@
 
 char f1() {
   char* s = "abcd";
-  return s[4]; // expected-warning{{Load or store into an out-of-bound memory position.}}
+  return s[5]; // expected-warning{{Load or store into an out-of-bound memory position.}}
 }





More information about the cfe-commits mailing list