diff options
author | John McCall <rjmccall@apple.com> | 2011-02-16 08:02:54 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-02-16 08:02:54 +0000 |
commit | e996ffd240f20a1048179d7727a6ee3227261921 (patch) | |
tree | 4401959697b60e22969148b60cd09e9b343fec14 /lib/CodeGen/CodeGenFunction.h | |
parent | c515d18023e952357d5dee645e6e3539b7b3d992 (diff) |
Save a copy expression for non-trivial copy constructions of catch variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125661 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 5ea1565fc3..c4971506c5 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -838,6 +838,31 @@ public: CGF.EnsureInsertPoint(); } }; + + /// An RAII object to set (and then clear) a mapping for an OpaqueValueExpr. + class OpaqueValueMapping { + CodeGenFunction &CGF; + const OpaqueValueExpr *OpaqueValue; + + public: + OpaqueValueMapping(CodeGenFunction &CGF, + const OpaqueValueExpr *opaqueValue, + llvm::Value *value) + : CGF(CGF), OpaqueValue(opaqueValue) { + assert(opaqueValue && "no opaque value expression!"); + CGF.OpaqueValues.insert(std::make_pair(opaqueValue, value)); + } + + void pop() { + assert(OpaqueValue && "mapping already popped!"); + CGF.OpaqueValues.erase(OpaqueValue); + OpaqueValue = 0; + } + + ~OpaqueValueMapping() { + if (OpaqueValue) CGF.OpaqueValues.erase(OpaqueValue); + } + }; /// getByrefValueFieldNumber - Given a declaration, returns the LLVM field /// number that holds the value. @@ -883,6 +908,10 @@ private: /// statement range in current switch instruction. llvm::BasicBlock *CaseRangeBlock; + /// OpaqueValues - Keeps track of the current set of opaque value + /// expressions. + llvm::DenseMap<const OpaqueValueExpr *, llvm::Value*> OpaqueValues; + // VLASizeMap - This keeps track of the associated size for each VLA type. // We track this by the size expression rather than the type itself because // in certain situations, like a const qualifier applied to an VLA typedef, @@ -1278,6 +1307,16 @@ public: return Res; } + /// getOpaqueValueMapping - Given an opaque value expression (which + /// must be mapped), return its mapping. Whether this is an address + /// or a value depends on the expression's type and value kind. + llvm::Value *getOpaqueValueMapping(const OpaqueValueExpr *e) { + llvm::DenseMap<const OpaqueValueExpr*,llvm::Value*>::iterator + it = OpaqueValues.find(e); + assert(it != OpaqueValues.end() && "no mapping for opaque value!"); + return it->second; + } + /// getAccessedFieldNo - Given an encoded value and a result number, return /// the input field number being accessed. static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts); @@ -1609,6 +1648,7 @@ public: LValue EmitConditionalOperatorLValue(const ConditionalOperator *E); LValue EmitCastLValue(const CastExpr *E); LValue EmitNullInitializationLValue(const CXXScalarValueInitExpr *E); + LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e); llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar); |