diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 10 | ||||
-rw-r--r-- | lib/CodeGen/CGExprCXX.cpp | 18 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 72 | ||||
-rw-r--r-- | lib/CodeGen/CGVtable.cpp | 9 |
4 files changed, 42 insertions, 67 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 58acd3c..4f14f94 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1390,9 +1390,9 @@ void CGDebugInfo::EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder) { PresumedLoc PLoc = SM.getPresumedLoc(CurLoc); llvm::MDNode *Scope = RegionStack.back(); - Builder.SetCurrentDebugLocation(llvm::NewDebugLoc::get(PLoc.getLine(), - PLoc.getColumn(), - Scope)); + Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(PLoc.getLine(), + PLoc.getColumn(), + Scope)); } /// EmitRegionStart- Constructs the debug code for entering a declarative @@ -1596,7 +1596,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag, DebugFactory.InsertDeclare(Storage, D, Builder.GetInsertBlock()); llvm::MDNode *Scope = RegionStack.back(); - Call->setDebugLoc(llvm::NewDebugLoc::get(Line, Column, Scope)); + Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); } /// EmitDeclare - Emit local variable declaration debug info. @@ -1660,7 +1660,7 @@ void CGDebugInfo::EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag, DebugFactory.InsertDeclare(Storage, D, Builder.GetInsertBlock()); llvm::MDNode *Scope = RegionStack.back(); - Call->setDebugLoc(llvm::NewDebugLoc::get(Line, PLoc.getColumn(), Scope)); + Call->setDebugLoc(llvm::DebugLoc::get(Line, PLoc.getColumn(), Scope)); } void CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD, diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index d9585c9..1fd1da8 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -307,23 +307,7 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest, // Code gen optimization to eliminate copy constructor and return // its first argument instead. if (getContext().getLangOptions().ElideConstructors && E->isElidable()) { - const Expr *Arg = E->getArg(0); - - if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) { - assert((ICE->getCastKind() == CastExpr::CK_NoOp || - ICE->getCastKind() == CastExpr::CK_ConstructorConversion || - ICE->getCastKind() == CastExpr::CK_UserDefinedConversion) && - "Unknown implicit cast kind in constructor elision"); - Arg = ICE->getSubExpr(); - } - - if (const CXXFunctionalCastExpr *FCE = dyn_cast<CXXFunctionalCastExpr>(Arg)) - Arg = FCE->getSubExpr(); - - if (const CXXBindTemporaryExpr *BindExpr = - dyn_cast<CXXBindTemporaryExpr>(Arg)) - Arg = BindExpr->getSubExpr(); - + const Expr *Arg = E->getArg(0)->getTemporaryObject(); EmitAggExpr(Arg, Dest, false); return; } diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 883ed98..5373390 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -42,41 +42,15 @@ using namespace CodeGen; // don't belong in CGObjCRuntime either so we will live with it for // now. -/// FindIvarInterface - Find the interface containing the ivar. -/// -/// FIXME: We shouldn't need to do this, the containing context should -/// be fixed. -static const ObjCInterfaceDecl *FindIvarInterface(ASTContext &Context, - const ObjCInterfaceDecl *OID, - const ObjCIvarDecl *OIVD, - unsigned &Index) { - // FIXME: The index here is closely tied to how - // ASTContext::getObjCLayout is implemented. This should be fixed to - // get the information from the layout directly. - Index = 0; - llvm::SmallVector<ObjCIvarDecl*, 16> Ivars; - Context.ShallowCollectObjCIvars(OID, Ivars); - for (unsigned k = 0, e = Ivars.size(); k != e; ++k) { - if (OIVD == Ivars[k]) - return OID; - ++Index; - } - - // Otherwise check in the super class. - if (const ObjCInterfaceDecl *Super = OID->getSuperClass()) - return FindIvarInterface(Context, Super, OIVD, Index); - - return 0; -} - static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *OID, const ObjCImplementationDecl *ID, const ObjCIvarDecl *Ivar) { - unsigned Index; - const ObjCInterfaceDecl *Container = - FindIvarInterface(CGM.getContext(), OID, Ivar, Index); - assert(Container && "Unable to find ivar container"); + const ObjCInterfaceDecl *Container = Ivar->getContainingInterface(); + + // FIXME: We should eliminate the need to have ObjCImplementationDecl passed + // in here; it should never be necessary because that should be the lexical + // decl context for the ivar. // If we know have an implementation (and the ivar is in it) then // look up in the implementation layout. @@ -85,6 +59,22 @@ static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM, RL = &CGM.getContext().getASTObjCImplementationLayout(ID); else RL = &CGM.getContext().getASTObjCInterfaceLayout(Container); + + // Compute field index. + // + // FIXME: The index here is closely tied to how ASTContext::getObjCLayout is + // implemented. This should be fixed to get the information from the layout + // directly. + unsigned Index = 0; + llvm::SmallVector<ObjCIvarDecl*, 16> Ivars; + CGM.getContext().ShallowCollectObjCIvars(Container, Ivars); + for (unsigned k = 0, e = Ivars.size(); k != e; ++k) { + if (Ivar == Ivars[k]) + break; + ++Index; + } + assert(Index != Ivars.size() && "Ivar is not inside container!"); + return RL->getFieldOffset(Index); } @@ -4727,14 +4717,10 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitMethodList(llvm::Twine Name, /// ObjCIvarOffsetVariable - Returns the ivar offset variable for /// the given ivar. -llvm::GlobalVariable * CGObjCNonFragileABIMac::ObjCIvarOffsetVariable( - const ObjCInterfaceDecl *ID, - const ObjCIvarDecl *Ivar) { - // FIXME: We shouldn't need to do this lookup. - unsigned Index; - const ObjCInterfaceDecl *Container = - FindIvarInterface(CGM.getContext(), ID, Ivar, Index); - assert(Container && "Unable to find ivar container!"); +llvm::GlobalVariable * +CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID, + const ObjCIvarDecl *Ivar) { + const ObjCInterfaceDecl *Container = Ivar->getContainingInterface(); std::string Name = "OBJC_IVAR_$_" + Container->getNameAsString() + '.' + Ivar->getNameAsString(); llvm::GlobalVariable *IvarOffsetGV = @@ -4749,10 +4735,10 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::ObjCIvarOffsetVariable( return IvarOffsetGV; } -llvm::Constant * CGObjCNonFragileABIMac::EmitIvarOffsetVar( - const ObjCInterfaceDecl *ID, - const ObjCIvarDecl *Ivar, - unsigned long int Offset) { +llvm::Constant * +CGObjCNonFragileABIMac::EmitIvarOffsetVar(const ObjCInterfaceDecl *ID, + const ObjCIvarDecl *Ivar, + unsigned long int Offset) { llvm::GlobalVariable *IvarOffsetGV = ObjCIvarOffsetVariable(ID, Ivar); IvarOffsetGV->setInitializer(llvm::ConstantInt::get(ObjCTypes.LongTy, Offset)); diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index 2d1c734..fc6d1a8 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -3146,11 +3146,16 @@ void CodeGenVTables::EmitVTableRelatedData(GlobalDecl GD) { if (KeyFunction->getCanonicalDecl() != MD->getCanonicalDecl()) return; } else { + // If we have no key funcion and this is a explicit instantiation declaration, + // we will produce a vtable at the explicit instantiation. We don't need one + // here. + if (RDKind == clang::TSK_ExplicitInstantiationDeclaration) + return; + // If this is an explicit instantiation of a method, we don't need a vtable. // Since we have no key function, we will emit the vtable when we see // a use, and just defining a function is not an use. - if ((RDKind == TSK_ImplicitInstantiation || - RDKind == TSK_ExplicitInstantiationDeclaration) && + if (RDKind == TSK_ImplicitInstantiation && MDKind == TSK_ExplicitInstantiationDefinition) return; } |