Skip to content

Commit 1f54eaa

Browse files
committed
[Clang,debuginfo] added vtt parameter in DISubroutineType for virtual destructors
1 parent 3382119 commit 1f54eaa

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,8 +2003,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
20032003
return getOrCreateInstanceMethodType(ThisType, Func, Unit);
20042004
}
20052005

2006-
llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
2007-
QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
2006+
llvm::DISubroutineType *CGDebugInfo::getOrCreateMethodTypeForDestructor(
2007+
const CXXMethodDecl *Method, llvm::DIFile *Unit, QualType FNType) {
2008+
const FunctionProtoType *Func = FNType->getAs<FunctionProtoType>();
2009+
// skip the first param since it is also this
2010+
return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit, true);
2011+
}
2012+
2013+
llvm::DISubroutineType *
2014+
CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr,
2015+
const FunctionProtoType *Func,
2016+
llvm::DIFile *Unit, bool SkipFirst) {
20082017
FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo();
20092018
Qualifiers &Qc = EPI.TypeQuals;
20102019
Qc.removeConst();
@@ -2044,7 +2053,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
20442053
}
20452054

20462055
// Copy rest of the arguments.
2047-
for (unsigned i = 1, e = Args.size(); i != e; ++i)
2056+
for (unsigned i = (SkipFirst ? 2 : 1), e = Args.size(); i != e; ++i)
20482057
Elts.push_back(Args[i]);
20492058

20502059
// Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4352,6 +4361,10 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
43524361
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
43534362
return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray({}));
43544363

4364+
if (const auto *Method = dyn_cast<CXXDestructorDecl>(D)) {
4365+
return getOrCreateMethodTypeForDestructor(Method, F, FnType);
4366+
}
4367+
43554368
if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
43564369
return getOrCreateMethodType(Method, F);
43574370

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,14 @@ class CGDebugInfo {
249249
/// to get a method type which includes \c this pointer.
250250
llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method,
251251
llvm::DIFile *F);
252+
253+
llvm::DISubroutineType *
254+
getOrCreateMethodTypeForDestructor(const CXXMethodDecl *Method,
255+
llvm::DIFile *F, QualType FNType);
256+
252257
llvm::DISubroutineType *
253258
getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func,
254-
llvm::DIFile *Unit);
259+
llvm::DIFile *Unit, bool SkipFirst = false);
255260
llvm::DISubroutineType *
256261
getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F);
257262
/// \return debug info descriptor for vtable.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang -g -c -emit-llvm %s -o - | llvm-dis | FileCheck %s
2+
3+
struct B {
4+
virtual ~B() {}
5+
};
6+
7+
struct A : virtual B {
8+
};
9+
10+
A a;
11+
12+
// CHECK-DAG: distinct !DISubprogram(name: "~A", linkageName: "_ZN1AD2Ev", {{.*}}, type: ![[subroutinetype:[0-9]+]]
13+
// CHECK-DAG: ![[subroutinetype]] = !DISubroutineType(types: ![[types:[0-9]+]])
14+
// CHECK-DAG: [[types]] = !{null, !{{[0-9]+}}, !{{[0-9]+}}}
15+
16+

0 commit comments

Comments
 (0)