diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index bf4d26c723d2e..0608b48f3a880 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -463,12 +463,12 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) { else if (isa(*D) && cast(*D)->hasBody()) Terminator = nullptr; else if (auto FD = dyn_cast(*D)) { - if (FD->isThisDeclarationADefinition()) + if (FD->doesThisDeclarationHaveABody() && !FD->isDefaulted()) Terminator = nullptr; else Terminator = ";"; } else if (auto TD = dyn_cast(*D)) { - if (TD->getTemplatedDecl()->isThisDeclarationADefinition()) + if (TD->getTemplatedDecl()->doesThisDeclarationHaveABody()) Terminator = nullptr; else Terminator = ";"; diff --git a/clang/test/AST/ast-print-method-decl.cpp b/clang/test/AST/ast-print-method-decl.cpp index 505e07dde1a86..3c3b8ceaf8638 100644 --- a/clang/test/AST/ast-print-method-decl.cpp +++ b/clang/test/AST/ast-print-method-decl.cpp @@ -85,3 +85,18 @@ struct CurlyCtorInit { // CHECK-NEXT: }; }; + + +// CHECK: struct DefMethodsWithoutBody { +struct DefMethodsWithoutBody { + // CHECK-NEXT: DefMethodsWithoutBody() = delete; + DefMethodsWithoutBody() = delete; + + // CHECK-NEXT: DefMethodsWithoutBody() = default; + ~DefMethodsWithoutBody() = default; + + // CHECK-NEXT: void m1() __attribute__((alias("X"))); + void m1() __attribute__((alias("X"))); + + // CHECK-NEXT: }; +};