@@ -2185,8 +2185,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
2185
2185
return getOrCreateInstanceMethodType (ThisType, Func, Unit);
2186
2186
}
2187
2187
2188
- llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType (
2189
- QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
2188
+ llvm::DISubroutineType *CGDebugInfo::getOrCreateMethodTypeForDestructor (
2189
+ const CXXMethodDecl *Method, llvm::DIFile *Unit, QualType FNType) {
2190
+ const FunctionProtoType *Func = FNType->getAs <FunctionProtoType>();
2191
+ // skip the first param since it is also this
2192
+ return getOrCreateInstanceMethodType (Method->getThisType (), Func, Unit, true );
2193
+ }
2194
+
2195
+ llvm::DISubroutineType *
2196
+ CGDebugInfo::getOrCreateInstanceMethodType (QualType ThisPtr,
2197
+ const FunctionProtoType *Func,
2198
+ llvm::DIFile *Unit, bool SkipFirst) {
2190
2199
FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo ();
2191
2200
Qualifiers &Qc = EPI.TypeQuals ;
2192
2201
Qc.removeConst ();
@@ -2226,7 +2235,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
2226
2235
}
2227
2236
2228
2237
// Copy rest of the arguments.
2229
- for (unsigned i = 1 , e = Args.size (); i != e; ++i)
2238
+ for (unsigned i = (SkipFirst ? 2 : 1 ) , e = Args.size (); i < e; ++i)
2230
2239
Elts.push_back (Args[i]);
2231
2240
2232
2241
// Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4620,6 +4629,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
4620
4629
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
4621
4630
return DBuilder.createSubroutineType (DBuilder.getOrCreateTypeArray ({}));
4622
4631
4632
+ if (const auto *Method = dyn_cast<CXXDestructorDecl>(D)) {
4633
+ // Read method type from 'FnType' because 'D.getType()' does not cover
4634
+ // implicit arguments for destructors.
4635
+ return getOrCreateMethodTypeForDestructor (Method, F, FnType);
4636
+ }
4637
+
4623
4638
if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
4624
4639
return getOrCreateMethodType (Method, F);
4625
4640
0 commit comments