@@ -2095,8 +2095,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
20952095 return getOrCreateInstanceMethodType (ThisType, Func, Unit);
20962096}
20972097
2098- llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType (
2099- QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
2098+ llvm::DISubroutineType *CGDebugInfo::getOrCreateMethodTypeForDestructor (
2099+ const CXXMethodDecl *Method, llvm::DIFile *Unit, QualType FNType) {
2100+ const FunctionProtoType *Func = FNType->getAs <FunctionProtoType>();
2101+ // skip the first param since it is also this
2102+ return getOrCreateInstanceMethodType (Method->getThisType (), Func, Unit, true );
2103+ }
2104+
2105+ llvm::DISubroutineType *
2106+ CGDebugInfo::getOrCreateInstanceMethodType (QualType ThisPtr,
2107+ const FunctionProtoType *Func,
2108+ llvm::DIFile *Unit, bool SkipFirst) {
21002109 FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo ();
21012110 Qualifiers &Qc = EPI.TypeQuals ;
21022111 Qc.removeConst ();
@@ -2136,7 +2145,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
21362145 }
21372146
21382147 // Copy rest of the arguments.
2139- for (unsigned i = 1 , e = Args.size (); i != e; ++i)
2148+ for (unsigned i = (SkipFirst ? 2 : 1 ) , e = Args.size (); i != e; ++i)
21402149 Elts.push_back (Args[i]);
21412150
21422151 // Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4470,6 +4479,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
44704479 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
44714480 return DBuilder.createSubroutineType (DBuilder.getOrCreateTypeArray ({}));
44724481
4482+ if (const auto *Method = dyn_cast<CXXDestructorDecl>(D)) {
4483+ // Read method type from 'FnType' because 'D.getType()' does not cover
4484+ // implicit arguments for destructors.
4485+ return getOrCreateMethodTypeForDestructor (Method, F, FnType);
4486+ }
4487+
44734488 if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
44744489 return getOrCreateMethodType (Method, F);
44754490
0 commit comments