[clang] 4098e13 - Revert "[clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body"

Steven Wu via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 28 11:41:09 PDT 2023


Author: Steven Wu
Date: 2023-07-28T11:39:46-07:00
New Revision: 4098e13a71464cc4747528edd8a41e5a4eaa1b23

URL: https://github.com/llvm/llvm-project/commit/4098e13a71464cc4747528edd8a41e5a4eaa1b23
DIFF: https://github.com/llvm/llvm-project/commit/4098e13a71464cc4747528edd8a41e5a4eaa1b23.diff

LOG: Revert "[clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body"

This reverts commit a3da6284c23affdd9092b2641017e99d85c2d89b. It breaks
tests on macOS as macOS doesn't support attribute alias.

Added: 
    

Modified: 
    clang/lib/AST/DeclPrinter.cpp
    clang/test/AST/ast-print-method-decl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 0608b48f3a880e..bf4d26c723d2e6 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<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->hasBody())
       Terminator = nullptr;
     else if (auto FD = dyn_cast<FunctionDecl>(*D)) {
-      if (FD->doesThisDeclarationHaveABody() && !FD->isDefaulted())
+      if (FD->isThisDeclarationADefinition())
         Terminator = nullptr;
       else
         Terminator = ";";
     } else if (auto TD = dyn_cast<FunctionTemplateDecl>(*D)) {
-      if (TD->getTemplatedDecl()->doesThisDeclarationHaveABody())
+      if (TD->getTemplatedDecl()->isThisDeclarationADefinition())
         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 3c3b8ceaf86389..505e07dde1a868 100644
--- a/clang/test/AST/ast-print-method-decl.cpp
+++ b/clang/test/AST/ast-print-method-decl.cpp
@@ -85,18 +85,3 @@ 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: };
-};


        


More information about the cfe-commits mailing list