Skip to content

[AST] Include clang/Basic/DiagnosticComment.h instead of clang/AST/CommentDiagnostic.h #117499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

@kazutakahirata kazutakahirata commented Nov 24, 2024

Since:

commit d076608
Author: Richard Trieu [email protected]
Date: Sat Dec 8 05:05:03 2018 +0000

clang/AST/CommentDiagnostic.h has been forwarding to
clang/Basic/DiagnosticComment.h. This patch includes
clang/Basic/DiagnosticComment.h instead of
clang/AST/CommentDiagnostic.h.

Since:

  commit d076608
  Author: Richard Trieu <[email protected]>
  Date:   Sat Dec 8 05:05:03 2018 +0000

clang/AST/CommentDiagnostic.h has been forwarding to
clang/Basic/DiagnosticParse.h.  This patch removes the indirection and
clang/AST/CommentDiagnostic.h.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 24, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 24, 2024

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

Changes

Since:

commit d076608
Author: Richard Trieu <[email protected]>
Date: Sat Dec 8 05:05:03 2018 +0000

clang/AST/CommentDiagnostic.h has been forwarding to
clang/Basic/DiagnosticParse.h. This patch removes the indirection and
clang/AST/CommentDiagnostic.h.


Full diff: https://github.com/llvm/llvm-project/pull/117499.diff

6 Files Affected:

  • (removed) clang/include/clang/AST/CommentDiagnostic.h (-15)
  • (modified) clang/include/module.modulemap (-1)
  • (modified) clang/lib/AST/CommentLexer.cpp (+1-1)
  • (modified) clang/lib/AST/CommentParser.cpp (+1-1)
  • (modified) clang/lib/AST/CommentSema.cpp (+1-1)
  • (modified) clang/lib/Sema/SemaDecl.cpp (+1-1)
diff --git a/clang/include/clang/AST/CommentDiagnostic.h b/clang/include/clang/AST/CommentDiagnostic.h
deleted file mode 100644
index 2e498d5db38648..00000000000000
--- a/clang/include/clang/AST/CommentDiagnostic.h
+++ /dev/null
@@ -1,15 +0,0 @@
-//===--- CommentDiagnostic.h - Diagnostics for the AST library --*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_AST_COMMENTDIAGNOSTIC_H
-#define LLVM_CLANG_AST_COMMENTDIAGNOSTIC_H
-
-#include "clang/Basic/DiagnosticComment.h"
-
-#endif
-
diff --git a/clang/include/module.modulemap b/clang/include/module.modulemap
index b399f0beee59a1..56b0409e74a150 100644
--- a/clang/include/module.modulemap
+++ b/clang/include/module.modulemap
@@ -111,7 +111,6 @@ module Clang_Diagnostics {
   module All { header "clang/Basic/AllDiagnostics.h" export * }
   module Analysis { textual header "clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def" }
   module AST { header "clang/AST/ASTDiagnostic.h" export * }
-  module Comment { header "clang/AST/CommentDiagnostic.h" export * }
   module Driver { header "clang/Driver/DriverDiagnostic.h" export * }
   module Frontend { header "clang/Frontend/FrontendDiagnostic.h" export * }
   module Lex { header "clang/Lex/LexDiagnostic.h" export * }
diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp
index f0250fc9fd55eb..ec9a5b480aa295 100644
--- a/clang/lib/AST/CommentLexer.cpp
+++ b/clang/lib/AST/CommentLexer.cpp
@@ -8,8 +8,8 @@
 
 #include "clang/AST/CommentLexer.h"
 #include "clang/AST/CommentCommandTraits.h"
-#include "clang/AST/CommentDiagnostic.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/DiagnosticComment.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ConvertUTF.h"
diff --git a/clang/lib/AST/CommentParser.cpp b/clang/lib/AST/CommentParser.cpp
index 61508fe886efc0..12ed8e3f1b79a0 100644
--- a/clang/lib/AST/CommentParser.cpp
+++ b/clang/lib/AST/CommentParser.cpp
@@ -8,9 +8,9 @@
 
 #include "clang/AST/CommentParser.h"
 #include "clang/AST/CommentCommandTraits.h"
-#include "clang/AST/CommentDiagnostic.h"
 #include "clang/AST/CommentSema.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/DiagnosticComment.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/ErrorHandling.h"
 
diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 69eda00643a8fa..bd2206bb8a3bc7 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -9,9 +9,9 @@
 #include "clang/AST/CommentSema.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/CommentCommandTraits.h"
-#include "clang/AST/CommentDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/Basic/DiagnosticComment.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Preprocessor.h"
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 74b0e5ad23bd48..1e9db39a7fb579 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16,7 +16,6 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/CharUnits.h"
-#include "clang/AST/CommentDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
@@ -30,6 +29,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/Builtins.h"
+#include "clang/Basic/DiagnosticComment.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"

Copy link
Member

@Sirraide Sirraide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we can remove this header at this point.

I do have a question about the modulemap though.

@@ -111,7 +111,6 @@ module Clang_Diagnostics {
module All { header "clang/Basic/AllDiagnostics.h" export * }
module Analysis { textual header "clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def" }
module AST { header "clang/AST/ASTDiagnostic.h" export * }
module Comment { header "clang/AST/CommentDiagnostic.h" export * }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to replace this with a reference to DiagnosticComment.h instead of removing it entirely?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing no, but I admit I am no modulemap expert though.

module.modulemap says:

module Clang_Diagnostics {
  requires cplusplus

  module All { header "clang/Basic/AllDiagnostics.h" export * }

Now, AllDiagnostics.h includes clang/Basic/DiagnosticComment.h, so module All above seems to imply DiagnosticComment.h.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo the module question.

@MaskRay
Copy link
Member

MaskRay commented Dec 6, 2024

@Weverything :)

@kazutakahirata kazutakahirata changed the title [AST] Remove clang/AST/CommentDiagnostic.h [AST] Include clang/Basic/DiagnosticComment.h instead of clang/AST/CommentDiagnostic.h Dec 6, 2024
@kazutakahirata
Copy link
Contributor Author

I'm going to go conservative for now by including clang/Basic/DiagnosticComment.h instead of clang/AST/CommentDiagnostic.h. We can revisit this and remove clang/AST/CommentDiagnostic.h and update module.modulemap.

@kazutakahirata kazutakahirata merged commit efe4bfa into llvm:main Dec 6, 2024
8 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_clang_remove_CommentDiagnostic.h branch December 6, 2024 08:32
@Weverything
Copy link
Contributor

I support getting rid of the Diagnostic.h files outside of the Basic directory, at least when they are just forwarding headers. From a layering point of view, Clang_Diagnostics should be the same level as Basic so it shouldn't be having things from AST. Removing the forwarding headers will help clean up the layering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants