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

Zhongxing Xu xuzhongxing at gmail.com
Thu Jun 18 21:51:14 PDT 2009


Author: zhongxingxu
Date: Thu Jun 18 23:51:14 2009
New Revision: 73754

URL: http://llvm.org/viewvc/llvm-project?rev=73754&view=rev
Log:
If the SymbolicRegion was cast to another type, use that type to create the 
ElementRegion.

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

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Jun 18 23:51:14 2009
@@ -749,9 +749,15 @@
   // If the operand is a symbolic or alloca region, create the first element
   // region on it.
   if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR)) {
-    // Get symbol's type. It should be a pointer type.
-    SymbolRef Sym = SR->getSymbol();
-    QualType T = Sym->getType(getContext());
+    QualType T;
+    // If the SymbolicRegion was cast to another type, use that type.
+    if (const QualType *t = state->get<RegionCasts>(SR)) {
+      T = *t;
+    } else {
+      // Otherwise use the symbol's type.
+      SymbolRef Sym = SR->getSymbol();
+      T = Sym->getType(getContext());
+    }
     QualType EleTy = T->getAsPointerType()->getPointeeType();
 
     SVal ZeroIdx = ValMgr.makeZeroArrayIndex();

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

==============================================================================
--- cfe/trunk/test/Analysis/casts.c (original)
+++ cfe/trunk/test/Analysis/casts.c Thu Jun 18 23:51:14 2009
@@ -27,3 +27,12 @@
   char c = (unsigned char) *tbool; // Should use cast-to type to create symbol.
 }
 
+void f2(const char *str) {
+ unsigned char ch, cl, *p;
+
+ p = (unsigned char *)str;
+ ch = *p++; // use cast-to type 'unsigned char' to create element region.
+ cl = *p++;
+ if(!cl)
+    cl = 'a';
+}





More information about the cfe-commits mailing list