aboutsummaryrefslogtreecommitdiff
path: root/Analysis/ValueState.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-02-19 01:44:53 +0000
committerTed Kremenek <kremenek@apple.com>2008-02-19 01:44:53 +0000
commitde43424560f1a744de6214dab6bbee28ad8437f5 (patch)
tree3e839d5e4886417a654b4f638b64167a7b15d092 /Analysis/ValueState.cpp
parent60c9b1867fab9d57e6828aa8d36baea703a08ff2 (diff)
Added boilerplate transfer function support for CallExprs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47298 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Analysis/ValueState.cpp')
-rw-r--r--Analysis/ValueState.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/Analysis/ValueState.cpp b/Analysis/ValueState.cpp
index 32be0c6d71..0f29def4a0 100644
--- a/Analysis/ValueState.cpp
+++ b/Analysis/ValueState.cpp
@@ -220,6 +220,8 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
// a better way, since APInts are fairly lightweight.
return nonlval::ConcreteInt(ValMgr.getValue(ED->getInitVal()));
}
+ else if (FunctionDecl* FD = dyn_cast<FunctionDecl>(D))
+ return lval::FuncVal(FD);
assert (false &&
"ValueDecl support for this ValueDecl not implemented.");
@@ -248,7 +250,10 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
case Stmt::ImplicitCastExprClass: {
ImplicitCastExpr* C = cast<ImplicitCastExpr>(E);
- if (C->getType() == C->getSubExpr()->getType()) {
+ QualType CT = C->getType();
+ QualType ST = C->getSubExpr()->getType();
+
+ if (CT == ST || (CT->isPointerType() && ST->isFunctionType())) {
E = C->getSubExpr();
continue;
}
@@ -257,7 +262,10 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
case Stmt::CastExprClass: {
CastExpr* C = cast<CastExpr>(E);
- if (C->getType() == C->getSubExpr()->getType()) {
+ QualType CT = C->getType();
+ QualType ST = C->getSubExpr()->getType();
+
+ if (CT == ST || (CT->isPointerType() && ST->isFunctionType())) {
E = C->getSubExpr();
continue;
}
@@ -297,8 +305,14 @@ LValue ValueStateManager::GetLValue(ValueState St, Expr* E) {
while (ParenExpr* P = dyn_cast<ParenExpr>(E))
E = P->getSubExpr();
- if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E))
- return lval::DeclVal(cast<VarDecl>(DR->getDecl()));
+ if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E)) {
+ ValueDecl* VD = DR->getDecl();
+
+ if (FunctionDecl* FD = dyn_cast<FunctionDecl>(VD))
+ return lval::FuncVal(FD);
+ else
+ return lval::DeclVal(cast<VarDecl>(DR->getDecl()));
+ }
if (UnaryOperator* U = dyn_cast<UnaryOperator>(E))
if (U->getOpcode() == UnaryOperator::Deref)