@@ -2106,8 +2106,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
21062106 return getOrCreateInstanceMethodType (ThisType, Func, Unit);
21072107}
21082108
2109- llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType (
2110- QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
2109+ llvm::DISubroutineType *CGDebugInfo::getOrCreateMethodTypeForDestructor (
2110+ const CXXMethodDecl *Method, llvm::DIFile *Unit, QualType FNType) {
2111+ const FunctionProtoType *Func = FNType->getAs <FunctionProtoType>();
2112+ // skip the first param since it is also this
2113+ return getOrCreateInstanceMethodType (Method->getThisType (), Func, Unit, true );
2114+ }
2115+
2116+ llvm::DISubroutineType *
2117+ CGDebugInfo::getOrCreateInstanceMethodType (QualType ThisPtr,
2118+ const FunctionProtoType *Func,
2119+ llvm::DIFile *Unit, bool SkipFirst) {
21112120 FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo ();
21122121 Qualifiers &Qc = EPI.TypeQuals ;
21132122 Qc.removeConst ();
@@ -2147,7 +2156,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
21472156 }
21482157
21492158 // Copy rest of the arguments.
2150- for (unsigned i = 1 , e = Args.size (); i != e; ++i)
2159+ for (unsigned i = (SkipFirst ? 2 : 1 ) , e = Args.size (); i != e; ++i)
21512160 Elts.push_back (Args[i]);
21522161
21532162 // Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4517,6 +4526,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
45174526 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
45184527 return DBuilder.createSubroutineType (DBuilder.getOrCreateTypeArray ({}));
45194528
4529+ if (const auto *Method = dyn_cast<CXXDestructorDecl>(D)) {
4530+ // Read method type from 'FnType' because 'D.getType()' does not cover
4531+ // implicit arguments for destructors.
4532+ return getOrCreateMethodTypeForDestructor (Method, F, FnType);
4533+ }
4534+
45204535 if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
45214536 return getOrCreateMethodType (Method, F);
45224537
0 commit comments