aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-02-22 07:16:58 +0000
committerJohn McCall <rjmccall@apple.com>2011-02-22 07:16:58 +0000
commit57b3b6a60856eaec30fd876a8a3face8f7e3ad7b (patch)
tree06247fed84349aebc8f4d39b8c2dc7c110f07324 /lib/CodeGen/CodeGenFunction.h
parent34695856c0e67b3765b46304cc71b5d2cd5b71c7 (diff)
Establish the iteration variable of an ObjC for-in loop before
emitting the collection expression. Fixes some really, really broken code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126193 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r--lib/CodeGen/CodeGenFunction.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index f741cfa6e8..be646fb290 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -1560,7 +1560,7 @@ public:
class AutoVarEmission {
friend class CodeGenFunction;
- const VarDecl &Variable;
+ const VarDecl *Variable;
/// The alignment of the variable.
CharUnits Alignment;
@@ -1578,13 +1578,18 @@ public:
/// initializer.
bool IsConstantAggregate;
+ struct Invalid {};
+ AutoVarEmission(Invalid) : Variable(0) {}
+
AutoVarEmission(const VarDecl &variable)
- : Variable(variable), Address(0), NRVOFlag(0),
+ : Variable(&variable), Address(0), NRVOFlag(0),
IsByRef(false), IsConstantAggregate(false) {}
bool wasEmittedAsGlobal() const { return Address == 0; }
public:
+ static AutoVarEmission invalid() { return AutoVarEmission(Invalid()); }
+
/// Returns the address of the object within this declaration.
/// Note that this does not chase the forwarding pointer for
/// __block decls.
@@ -1592,8 +1597,8 @@ public:
if (!IsByRef) return Address;
return CGF.Builder.CreateStructGEP(Address,
- CGF.getByRefValueLLVMField(&Variable),
- Variable.getNameAsString());
+ CGF.getByRefValueLLVMField(Variable),
+ Variable->getNameAsString());
}
};
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var);