diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-02-27 19:21:33 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-02-27 19:21:33 +0000 |
| commit | fef05fae6768e53ea0b72abefbfa46d0c196ee41 (patch) | |
| tree | d513cb8a5982053f9bf0484515f7139b635d4755 | |
| parent | e1938405fa4104ebf5bade823a9dbe1d425d30a8 (diff) | |
| download | bcm5719-llvm-fef05fae6768e53ea0b72abefbfa46d0c196ee41.tar.gz bcm5719-llvm-fef05fae6768e53ea0b72abefbfa46d0c196ee41.zip | |
Small tweaks to the transfer function for DeclStmt: do not mark external global
variables as uninitialized, and only "initialize" static function variables.
llvm-svn: 47683
| -rw-r--r-- | clang/Analysis/GRExprEngine.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/clang/Analysis/GRExprEngine.cpp b/clang/Analysis/GRExprEngine.cpp index 86bd2700d71..f227160bfb1 100644 --- a/clang/Analysis/GRExprEngine.cpp +++ b/clang/Analysis/GRExprEngine.cpp @@ -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); |

