@@ -2108,8 +2108,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
21082108 return getOrCreateInstanceMethodType (ThisType, Func, Unit);
21092109}
21102110
2111- llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType (
2112- QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
2111+ llvm::DISubroutineType *CGDebugInfo::getOrCreateMethodTypeForDestructor (
2112+ const CXXMethodDecl *Method, llvm::DIFile *Unit, QualType FNType) {
2113+ const FunctionProtoType *Func = FNType->getAs <FunctionProtoType>();
2114+ // skip the first param since it is also this
2115+ return getOrCreateInstanceMethodType (Method->getThisType (), Func, Unit, true );
2116+ }
2117+
2118+ llvm::DISubroutineType *
2119+ CGDebugInfo::getOrCreateInstanceMethodType (QualType ThisPtr,
2120+ const FunctionProtoType *Func,
2121+ llvm::DIFile *Unit, bool SkipFirst) {
21132122 FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo ();
21142123 Qualifiers &Qc = EPI.TypeQuals ;
21152124 Qc.removeConst ();
@@ -2149,7 +2158,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
21492158 }
21502159
21512160 // Copy rest of the arguments.
2152- for (unsigned i = 1 , e = Args.size (); i != e; ++i)
2161+ for (unsigned i = (SkipFirst ? 2 : 1 ) , e = Args.size (); i < e; ++i)
21532162 Elts.push_back (Args[i]);
21542163
21552164 // Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4522,6 +4531,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
45224531 // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
45234532 return DBuilder.createSubroutineType (DBuilder.getOrCreateTypeArray ({}));
45244533
4534+ if (const auto *Method = dyn_cast<CXXDestructorDecl>(D)) {
4535+ // Read method type from 'FnType' because 'D.getType()' does not cover
4536+ // implicit arguments for destructors.
4537+ return getOrCreateMethodTypeForDestructor (Method, F, FnType);
4538+ }
4539+
45254540 if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
45264541 return getOrCreateMethodType (Method, F);
45274542
0 commit comments