aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprConstant.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/CodeGen/CGExprConstant.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/CodeGen/CGExprConstant.cpp')
-rw-r--r--lib/CodeGen/CGExprConstant.cpp18
1 files changed, 3 insertions, 15 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 0df03ec3a2..b30bafb510 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -478,21 +478,9 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
bool Success = false;
- if (DestType->isReferenceType()) {
- // If the destination type is a reference type, we need to evaluate it
- // as an lvalue.
- if (E->EvaluateAsLValue(Result, Context)) {
- if (const Expr *LVBase = Result.Val.getLValueBase()) {
- if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(LVBase)) {
- const ValueDecl *VD = cast<ValueDecl>(DRE->getDecl());
-
- // We can only initialize a reference with an lvalue if the lvalue
- // is not a reference itself.
- Success = !VD->getType()->isReferenceType();
- }
- }
- }
- } else
+ if (DestType->isReferenceType())
+ Success = E->EvaluateAsLValue(Result, Context);
+ else
Success = E->Evaluate(Result, Context);
if (Success) {