diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-05-27 05:39:06 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-05-27 05:39:06 +0000 |
commit | 4a18784dea763be146df68546e6dbf4233c33077 (patch) | |
tree | 71637c69aac7db542e72b71a4a40b103eb233101 /lib/CodeGen/CGDecl.cpp | |
parent | 815215daf8f642b53a28212313fca7b9f77e5b9d (diff) |
Add IRGen support for local variables of reference type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72462 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 52bb90e7f8..bcad77be51 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -332,11 +332,6 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { DI->EmitDeclareOfAutoVariable(&D, DeclPtr, Builder); } - if (D.getType()->isReferenceType()) { - CGM.ErrorUnsupported(&D, "declaration with reference type"); - return; - } - // If this local has an initializer, emit it now. if (const Expr *Init = D.getInit()) { llvm::Value *Loc = DeclPtr; @@ -344,7 +339,10 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { bool needsCopyDispose = BlockRequiresCopying(Ty); Loc = Builder.CreateStructGEP(DeclPtr, needsCopyDispose*2+4, "x"); } - if (!hasAggregateLLVMType(Init->getType())) { + if (Ty->isReferenceType()) { + llvm::Value *V = EmitReferenceBindingToExpr(Init, Ty).getScalarVal(); + EmitStoreOfScalar(V, Loc, false, Ty); + } else if (!hasAggregateLLVMType(Init->getType())) { llvm::Value *V = EmitScalarExpr(Init); EmitStoreOfScalar(V, Loc, D.getType().isVolatileQualified(), D.getType()); |