diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2011-02-26 22:09:03 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2011-02-26 22:09:03 +0000 |
commit | c3b054d250cdca485c71845089c316e10610ebad (patch) | |
tree | abae0246ec9156cc1a7cbb947b2b0dfe95fa3189 /lib/CodeGen/CodeGenFunction.h | |
parent | bca07a4524feb4edec581062d631a13116320a24 (diff) |
Notes
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 67ef41448e8de..be646fb29022f 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -1555,7 +1555,55 @@ public: /// EmitAutoVarDecl - Emit an auto variable declaration. /// /// This function can be called with a null (unreachable) insert point. - void EmitAutoVarDecl(const VarDecl &D, SpecialInitFn *SpecialInit = 0); + void EmitAutoVarDecl(const VarDecl &D); + + class AutoVarEmission { + friend class CodeGenFunction; + + const VarDecl *Variable; + + /// The alignment of the variable. + CharUnits Alignment; + + /// The address of the alloca. Null if the variable was emitted + /// as a global constant. + llvm::Value *Address; + + llvm::Value *NRVOFlag; + + /// True if the variable is a __block variable. + bool IsByRef; + + /// True if the variable is of aggregate type and has a constant + /// initializer. + bool IsConstantAggregate; + + struct Invalid {}; + AutoVarEmission(Invalid) : Variable(0) {} + + AutoVarEmission(const VarDecl &variable) + : 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. + llvm::Value *getObjectAddress(CodeGenFunction &CGF) const { + if (!IsByRef) return Address; + + return CGF.Builder.CreateStructGEP(Address, + CGF.getByRefValueLLVMField(Variable), + Variable->getNameAsString()); + } + }; + AutoVarEmission EmitAutoVarAlloca(const VarDecl &var); + void EmitAutoVarInit(const AutoVarEmission &emission); + void EmitAutoVarCleanups(const AutoVarEmission &emission); void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage); |