[cfe-commits] r73189 - in /cfe/trunk: lib/Analysis/RegionStore.cpp test/Analysis/array-struct.c

Zhongxing Xu xuzhongxing at gmail.com
Thu Jun 11 02:11:42 PDT 2009


Author: zhongxingxu
Date: Thu Jun 11 04:11:27 2009
New Revision: 73189

URL: http://llvm.org/viewvc/llvm-project?rev=73189&view=rev
Log:
Bind the mistakenly generated nonloc::SymbolVal to struct correctly. See the
comments for added test case for details.

Modified:
    cfe/trunk/lib/Analysis/RegionStore.cpp
    cfe/trunk/test/Analysis/array-struct.c

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Jun 11 04:11:27 2009
@@ -1198,6 +1198,9 @@
   if (V.isUnknown())
     return KillStruct(St, R);
 
+  if (isa<nonloc::SymbolVal>(V))
+    return setDefaultValue(St, R, V);
+
   nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(V);
   nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
   RecordDecl::field_iterator FI = RD->field_begin(getContext()), 

Modified: cfe/trunk/test/Analysis/array-struct.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/array-struct.c?rev=73189&r1=73188&r2=73189&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/array-struct.c (original)
+++ cfe/trunk/test/Analysis/array-struct.c Thu Jun 11 04:11:27 2009
@@ -148,3 +148,13 @@
   if (a[1]) // no-warning
     1;
 }
+
+struct s3 p[1];
+
+// Code from postgresql.
+// Current cast logic of region store mistakenly leaves the final result region
+// an ElementRegion of type 'char'. Then load a nonloc::SymbolVal from it and
+// assigns to 'a'. 
+void f16(struct s3 *p) {
+  struct s3 a = *((struct s3*) ((char*) &p[0]));
+}





More information about the cfe-commits mailing list