Skip to content

Commit f6f3675

Browse files
author
git apple-llvm automerger
committed
Merge commit '27c1aa9b9cf9' from llvm.org/main into next
2 parents def0dad + 27c1aa9 commit f6f3675

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,14 @@ class CGDebugInfo {
253253
/// to get a method type which includes \c this pointer.
254254
llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method,
255255
llvm::DIFile *F);
256+
257+
llvm::DISubroutineType *
258+
getOrCreateMethodTypeForDestructor(const CXXMethodDecl *Method,
259+
llvm::DIFile *F, QualType FNType);
260+
256261
llvm::DISubroutineType *
257262
getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func,
258-
llvm::DIFile *Unit);
263+
llvm::DIFile *Unit, bool SkipFirst = false);
259264
llvm::DISubroutineType *
260265
getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F);
261266
/// \return debug info descriptor for vtable.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -debug-info-kind=limited %s -o - | FileCheck --check-prefix MSVC %s
3+
4+
struct B {
5+
virtual ~B() {}
6+
};
7+
8+
struct A : virtual B {
9+
};
10+
11+
A a;
12+
13+
14+
// CHECK-DAG: !{{[0-9]+}} = !DILocalVariable(name: "vtt", arg: 2, scope: ![[destructor:[0-9]+]], type: ![[vtttype:[0-9]+]], flags: DIFlagArtificial)
15+
// CHECK-DAG: ![[destructor]] = distinct !DISubprogram(name: "~A", {{.*}}, type: ![[subroutinetype:[0-9]+]]
16+
// CHECK-DAG: ![[subroutinetype]] = !DISubroutineType(types: ![[types:[0-9]+]])
17+
// CHECK-DAG: [[types]] = !{null, !{{[0-9]+}}, ![[vtttype]]}
18+
19+
// MSVC-DAG: ![[inttype:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
20+
// MSVC-DAG: ![[voidpointertype:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
21+
// MSVC-DAG: ![[destructor:[0-9]+]] = distinct !DISubprogram(name: "~A", linkageName: "??_GA@@UEAAPEAXI@Z", {{.*}}, type: ![[subroutinetype:[0-9]+]]
22+
// MSVC-DAG: !{{[0-9]+}} = !DILocalVariable(name: "should_call_delete", arg: 2, scope: ![[destructor]], type: ![[inttype]], flags: DIFlagArtificial)
23+
// MSVC-DAG: ![[subroutinetype]] = !DISubroutineType(types: ![[types:[0-9]+]])
24+
// MSVC-DAG: [[types]] = !{![[voidpointertype]], !{{[0-9]+}}, ![[inttype]]}

0 commit comments

Comments
 (0)