diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-05-27 06:04:58 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-05-27 06:04:58 +0000 |
commit | 751aa72b72970cae379b86dc9177d8bcb12cda81 (patch) | |
tree | 5d21f364f9bcba278b6cef6d3259e3166b9e3680 /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | 55422ad068e3c28883a8fcaee311511a4feb6d2a (diff) | |
download | bcm5719-llvm-751aa72b72970cae379b86dc9177d8bcb12cda81.tar.gz bcm5719-llvm-751aa72b72970cae379b86dc9177d8bcb12cda81.zip |
Fix up constant expression handling to deal with the address
of a reference correctly.
llvm-svn: 72463
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 0df03ec3a27..b30bafb5105 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/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) { |