aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-05-27 06:04:58 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-05-27 06:04:58 +0000
commit50c39ea4858265f3f5f42a0c624557ce2281936b (patch)
treebb90ac16834dc1313cf653c2a2f407a856f93112 /lib/AST/ExprConstant.cpp
parent4a18784dea763be146df68546e6dbf4233c33077 (diff)
Fix up constant expression handling to deal with the address
of a reference correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72463 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 7651884aa6..d0d8b81bab 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -178,11 +178,20 @@ static bool EvaluateLValue(const Expr* E, APValue& Result, EvalInfo &Info) {
}
APValue LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E)
-{
+{
if (!E->hasGlobalStorage())
return APValue();
-
- return APValue(E, 0);
+
+ if (isa<FunctionDecl>(E->getDecl())) {
+ return APValue(E, 0);
+ } else if (VarDecl* VD = dyn_cast<VarDecl>(E->getDecl())) {
+ if (!VD->getType()->isReferenceType())
+ return APValue(E, 0);
+ if (VD->getInit())
+ return Visit(VD->getInit());
+ }
+
+ return APValue();
}
APValue LValueExprEvaluator::VisitBlockExpr(BlockExpr *E)