From be17651f5cd2e94922c1b732bc8589e180698193 Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Tue, 4 May 2010 20:51:19 +0000 Subject: Update clang to r103052. --- lib/CodeGen/CGBlocks.cpp | 2 ++ lib/CodeGen/CGDebugInfo.cpp | 5 ++++- lib/CodeGen/CGDecl.cpp | 7 ++----- lib/CodeGen/CGDeclCXX.cpp | 3 +++ lib/CodeGen/CGObjC.cpp | 26 ++++++++++++++------------ 5 files changed, 25 insertions(+), 18 deletions(-) (limited to 'lib/CodeGen') diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index db24def216d5e..8082b33fd66de 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -532,6 +532,8 @@ llvm::Value *CodeGenFunction::GetAddrOfBlockDecl(const BlockDeclRefExpr *E) { V = Builder.CreateBitCast(V, PtrStructTy); V = Builder.CreateStructGEP(V, getByRefValueLLVMField(VD), VD->getNameAsString()); + if (VD->getType()->isReferenceType()) + V = Builder.CreateLoad(V); } else { const llvm::Type *Ty = CGM.getTypes().ConvertType(VD->getType()); diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 4963e73fe4644..48ae5113b3af5 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -495,7 +495,10 @@ CollectRecordFields(const RecordDecl *RD, llvm::DIFile Unit, llvm::DIType CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, llvm::DIFile Unit) { - llvm::DIType FnTy = getOrCreateType(Method->getType(), Unit); + llvm::DIType FnTy + = getOrCreateType(QualType(Method->getType()->getAs(), + 0), + Unit); // Static methods do not need "this" pointer argument. if (Method->isStatic()) diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index ba3a2b47edb4b..48198ff5761bc 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -231,9 +231,6 @@ CodeGenFunction::AddInitializerToGlobalBlockVarDecl(const VarDecl &D, void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage) { - // Bail out early if the block is unreachable. - if (!Builder.GetInsertBlock()) return; - llvm::Value *&DMEntry = LocalDeclMap[&D]; assert(DMEntry == 0 && "Decl already exists in localdeclmap!"); @@ -245,9 +242,9 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D, if (getContext().getLangOptions().CPlusPlus) CGM.setStaticLocalDeclAddress(&D, GV); + // We can't have a VLA here, but we can have a pointer to a VLA, + // even though that doesn't really make any sense. // Make sure to evaluate VLA bounds now so that we have them for later. - // - // FIXME: Can this happen? if (D.getType()->isVariablyModifiedType()) EmitVLASize(D.getType()); diff --git a/lib/CodeGen/CGDeclCXX.cpp b/lib/CodeGen/CGDeclCXX.cpp index f6c805fdcaa03..6afa53868ecc0 100644 --- a/lib/CodeGen/CGDeclCXX.cpp +++ b/lib/CodeGen/CGDeclCXX.cpp @@ -279,6 +279,9 @@ static llvm::Constant *getGuardAbortFn(CodeGenFunction &CGF) { void CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D, llvm::GlobalVariable *GV) { + // Bail out early if this initializer isn't reachable. + if (!Builder.GetInsertBlock()) return; + bool ThreadsafeStatics = getContext().getLangOptions().ThreadsafeStatics; llvm::SmallString<256> GuardVName; diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 33592501d7341..8426f7105be4f 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -441,18 +441,20 @@ void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, LoadObjCSelf(), Ivar, 0); const RecordType *RT = FieldType->getAs(); CXXRecordDecl *FieldClassDecl = cast(RT->getDecl()); - if (Array) { - const llvm::Type *BasePtr = ConvertType(FieldType); - BasePtr = llvm::PointerType::getUnqual(BasePtr); - llvm::Value *BaseAddrPtr = - Builder.CreateBitCast(LV.getAddress(), BasePtr); - EmitCXXAggrDestructorCall(FieldClassDecl->getDestructor(getContext()), - Array, BaseAddrPtr); - } - else - EmitCXXDestructorCall(FieldClassDecl->getDestructor(CGM.getContext()), - Dtor_Complete, /*ForVirtualBase=*/false, - LV.getAddress()); + CXXDestructorDecl *Dtor = FieldClassDecl->getDestructor(getContext()); + if (!Dtor->isTrivial()) + if (Array) { + const llvm::Type *BasePtr = ConvertType(FieldType); + BasePtr = llvm::PointerType::getUnqual(BasePtr); + llvm::Value *BaseAddrPtr = + Builder.CreateBitCast(LV.getAddress(), BasePtr); + EmitCXXAggrDestructorCall(Dtor, + Array, BaseAddrPtr); + } + else + EmitCXXDestructorCall(Dtor, + Dtor_Complete, /*ForVirtualBase=*/false, + LV.getAddress()); } } FinishFunction(); -- cgit v1.3