diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 33f34fa524da..1fbed63b7191 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -776,7 +776,7 @@ public: CXXConstructorDecl *getDefaultConstructor(ASTContext &Context); /// getDestructor - Returns the destructor decl for this class. - CXXDestructorDecl *getDestructor(ASTContext &Context) const; + CXXDestructorDecl *getDestructor() const; /// isLocalClass - If the class is a local class [class.local], returns /// the enclosing function declaration. diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index cd7afd98b63d..71b5835c1287 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -566,7 +566,8 @@ CXXRecordDecl::getDefaultConstructor(ASTContext &Context) { return 0; } -CXXDestructorDecl *CXXRecordDecl::getDestructor(ASTContext &Context) const { +CXXDestructorDecl *CXXRecordDecl::getDestructor() const { + ASTContext &Context = getASTContext(); QualType ClassType = Context.getTypeDeclType(this); DeclarationName Name diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 96cea87d09ba..e5871b27d468 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -372,8 +372,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { if (CXXRecordDecl *ClassDecl = dyn_cast(RT->getDecl())) { if (!ClassDecl->hasTrivialDestructor()) { - const CXXDestructorDecl *D = - ClassDecl->getDestructor(getContext()); + const CXXDestructorDecl *D = ClassDecl->getDestructor(); assert(D && "BuildBlockLiteralTmp - destructor is nul"); { // Normal destruction. diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 353a7bcf8f1b..4f3572e1cc7a 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -97,7 +97,7 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) { /// If we don't have a definition for the destructor yet, don't /// emit. We can't emit aliases to declarations; that's just not /// how aliases work. - const CXXDestructorDecl *BaseD = UniqueBase->getDestructor(getContext()); + const CXXDestructorDecl *BaseD = UniqueBase->getDestructor(); if (!BaseD->isImplicit() && !BaseD->getBody()) return true; diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 4028cda6b661..085cfd316878 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -342,7 +342,7 @@ static void EmitBaseInitializer(CodeGenFunction &CGF, // FIXME: Is this OK for C++0x delegating constructors? CodeGenFunction::EHCleanupBlock Cleanup(CGF); - CXXDestructorDecl *DD = BaseClassDecl->getDestructor(CGF.getContext()); + CXXDestructorDecl *DD = BaseClassDecl->getDestructor(); CGF.EmitCXXDestructorCall(DD, Dtor_Base, isBaseVirtual, V); } } @@ -539,7 +539,7 @@ static void EmitMemberInitializer(CodeGenFunction &CGF, llvm::Value *ThisPtr = CGF.LoadCXXThis(); LValue LHS = CGF.EmitLValueForField(ThisPtr, Field, 0); - CXXDestructorDecl *DD = RD->getDestructor(CGF.getContext()); + CXXDestructorDecl *DD = RD->getDestructor(); CGF.EmitCXXDestructorCall(DD, Dtor_Complete, /*ForVirtualBase=*/false, LHS.getAddress()); } @@ -783,7 +783,7 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD, // Ignore trivial destructors. if (BaseClassDecl->hasTrivialDestructor()) continue; - const CXXDestructorDecl *D = BaseClassDecl->getDestructor(getContext()); + const CXXDestructorDecl *D = BaseClassDecl->getDestructor(); llvm::Value *V = GetAddressOfDirectBaseInCompleteClass(LoadCXXThis(), ClassDecl, BaseClassDecl, @@ -838,10 +838,10 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD, BasePtr = llvm::PointerType::getUnqual(BasePtr); llvm::Value *BaseAddrPtr = Builder.CreateBitCast(LHS.getAddress(), BasePtr); - EmitCXXAggrDestructorCall(FieldClassDecl->getDestructor(getContext()), + EmitCXXAggrDestructorCall(FieldClassDecl->getDestructor(), Array, BaseAddrPtr); } else - EmitCXXDestructorCall(FieldClassDecl->getDestructor(getContext()), + EmitCXXDestructorCall(FieldClassDecl->getDestructor(), Dtor_Complete, /*ForVirtualBase=*/false, LHS.getAddress()); } @@ -862,7 +862,7 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD, if (BaseClassDecl->hasTrivialDestructor()) continue; - const CXXDestructorDecl *D = BaseClassDecl->getDestructor(getContext()); + const CXXDestructorDecl *D = BaseClassDecl->getDestructor(); llvm::Value *V = GetAddressOfDirectBaseInCompleteClass(LoadCXXThis(), ClassDecl, BaseClassDecl, diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 7498a070734e..5c3055f5b612 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -678,7 +678,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { Loc = Builder.CreateStructGEP(DeclPtr, getByRefValueLLVMField(&D), D.getNameAsString()); - const CXXDestructorDecl *D = ClassDecl->getDestructor(getContext()); + const CXXDestructorDecl *D = ClassDecl->getDestructor(); assert(D && "EmitLocalBlockVarDecl - destructor is nul"); if (const ConstantArrayType *Array = diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 3f4919fbe9c4..803ee10721a2 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -66,7 +66,7 @@ static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D, if (RD->hasTrivialDestructor()) return; - CXXDestructorDecl *Dtor = RD->getDestructor(Context); + CXXDestructorDecl *Dtor = RD->getDestructor(); llvm::Constant *DtorFn; if (Array) { diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 83d91edb1060..182c2ea877f9 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -304,7 +304,7 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) { if (const RecordType *RecordTy = ThrowType->getAs()) { CXXRecordDecl *Record = cast(RecordTy->getDecl()); if (!Record->hasTrivialDestructor()) { - CXXDestructorDecl *DtorD = Record->getDestructor(getContext()); + CXXDestructorDecl *DtorD = Record->getDestructor(); Dtor = CGM.GetAddrOfCXXDestructor(DtorD, Dtor_Complete); Dtor = llvm::ConstantExpr::getBitCast(Dtor, Int8PtrTy); } diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 2bda5adb42b0..fe4f7a175223 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -275,7 +275,7 @@ EmitExprForReferenceBinding(CodeGenFunction& CGF, const Expr* E, if (const RecordType *RT = E->getType()->getAs()) { CXXRecordDecl *ClassDecl = cast(RT->getDecl()); if (!ClassDecl->hasTrivialDestructor()) - ReferenceTemporaryDtor = ClassDecl->getDestructor(CGF.getContext()); + ReferenceTemporaryDtor = ClassDecl->getDestructor(); } } diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index a23dc154c58d..f2e6a11292b7 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -829,7 +829,7 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { if (const RecordType *RT = DeleteTy->getAs()) { if (CXXRecordDecl *RD = dyn_cast(RT->getDecl())) { if (!RD->hasTrivialDestructor()) { - const CXXDestructorDecl *Dtor = RD->getDestructor(getContext()); + const CXXDestructorDecl *Dtor = RD->getDestructor(); if (E->isArrayForm()) { llvm::Value *AllocatedObjectPtr; llvm::Value *NumElements; diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 30f7ab55ce9a..2e629bf856dc 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -461,7 +461,7 @@ void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, LoadObjCSelf(), Ivar, 0); const RecordType *RT = FieldType->getAs(); CXXRecordDecl *FieldClassDecl = cast(RT->getDecl()); - CXXDestructorDecl *Dtor = FieldClassDecl->getDestructor(getContext()); + CXXDestructorDecl *Dtor = FieldClassDecl->getDestructor(); if (!Dtor->isTrivial()) { if (Array) { const llvm::Type *BasePtr = ConvertType(FieldType); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 500d73eb9b44..27455dba497a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5951,7 +5951,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) { case CXXDestructor: if (RD->hasUserDeclaredDestructor()) { - SourceLocation DtorLoc = RD->getDestructor(Context)->getLocation(); + SourceLocation DtorLoc = RD->getDestructor()->getLocation(); Diag(DtorLoc, diag::note_nontrivial_user_defined) << QT << member; return; } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 62dd5ff31e34..927378053653 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2230,7 +2230,7 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location, if (FieldClassDecl->hasTrivialDestructor()) continue; - CXXDestructorDecl *Dtor = FieldClassDecl->getDestructor(Context); + CXXDestructorDecl *Dtor = FieldClassDecl->getDestructor(); CheckDestructorAccess(Field->getLocation(), Dtor, PDiag(diag::err_access_dtor_field) << Field->getDeclName() @@ -2256,7 +2256,7 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location, if (BaseClassDecl->hasTrivialDestructor()) continue; - CXXDestructorDecl *Dtor = BaseClassDecl->getDestructor(Context); + CXXDestructorDecl *Dtor = BaseClassDecl->getDestructor(); // FIXME: caret should be on the start of the class name CheckDestructorAccess(Base->getSourceRange().getBegin(), Dtor, @@ -2283,7 +2283,7 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location, if (BaseClassDecl->hasTrivialDestructor()) continue; - CXXDestructorDecl *Dtor = BaseClassDecl->getDestructor(Context); + CXXDestructorDecl *Dtor = BaseClassDecl->getDestructor(); CheckDestructorAccess(ClassDecl->getLocation(), Dtor, PDiag(diag::err_access_dtor_vbase) << VBase->getType()); @@ -2893,7 +2893,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(Scope *S, B != BEnd; ++B) { if (const RecordType *BaseType = B->getType()->getAs()) ExceptSpec.CalledDecl( - cast(BaseType->getDecl())->getDestructor(Context)); + cast(BaseType->getDecl())->getDestructor()); } // Virtual base-class destructors. @@ -2902,7 +2902,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(Scope *S, B != BEnd; ++B) { if (const RecordType *BaseType = B->getType()->getAs()) ExceptSpec.CalledDecl( - cast(BaseType->getDecl())->getDestructor(Context)); + cast(BaseType->getDecl())->getDestructor()); } // Field destructors. @@ -2912,7 +2912,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(Scope *S, if (const RecordType *RecordTy = Context.getBaseElementType(F->getType())->getAs()) ExceptSpec.CalledDecl( - cast(RecordTy->getDecl())->getDestructor(Context)); + cast(RecordTy->getDecl())->getDestructor()); } QualType Ty = Context.getFunctionType(Context.VoidTy, @@ -5057,7 +5057,7 @@ void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) { CXXRecordDecl *ClassDecl = cast(Record->getDecl()); if (!ClassDecl->isInvalidDecl() && !VD->isInvalidDecl() && !ClassDecl->hasTrivialDestructor() && !ClassDecl->isDependentContext()) { - CXXDestructorDecl *Destructor = ClassDecl->getDestructor(Context); + CXXDestructorDecl *Destructor = ClassDecl->getDestructor(); MarkDeclarationReferenced(VD->getLocation(), Destructor); CheckDestructorAccess(VD->getLocation(), Destructor, PDiag(diag::err_access_dtor_var) @@ -6529,7 +6529,7 @@ void Sema::SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation) { ->getAs()) { CXXRecordDecl *RD = cast(RecordTy->getDecl()); if (CXXDestructorDecl *Destructor - = const_cast(RD->getDestructor(Context))) { + = const_cast(RD->getDestructor())) { MarkDeclarationReferenced(Field->getLocation(), Destructor); CheckDestructorAccess(Field->getLocation(), Destructor, PDiag(diag::err_access_dtor_ivar) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 3c64584bfcea..779304641f4c 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -473,8 +473,8 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { if (RD->hasTrivialDestructor()) return false; - CXXDestructorDecl *Destructor = - const_cast(RD->getDestructor(Context)); + CXXDestructorDecl *Destructor + = const_cast(RD->getDestructor()); if (!Destructor) return false; @@ -1475,7 +1475,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, return ExprError(); if (!RD->hasTrivialDestructor()) - if (const CXXDestructorDecl *Dtor = RD->getDestructor(Context)) + if (const CXXDestructorDecl *Dtor = RD->getDestructor()) MarkDeclarationReferenced(StartLoc, const_cast(Dtor)); } @@ -2639,11 +2639,10 @@ Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) { if (RD->hasTrivialDestructor()) return Owned(E); - CXXTemporary *Temp = CXXTemporary::Create(Context, - RD->getDestructor(Context)); + CXXTemporary *Temp = CXXTemporary::Create(Context, RD->getDestructor()); ExprTemporaries.push_back(Temp); if (CXXDestructorDecl *Destructor = - const_cast(RD->getDestructor(Context))) { + const_cast(RD->getDestructor())) { MarkDeclarationReferenced(E->getExprLoc(), Destructor); CheckDestructorAccess(E->getExprLoc(), Destructor, PDiag(diag::err_access_dtor_temp) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 3acec5667094..c1569620dab7 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -3709,7 +3709,7 @@ InitializationSequence::Perform(Sema &S, QualType T = CurInitExpr->getType(); if (const RecordType *Record = T->getAs()) { CXXDestructorDecl *Destructor - = cast(Record->getDecl())->getDestructor(S.Context); + = cast(Record->getDecl())->getDestructor(); S.CheckDestructorAccess(CurInitExpr->getLocStart(), Destructor, S.PDiag(diag::err_access_dtor_temp) << T); S.MarkDeclarationReferenced(CurInitExpr->getLocStart(), Destructor);