]> granicus.if.org Git - clang/commitdiff
Small tweaks to the transfer function for DeclStmt: do not mark external global
authorTed Kremenek <kremenek@apple.com>
Wed, 27 Feb 2008 19:21:33 +0000 (19:21 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 27 Feb 2008 19:21:33 +0000 (19:21 +0000)
variables as uninitialized, and only "initialize" static function variables.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47683 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRExprEngine.cpp

index 86bd2700d71fecfd9d223e1a0f4f60e272c663b4..f227160bfb1fdccfa7d90fcb73c9baaa741d4910 100644 (file)
@@ -592,12 +592,24 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, GRExprEngine::NodeTy* Pred,
       if (VD->getType()->isArrayType())
         continue;
       
-      // FIXME: static variables have an initializer, but the second
-      //  time a function is called those values may not be current.
-      const Expr* Ex = VD->getInit(); 
+      const Expr* Ex = VD->getInit();
       
-      St = SetRVal(St, lval::DeclVal(VD),
-                   Ex ? GetRVal(St, Ex) : UninitializedVal());
+      if (!VD->hasGlobalStorage() || VD->getStorageClass() == VarDecl::Static) {
+        
+        // In this context, Static => Local variable.
+        
+        assert (!VD->getStorageClass() == VarDecl::Static ||
+                !isa<FileVarDecl>(VD));
+        
+        // If there is no initializer, set the value of the
+        // variable to "Uninitialized".
+        //
+        // FIXME: static variables may have an initializer, but the second
+        //  time a function is called those values may not be current.
+        
+        St = SetRVal(St, lval::DeclVal(VD),
+                     Ex ? GetRVal(St, Ex) : UninitializedVal());
+      }
     }
 
   Nodify(Dst, DS, Pred, St);