@@ -2095,8 +2095,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
2095
2095
return getOrCreateInstanceMethodType (ThisType, Func, Unit);
2096
2096
}
2097
2097
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) {
2100
2109
FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo ();
2101
2110
Qualifiers &Qc = EPI.TypeQuals ;
2102
2111
Qc.removeConst ();
@@ -2136,7 +2145,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
2136
2145
}
2137
2146
2138
2147
// 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)
2140
2149
Elts.push_back (Args[i]);
2141
2150
2142
2151
// Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4470,6 +4479,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
4470
4479
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
4471
4480
return DBuilder.createSubroutineType (DBuilder.getOrCreateTypeArray ({}));
4472
4481
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
+
4473
4488
if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
4474
4489
return getOrCreateMethodType (Method, F);
4475
4490
0 commit comments