[PATCH] D80001: [RFC/WIP][clang] Fix printing of names of inherited constructors
Pavel Labath via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 15 05:53:27 PDT 2020
labath created this revision.
labath added reviewers: rsmith, dblaikie.
Herald added a subscriber: aprantl.
Herald added a project: clang.
This is a fairly hacky fix to the following problem: Debug information
entries for inherited constructors are emitted with the name of the base
class, instead of the inheriting class.
This problem can be tracked down to a FIXME in
Sema::findInheritingConstructor, which works around the problem of not
having a DeclarationName to describe inherited constructors. The current
patch compounds that workaround by printing the inherited constructor
name in a different way.
I don't really expect this patch to make its way into the tree in the
current form. I am mainly putting it up to point out the problem and
start a discussion on the solution. I suppose the right fix is to
implement the FIXME, and add a new DeclarationName kind. But that seems
like it could be a fairly involved change, so I wanted to get some
confirmation (and maybe a bit of guidance) first.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80001
Files:
clang/include/clang/AST/DeclCXX.h
clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
clang/test/CodeGenCXX/debug-info-inlined.cpp
Index: clang/test/CodeGenCXX/debug-info-inlined.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-inlined.cpp
+++ clang/test/CodeGenCXX/debug-info-inlined.cpp
@@ -26,4 +26,4 @@
// CHECK-SAME: !dbg ![[INL:[0-9]+]]
// CHECK: ![[INL]] = !DILocation(line: 10, scope: ![[SP:[0-9]+]], inlinedAt:
-// CHECK: ![[SP]] = distinct !DISubprogram(name: "Base", {{.*}} DISPFlagDefinition
+// CHECK: ![[SP]] = distinct !DISubprogram(name: "Forward", {{.*}} DISPFlagDefinition
Index: clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
+++ clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
@@ -16,10 +16,10 @@
// CHECK-SAME: metadata ![[THIS:[0-9]+]], metadata !DIExpression()), !dbg ![[LOC:[0-9]+]]
// CHECK: ret void, !dbg ![[NOINL:[0-9]+]]
// CHECK: ![[FOO:.*]] = distinct !DISubprogram(name: "foo"
-// CHECK-DAG: ![[A:.*]] = distinct !DISubprogram(name: "A", linkageName: "_ZN1BCI11AEiz"
+// CHECK-DAG: ![[B:.*]] = distinct !DISubprogram(name: "B", linkageName: "_ZN1BCI11AEiz"
void foo() {
-// CHECK-DAG: ![[LOC]] = !DILocation(line: 0, scope: ![[A]], inlinedAt: ![[INL:[0-9]+]])
-// CHECK-DAG: ![[INL]] = !DILocation(line: [[@LINE+1]], scope: ![[FOO]])
+ // CHECK-DAG: ![[LOC]] = !DILocation(line: 0, scope: ![[B]], inlinedAt: ![[INL:[0-9]+]])
+ // CHECK-DAG: ![[INL]] = !DILocation(line: [[@LINE+1]], scope: ![[FOO]])
B b(0);
// CHECK: ![[NOINL]] = !DILocation(line: [[@LINE+1]], scope: !{{[0-9]+}})
}
Index: clang/include/clang/AST/DeclCXX.h
===================================================================
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -2631,6 +2631,13 @@
return const_cast<CXXConstructorDecl*>(this)->getCanonicalDecl();
}
+ void printName(raw_ostream &os) const override {
+ if (isInheritingConstructor())
+ getParent()->printName(os);
+ else
+ CXXMethodDecl::printName(os);
+ }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == CXXConstructor; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80001.264216.patch
Type: text/x-patch
Size: 2261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200515/9c1c7a5f/attachment.bin>
More information about the cfe-commits
mailing list