[cfe-commits] r113888 - in /cfe/trunk: lib/Checker/RegionStore.cpp test/Analysis/misc-ps-region-store.m
Ted Kremenek
kremenek at apple.com
Tue Sep 14 16:08:35 PDT 2010
Author: kremenek
Date: Tue Sep 14 18:08:34 2010
New Revision: 113888
URL: http://llvm.org/viewvc/llvm-project?rev=113888&view=rev
Log:
Don't divide-by-zero in RegionStoreManager::getSizeInElements() when getting the size of a VLA. We don't track VLA extents yet,
but we should at least not crash. Fixes <rdar://problem/8424269>.
Modified:
cfe/trunk/lib/Checker/RegionStore.cpp
cfe/trunk/test/Analysis/misc-ps-region-store.m
Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=113888&r1=113887&r2=113888&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Tue Sep 14 18:08:34 2010
@@ -745,6 +745,14 @@
return UnknownVal();
CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+ if (Ctx.getAsVariableArrayType(EleTy)) {
+ // FIXME: We need to track extra state to properly record the size
+ // of VLAs. Returning UnknownVal here, however, is a stop-gap so that
+ // we don't have a divide-by-zero below.
+ return UnknownVal();
+ }
+
CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
// If a variable is reinterpreted as a type that doesn't fit into a larger
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=113888&r1=113887&r2=113888&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.m Tue Sep 14 18:08:34 2010
@@ -1156,3 +1156,30 @@
{
}
}
+
+// <rdar://problem/8424269> - Handle looking at the size of a VLA in
+// ArrayBoundChecker. Nothing intelligent (yet); just don't crash.
+typedef struct RDar8424269_A {
+ int RDar8424269_C;
+} RDar8424269_A;
+static void RDar8424269_B(RDar8424269_A *p, unsigned char *RDar8424269_D,
+ const unsigned char *RDar8424269_E, int RDar8424269_F,
+ int b_w, int b_h, int dx, int dy) {
+ int x, y, b, r, l;
+ unsigned char tmp2t[3][RDar8424269_F * (32 + 8)];
+ unsigned char *tmp2 = tmp2t[0];
+ if (p && !p->RDar8424269_C)
+ b = 15;
+ tmp2 = tmp2t[1];
+ if (b & 2) { // expected-warning{{The left operand of '&' is a garbage value}}
+ for (y = 0; y < b_h; y++) {
+ for (x = 0; x < b_w + 1; x++) {
+ int am = 0;
+ tmp2[x] = am;
+ }
+ }
+ }
+ tmp2 = tmp2t[2];
+}
+
+
More information about the cfe-commits
mailing list