Skip to content

Commit e0d1cb7

Browse files
author
git apple-llvm automerger
committed
Merge commit 'c2347170f40d' from llvm.org/main into next
2 parents e257ab8 + c234717 commit e0d1cb7

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
@@ -2185,8 +2185,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
21852185
return getOrCreateInstanceMethodType(ThisType, Func, Unit);
21862186
}
21872187

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) {
21902199
FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo();
21912200
Qualifiers &Qc = EPI.TypeQuals;
21922201
Qc.removeConst();
@@ -2226,7 +2235,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
22262235
}
22272236

22282237
// 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)
22302239
Elts.push_back(Args[i]);
22312240

22322241
// Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4620,6 +4629,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
46204629
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
46214630
return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray({}));
46224631

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+
46234638
if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
46244639
return getOrCreateMethodType(Method, F);
46254640

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,14 @@ class CGDebugInfo {
267267
/// to get a method type which includes \c this pointer.
268268
llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method,
269269
llvm::DIFile *F);
270+
271+
llvm::DISubroutineType *
272+
getOrCreateMethodTypeForDestructor(const CXXMethodDecl *Method,
273+
llvm::DIFile *F, QualType FNType);
274+
270275
llvm::DISubroutineType *
271276
getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func,
272-
llvm::DIFile *Unit);
277+
llvm::DIFile *Unit, bool SkipFirst = false);
273278
llvm::DISubroutineType *
274279
getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F);
275280
/// \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)