Fix up constant expression handling to deal with the address
of a reference correctly.
llvm-svn: 72463
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7651884..d0d8b81 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -178,11 +178,20 @@
}
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)