]> granicus.if.org Git - clang/commitdiff
Treat AllocaRegion as SymbolicRegion in RegionStore::Retrieve().
authorZhongxing Xu <xuzhongxing@gmail.com>
Wed, 20 May 2009 09:18:48 +0000 (09:18 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Wed, 20 May 2009 09:18:48 +0000 (09:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72166 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/RegionStore.cpp
test/Analysis/array-struct.c

index be34bd57b85424fa3b45f2a431bb2bb9c1f259ea..02d3d1f885f956cefb4a127f78a484bd25bac9f4 100644 (file)
@@ -705,10 +705,13 @@ SVal RegionStoreManager::Retrieve(const GRState* St, Loc L, QualType T) {
 
   const MemRegion* MR = cast<loc::MemRegionVal>(L).getRegion();
 
-  // We return unknown for symbolic region for now. This might be improved.
+  // FIXME: return symbolic value for these cases.
   // Example:
   // void f(int* p) { int x = *p; }
-  if (isa<SymbolicRegion>(MR))
+  // char* p = alloca();
+  // read(p);
+  // c = *p;
+  if (isa<SymbolicRegion>(MR) || isa<AllocaRegion>(MR))
     return UnknownVal();
 
   // FIXME: Perhaps this method should just take a 'const MemRegion*' argument
index e602d5f5276b5f0ecb679637317988dfe5716f64..c0e1d8b7e39f7107af1100f6e0aa749b60668fb9 100644 (file)
@@ -15,6 +15,7 @@ typedef struct {
   int data;
 } STYPE;
 
+void g(char *p);
 void g1(struct s* p);
 
 // Array to pointer conversion. Array in the struct field.
@@ -62,6 +63,8 @@ void f5() {
 void f6() {
   char *p;
   p = __builtin_alloca(10); 
+  g(p);
+  char c = *p;
   p[1] = 'a';
   // Test if RegionStore::EvalBinOp converts the alloca region to element
   // region.
@@ -98,7 +101,7 @@ void f10() {
 // Retrieve the default value of element/field region.
 void f11() {
   struct s a;
-  g(&a);
+  g1(&a);
   if (a.data == 0) // no-warning
     a.data = 1;
 }