aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index c42dd95..22f6f6c 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -584,7 +584,15 @@ public:
if (SavedLocals.count(LocalVD) > 0) return false;
SavedLocals[LocalVD] = CGF.LocalDeclMap.lookup(LocalVD);
CGF.LocalDeclMap.erase(LocalVD);
- SavedPrivates[LocalVD] = PrivateGen();
+ auto *V = PrivateGen();
+ QualType VarTy = LocalVD->getType();
+ if (VarTy->isReferenceType()) {
+ auto *TempAlloca = CGF.CreateMemTemp(VarTy);
+ LValue RefLVal = CGF.MakeNaturalAlignAddrLValue(TempAlloca, VarTy);
+ CGF.EmitStoreOfScalar(V, RefLVal);
+ V = TempAlloca;
+ }
+ SavedPrivates[LocalVD] = V;
CGF.LocalDeclMap[LocalVD] = SavedLocals[LocalVD];
return true;
}