@@ -2108,8 +2108,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
2108
2108
return getOrCreateInstanceMethodType (ThisType, Func, Unit);
2109
2109
}
2110
2110
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) {
2113
2122
FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo ();
2114
2123
Qualifiers &Qc = EPI.TypeQuals ;
2115
2124
Qc.removeConst ();
@@ -2149,7 +2158,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
2149
2158
}
2150
2159
2151
2160
// 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)
2153
2162
Elts.push_back (Args[i]);
2154
2163
2155
2164
// Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4522,6 +4531,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
4522
4531
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
4523
4532
return DBuilder.createSubroutineType (DBuilder.getOrCreateTypeArray ({}));
4524
4533
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
+
4525
4540
if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
4526
4541
return getOrCreateMethodType (Method, F);
4527
4542
0 commit comments