diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-09-11 01:27:29 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-09-11 01:27:29 +0000 |
commit | c5904b40c3d76b612fb09c6d2717f646a0af6670 (patch) | |
tree | c998305e33a009fddc4aca5aace657cecd5dbcfa /lib/CodeGen/CGObjCMac.cpp | |
parent | 0b34cf7399e61ef33dc5a3af405351822eeb5f3e (diff) |
Fixes an obscure bug in importd block variable layout
information when imported variable is used
more than once. Originally though to be a bug in importing
block varibles. Fixes radar 8417746.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113675 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 8254135686..73074b6bbe 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1000,7 +1000,7 @@ public: /// definition is seen. The return value has type ProtocolPtrTy. virtual llvm::Constant *GetOrEmitProtocolRef(const ObjCProtocolDecl *PD)=0; virtual llvm::Constant *GCBlockLayout(CodeGen::CodeGenFunction &CGF, - const llvm::SmallVectorImpl<const BlockDeclRefExpr *> &); + const llvm::SmallVectorImpl<const Expr *> &); }; @@ -1663,11 +1663,11 @@ static Qualifiers::GC GetGCAttrTypeForType(ASTContext &Ctx, QualType FQT) { } llvm::Constant *CGObjCCommonMac::GCBlockLayout(CodeGen::CodeGenFunction &CGF, - const llvm::SmallVectorImpl<const BlockDeclRefExpr *> &DeclRefs) { + const llvm::SmallVectorImpl<const Expr *> &BlockLayout) { llvm::Constant *NullPtr = llvm::Constant::getNullValue(llvm::Type::getInt8PtrTy(VMContext)); if ((CGM.getLangOptions().getGCMode() == LangOptions::NonGC) || - DeclRefs.empty()) + BlockLayout.empty()) return NullPtr; bool hasUnion = false; SkipIvars.clear(); @@ -1678,8 +1678,11 @@ llvm::Constant *CGObjCCommonMac::GCBlockLayout(CodeGen::CodeGenFunction &CGF, // __isa is the first field in block descriptor and must assume by runtime's // convention that it is GC'able. IvarsInfo.push_back(GC_IVAR(0, 1)); - for (size_t i = 0; i < DeclRefs.size(); ++i) { - const BlockDeclRefExpr *BDRE = DeclRefs[i]; + for (size_t i = 0; i < BlockLayout.size(); ++i) { + const Expr *E = BlockLayout[i]; + const BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(E); + if (!BDRE) + continue; const ValueDecl *VD = BDRE->getDecl(); CharUnits Offset = CGF.BlockDecls[VD]; uint64_t FieldOffset = Offset.getQuantity(); |