aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-03-04 20:40:11 +0000
committerTed Kremenek <kremenek@apple.com>2008-03-04 20:40:11 +0000
commitfcb092b1aafd44019f9ddba46514d8bea2cb7942 (patch)
tree1b58b4c0ee7be7f48c17b6560ec0aa65935557e3
parent7fa6a4079fd68344e4d38c30f7681b3a7d30fbd1 (diff)
For the transfer function of DeclStmt, for now initialize the values of
structs (local variables) to Unknown instead of Undefined. (added FIXME to initialize *members* of struct to undefined) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47901 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Analysis/GRExprEngine.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp
index 8db5a14be4..7a0ca71054 100644
--- a/Analysis/GRExprEngine.cpp
+++ b/Analysis/GRExprEngine.cpp
@@ -622,10 +622,10 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, GRExprEngine::NodeTy* Pred,
//
// FIXME: static variables may have an initializer, but the second
// time a function is called those values may not be current.
+
+ QualType T = VD->getType();
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
@@ -634,6 +634,8 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, GRExprEngine::NodeTy* Pred,
// —if it has arithmetic type, it is initialized to (positive or
// unsigned) zero;
+ // FIXME: Handle structs. Now we treat their values as unknown.
+
if (T->isPointerType()) {
St = SetRVal(St, lval::DeclVal(VD),
@@ -645,18 +647,21 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, GRExprEngine::NodeTy* Pred,
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());
+ else {
+
+ // FIXME: Handle structs. Now we treat them as unknown. What
+ // we need to do is treat their members as unknown.
+ if (T->isPointerType() || T->isIntegerType())
+ St = SetRVal(St, lval::DeclVal(VD),
+ Ex ? GetRVal(St, Ex) : UndefinedVal());
+ }
}
}
Nodify(Dst, DS, Pred, St);
-
- if (Dst.empty()) { Dst.Add(Pred); }
}