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

Zhongxing Xu xuzhongxing at gmail.com
Sun Jun 28 23:43:42 PDT 2009


Author: zhongxingxu
Date: Mon Jun 29 01:43:40 2009
New Revision: 74419

URL: http://llvm.org/viewvc/llvm-project?rev=74419&view=rev
Log:
Invalidate the alloca region by setting its default value to conjured symbol.

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

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

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Mon Jun 29 01:43:40 2009
@@ -2796,7 +2796,7 @@
         //  to identify conjured symbols by an expression pair: the enclosing
         //  expression (the context) and the expression itself.  This should
         //  disambiguate conjured symbols. 
-        
+        unsigned Count = Builder.getCurrentBlockCount();
         const TypedRegion* R = dyn_cast<TypedRegion>(MR->getRegion());
 
         if (R) {
@@ -2833,7 +2833,7 @@
           
           if (R->isBoundable()) {
             // Set the value of the variable to be a conjured symbol.
-            unsigned Count = Builder.getCurrentBlockCount();
+
             QualType T = R->getValueType(Ctx);
           
             if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())){
@@ -2895,6 +2895,15 @@
             }
           }
         }
+        else if (isa<AllocaRegion>(MR->getRegion())) {
+          // Invalidate the alloca region by setting its default value to 
+          // conjured symbol. The type of the symbol is irrelavant.
+          SVal V = ValMgr.getConjuredSymbolVal(*I, Eng.getContext().IntTy, 
+                                               Count);
+          StoreManager& StoreMgr = 
+                    Eng.getStateManager().getStoreManager();
+          state = StoreMgr.setDefaultValue(state, MR->getRegion(), V);
+        }
         else
           state = state->bindLoc(*MR, UnknownVal());
       }

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

==============================================================================
--- cfe/trunk/test/Analysis/array-struct.c (original)
+++ cfe/trunk/test/Analysis/array-struct.c Mon Jun 29 01:43:40 2009
@@ -168,3 +168,15 @@
   if (t.e.d)
     x = 1;
 }
+
+void read(char*);
+
+void f18() {
+  char *q;
+  char *p = (char *) __builtin_alloca(10);
+  read(p);
+  q = p;
+  q++;
+  if (*q) { // no-warning
+  }
+}





More information about the cfe-commits mailing list