[PATCH] D154186: [clang][DeclPrinter] Fix AST print of delegating constructors
Timo Stripf via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 30 00:00:57 PDT 2023
strimo378 created this revision.
strimo378 added a reviewer: aaron.ballman.
strimo378 added a project: clang.
Herald added a project: All.
strimo378 requested review of this revision.
Herald added a subscriber: cfe-commits.
DeclPrinter::PrintConstructorInitializers did not consider delegating initializers. As result, the output contained an "NULL TYPE" for delegating constructors.
I chose a generic test case name (ast-print-method-decl.cpp). The plan is to add there other method related test cases for fixes I have in my local branch.
Please use "Timo Stripf" and timo.stripf at emmtrix.com for commit.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D154186
Files:
clang/lib/AST/DeclPrinter.cpp
clang/test/AST/ast-print-method-decl.cpp
Index: clang/test/AST/ast-print-method-decl.cpp
===================================================================
--- /dev/null
+++ clang/test/AST/ast-print-method-decl.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+
+// CHECK: struct A {
+struct A {
+ // CHECK-NEXT: A();
+ A();
+
+ // CHECK-NEXT: A(int) : A() {
+ A(int) : A() {
+ // CHECK-NEXT: }
+ }
+
+
+ // CHECK-NEXT: };
+};
Index: clang/lib/AST/DeclPrinter.cpp
===================================================================
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -321,6 +321,8 @@
if (BMInitializer->isAnyMemberInitializer()) {
FieldDecl *FD = BMInitializer->getAnyMember();
Out << *FD;
+ } else if (BMInitializer->isDelegatingInitializer()) {
+ Out << CDecl->getNameAsString();
} else {
Out << QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154186.536123.patch
Type: text/x-patch
Size: 939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230630/6f9055cd/attachment.bin>
More information about the cfe-commits
mailing list