[cfe-commits] r47880 - /cfe/trunk/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Mon Mar 3 20:18:05 PST 2008
Author: kremenek
Date: Mon Mar 3 22:18:04 2008
New Revision: 47880
URL: http://llvm.org/viewvc/llvm-project?rev=47880&view=rev
Log:
Add transfer function support for the default initialization of static
variables that are pointers or integers.
Modified:
cfe/trunk/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRExprEngine.cpp?rev=47880&r1=47879&r2=47880&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Mon Mar 3 22:18:04 2008
@@ -623,8 +623,34 @@
// 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) : UndefinedVal());
+ if ( VD->getStorageClass() == VarDecl::Static) {
+
+ QualType T = VD->getType();
+
+ // C99: 6.7.8 Initialization
+ // If an object that has static storage duration is not initialized
+ // explicitly, then:
+ // âif it has pointer type, it is initialized to a null pointer;
+ // âif it has arithmetic type, it is initialized to (positive or
+ // unsigned) zero;
+
+ if (T->isPointerType()) {
+
+ St = SetRVal(St, lval::DeclVal(VD),
+ lval::ConcreteInt(ValMgr.getValue(0, T)));
+ }
+ else if (T->isIntegerType()) {
+
+ St = SetRVal(St, lval::DeclVal(VD),
+ nonlval::ConcreteInt(ValMgr.getValue(0, T)));
+ }
+
+ // FIXME: Handle structs. Now we treat their values as unknown.
+ }
+ else
+ St = SetRVal(St, lval::DeclVal(VD),
+ Ex ? GetRVal(St, Ex) : UndefinedVal());
+
}
}
More information about the cfe-commits
mailing list