-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] [NFC] Tablegen component diags headers #134777
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
@llvm/pr-subscribers-clang Author: None (Sirraide) ChangesThe component diagnostic headers (i.e. Also, it seems that Patch is 29.50 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/134777.diff 17 Files Affected:
diff --git a/clang/include/clang/Basic/CMakeLists.txt b/clang/include/clang/Basic/CMakeLists.txt
index 4d5e1eaa3facb..265ea1fc06494 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -13,6 +13,11 @@ macro(clang_diag_gen component)
-gen-clang-diags-compat-ids -clang-component=${component}
SOURCE Diagnostic.td
TARGET ClangDiagnostic${component}CompatIDs)
+
+ clang_tablegen(Diagnostic${component}Interface.inc
+ -gen-clang-diags-iface -clang-component=${component}
+ SOURCE Diagnostic.td
+ TARGET ClangDiagnostic${component}Interface)
endmacro(clang_diag_gen)
clang_diag_gen(Analysis)
diff --git a/clang/include/clang/Basic/DiagnosticAST.h b/clang/include/clang/Basic/DiagnosticAST.h
index 41e2598f7cc3b..be9e303d92629 100644
--- a/clang/include/clang/Basic/DiagnosticAST.h
+++ b/clang/include/clang/Basic/DiagnosticAST.h
@@ -10,44 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICAST_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define ASTSTART
-#include "clang/Basic/DiagnosticASTKinds.inc"
-#undef DIAG
- NUM_BUILTIN_AST_DIAGNOSTICS
-};
-
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticASTEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // end namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticASTCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // end namespace clang
+#include "clang/Basic/DiagnosticASTInterface.inc"
#endif // LLVM_CLANG_BASIC_DIAGNOSTICAST_H
diff --git a/clang/include/clang/Basic/DiagnosticAnalysis.h b/clang/include/clang/Basic/DiagnosticAnalysis.h
index 5ead092b946c5..8e2635ffbd78d 100644
--- a/clang/include/clang/Basic/DiagnosticAnalysis.h
+++ b/clang/include/clang/Basic/DiagnosticAnalysis.h
@@ -10,43 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICANALYSIS_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define ANALYSISSTART
-#include "clang/Basic/DiagnosticAnalysisKinds.inc"
-#undef DIAG
- NUM_BUILTIN_ANALYSIS_DIAGNOSTICS
-};
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticAnalysisEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // end namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticAnalysisCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // end namespace clang
+#include "clang/Basic/DiagnosticAnalysisInterface.inc"
#endif // LLVM_CLANG_BASIC_DIAGNOSTICANALYSIS_H
diff --git a/clang/include/clang/Basic/DiagnosticComment.h b/clang/include/clang/Basic/DiagnosticComment.h
index 08e66e8051834..f2a325c4e167a 100644
--- a/clang/include/clang/Basic/DiagnosticComment.h
+++ b/clang/include/clang/Basic/DiagnosticComment.h
@@ -10,44 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICCOMMENT_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define COMMENTSTART
-#include "clang/Basic/DiagnosticCommentKinds.inc"
-#undef DIAG
- NUM_BUILTIN_COMMENT_DIAGNOSTICS
-};
-
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticCommentEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // end namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticCommentCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // end namespace clang
+#include "clang/Basic/DiagnosticCommentInterface.inc"
#endif // LLVM_CLANG_BASIC_DIAGNOSTICCOMMENT_H
diff --git a/clang/include/clang/Basic/DiagnosticCrossTU.h b/clang/include/clang/Basic/DiagnosticCrossTU.h
index 761716d781446..4c0aa8cd26698 100644
--- a/clang/include/clang/Basic/DiagnosticCrossTU.h
+++ b/clang/include/clang/Basic/DiagnosticCrossTU.h
@@ -10,44 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICCROSSTU_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define CROSSTUSTART
-#include "clang/Basic/DiagnosticCrossTUKinds.inc"
-#undef DIAG
- NUM_BUILTIN_CROSSTU_DIAGNOSTICS
-};
-
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticCrossTUEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // end namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticCrossTUCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // end namespace clang
+#include "clang/Basic/DiagnosticCrossTUInterface.inc"
#endif // LLVM_CLANG_BASIC_DIAGNOSTICCROSSTU_H
diff --git a/clang/include/clang/Basic/DiagnosticDriver.h b/clang/include/clang/Basic/DiagnosticDriver.h
index 864a23a49e4cd..e00dcedd68ab1 100644
--- a/clang/include/clang/Basic/DiagnosticDriver.h
+++ b/clang/include/clang/Basic/DiagnosticDriver.h
@@ -10,44 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICDRIVER_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define DRIVERSTART
-#include "clang/Basic/DiagnosticDriverKinds.inc"
-#undef DIAG
- NUM_BUILTIN_DRIVER_DIAGNOSTICS
-};
-
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticDriverEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // end namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticDriverCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // end namespace clang
+#include "clang/Basic/DiagnosticDriverInterface.inc"
#endif // LLVM_CLANG_BASIC_DIAGNOSTICDRIVER_H
diff --git a/clang/include/clang/Basic/DiagnosticFrontend.h b/clang/include/clang/Basic/DiagnosticFrontend.h
index 3506f05daae54..923ddd3b45ba0 100644
--- a/clang/include/clang/Basic/DiagnosticFrontend.h
+++ b/clang/include/clang/Basic/DiagnosticFrontend.h
@@ -10,44 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICFRONTEND_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define FRONTENDSTART
-#include "clang/Basic/DiagnosticFrontendKinds.inc"
-#undef DIAG
- NUM_BUILTIN_FRONTEND_DIAGNOSTICS
-};
-
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticFrontendEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // end namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticFrontendCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // end namespace clang
+#include "clang/Basic/DiagnosticFrontendInterface.inc"
#endif // LLVM_CLANG_BASIC_DIAGNOSTICFRONTEND_H
diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index f936d4fb7a403..80d52a0d01112 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -71,17 +71,6 @@ namespace clang {
/// All of the diagnostics that can be emitted by the frontend.
typedef unsigned kind;
- // Get typedefs for common diagnostics.
- enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, CATEGORY, \
- NOWERROR, SHOWINSYSHEADER, SHOWINSYSMACRO, DEFFERABLE) \
- ENUM,
-#define COMMONSTART
-#include "clang/Basic/DiagnosticCommonKinds.inc"
- NUM_BUILTIN_COMMON_DIAGNOSTICS
-#undef DIAG
- };
-
/// Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs
/// to either Ignore (nothing), Remark (emit a remark), Warning
/// (emit a warning) or Error (emit as an error). It allows clients to
@@ -103,20 +92,13 @@ namespace clang {
Remark ///< A diagnostic that indicates normal progress through
///< compilation.
};
- }
+ } // end namespace diag
+} // end namespace clang
- namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticCommonCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
- } // end namespace diag_compat
+// This has to be included *after* the DIAG_START_ enums above are defined.
+#include "clang/Basic/DiagnosticCommonInterface.inc"
+namespace clang {
class DiagnosticMapping {
LLVM_PREFERRED_TYPE(diag::Severity)
unsigned Severity : 3;
diff --git a/clang/include/clang/Basic/DiagnosticInstallAPI.h b/clang/include/clang/Basic/DiagnosticInstallAPI.h
index 4619bfeea05a2..9d814522270e5 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPI.h
+++ b/clang/include/clang/Basic/DiagnosticInstallAPI.h
@@ -10,42 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICINSTALLAPI_H
#include "clang/Basic/Diagnostic.h"
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define INSTALLAPISTART
-#include "clang/Basic/DiagnosticInstallAPIKinds.inc"
-#undef DIAG
- NUM_BUILTIN_INSTALLAPI_DIAGNOSTICS
-};
+#include "clang/Basic/DiagnosticInstallAPIInterface.inc"
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticInstallAPIEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticInstallAPICompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // namespace clang
#endif // LLVM_CLANG_BASIC_DIAGNOSTICINSTALLAPI_H
diff --git a/clang/include/clang/Basic/DiagnosticLex.h b/clang/include/clang/Basic/DiagnosticLex.h
index 6fa90f785bbf8..f20f4fcd2d3d7 100644
--- a/clang/include/clang/Basic/DiagnosticLex.h
+++ b/clang/include/clang/Basic/DiagnosticLex.h
@@ -10,43 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICLEX_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define LEXSTART
-#include "clang/Basic/DiagnosticLexKinds.inc"
-#undef DIAG
- NUM_BUILTIN_LEX_DIAGNOSTICS
-};
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticLexEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // end namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticLexCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // end namespace clang
+#include "clang/Basic/DiagnosticLexInterface.inc"
#endif // LLVM_CLANG_BASIC_DIAGNOSTICLEX_H
diff --git a/clang/include/clang/Basic/DiagnosticParse.h b/clang/include/clang/Basic/DiagnosticParse.h
index e2a4368a59c4b..1e025bdf02415 100644
--- a/clang/include/clang/Basic/DiagnosticParse.h
+++ b/clang/include/clang/Basic/DiagnosticParse.h
@@ -10,44 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICPARSE_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define PARSESTART
-#include "clang/Basic/DiagnosticParseKinds.inc"
-#undef DIAG
- NUM_BUILTIN_PARSE_DIAGNOSTICS
-};
-
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { \
- enum {
-#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX,
-#define DIAG_ENUM_END() \
- } \
- ; \
- }
-#include "clang/Basic/DiagnosticParseEnums.inc"
-#undef DIAG_ENUM_END
-#undef DIAG_ENUM_ITEM
-#undef DIAG_ENUM
-} // end namespace diag
-
-namespace diag_compat {
-#define DIAG_COMPAT_IDS_BEGIN() enum {
-#define DIAG_COMPAT_IDS_END() \
- } \
- ;
-#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
-#include "clang/Basic/DiagnosticParseCompatIDs.inc"
-#undef DIAG_COMPAT_ID
-#undef DIAG_COMPAT_IDS_BEGIN
-#undef DIAG_COMPAT_IDS_END
-} // end namespace diag_compat
-} // end namespace clang
+#include "clang/Basic/DiagnosticParseInterface.inc"
#endif // LLVM_CLANG_BASIC_DIAGNOSTICPARSE_H
diff --git a/clang/include/clang/Basic/DiagnosticRefactoring.h b/clang/include/clang/Basic/DiagnosticRefactoring.h
index b3f3a10925f09..380060e51d0f6 100644
--- a/clang/include/clang/Basic/DiagnosticRefactoring.h
+++ b/clang/include/clang/Basic/DiagnosticRefactoring.h
@@ -10,44 +10,6 @@
#define LLVM_CLANG_BASIC_DIAGNOSTICREFACTORING_H
#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-namespace diag {
-enum {
-#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \
- ENUM,
-#define REFACTORINGSTART
-#include "clang/Basic/DiagnosticRefactoringKinds.inc"
-#undef DIAG
- NUM_BUILTIN_REFACTORING_DIAGNOSTICS
-};
-
-#define DIAG_ENUM(ENUM_NAME) \
- namespace ENUM_NAME { ...
[truncated]
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/include/clang/Basic/DiagnosticAST.h clang/include/clang/Basic/DiagnosticAnalysis.h clang/include/clang/Basic/DiagnosticComment.h clang/include/clang/Basic/DiagnosticCrossTU.h clang/include/clang/Basic/DiagnosticDriver.h clang/include/clang/Basic/DiagnosticFrontend.h clang/include/clang/Basic/DiagnosticIDs.h clang/include/clang/Basic/DiagnosticInstallAPI.h clang/include/clang/Basic/DiagnosticLex.h clang/include/clang/Basic/DiagnosticParse.h clang/include/clang/Basic/DiagnosticRefactoring.h clang/include/clang/Basic/DiagnosticSema.h clang/include/clang/Basic/DiagnosticSerialization.h clang/utils/TableGen/ClangDiagnosticsEmitter.cpp clang/utils/TableGen/TableGen.cpp clang/utils/TableGen/TableGenBackends.h View the diff from clang-format here.diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index 80d52a0d0..83891ff11 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -92,83 +92,86 @@ namespace clang {
Remark ///< A diagnostic that indicates normal progress through
///< compilation.
};
- } // end namespace diag
-} // end namespace clang
+ } // end namespace diag
+ } // end namespace clang
-// This has to be included *after* the DIAG_START_ enums above are defined.
+ // This has to be included *after* the DIAG_START_ enums above are defined.
#include "clang/Basic/DiagnosticCommonInterface.inc"
-namespace clang {
-class DiagnosticMapping {
- LLVM_PREFERRED_TYPE(diag::Severity)
- unsigned Severity : 3;
- LLVM_PREFERRED_TYPE(bool)
- unsigned IsUser : 1;
- LLVM_PREFERRED_TYPE(bool)
- unsigned IsPragma : 1;
- LLVM_PREFERRED_TYPE(bool)
- unsigned HasNoWarningAsError : 1;
- LLVM_PREFERRED_TYPE(bool)
- unsigned HasNoErrorAsFatal : 1;
- LLVM_PREFERRED_TYPE(bool)
- unsigned WasUpgradedFromWarning : 1;
-
-public:
- static DiagnosticMapping Make(diag::Severity Severity, bool IsUser,
- bool IsPragma) {
- DiagnosticMapping Result;
- Result.Severity = (unsigned)Severity;
- Result.IsUser = IsUser;
- Result.IsPragma = IsPragma;
- Result.HasNoWarningAsError = 0;
- Result.HasNoErrorAsFatal = 0;
- Result.WasUpgradedFromWarning = 0;
- return Result;
- }
+ namespace clang {
+ class DiagnosticMapping {
+ LLVM_PREFERRED_TYPE(diag::Severity)
+ unsigned Severity : 3;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned IsUser : 1;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned IsPragma : 1;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned HasNoWarningAsError : 1;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned HasNoErrorAsFatal : 1;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned WasUpgradedFromWarning : 1;
+
+ public:
+ static DiagnosticMapping Make(diag::Severity Severity, bool IsUser,
+ bool IsPragma) {
+ DiagnosticMapping Result;
+ Result.Severity = (unsigned)Severity;
+ Result.IsUser = IsUser;
+ Result.IsPragma = IsPragma;
+ Result.HasNoWarningAsError = 0;
+ Result.HasNoErrorAsFatal = 0;
+ Result.WasUpgradedFromWarning = 0;
+ return Result;
+ }
- diag::Severity getSeverity() const { return (diag::Severity)Severity; }
- void setSeverity(diag::Severity Value) { Severity = (unsigned)Value; }
+ diag::Severity getSeverity() const { return (diag::Severity)Severity; }
+ void setSeverity(diag::Severity Value) { Severity = (unsigned)Value; }
- bool isUser() const { return IsUser; }
- bool isPragma() const { return IsPragma; }
+ bool isUser() const { return IsUser; }
+ bool isPragma() const { return IsPragma; }
- bool isErrorOrFatal() const {
- return getSeverity() == diag::Severity::Error ||
- getSeverity() == diag::Severity::Fatal;
- }
+ bool isErrorOrFatal() const {
+ return getSeverity() == diag::Severity::Error ||
+ getSeverity() == diag::Severity::Fatal;
+ }
- bool hasNoWarningAsError() const { return HasNoWarningAsError; }
- void setNoWarningAsError(bool Value) { HasNoWarningAsError = Value; }
+ bool hasNoWarningAsError() const { return HasNoWarningAsError; }
+ void setNoWarningAsError(bool Value) { HasNoWarningAsError = Value; }
- bool hasNoErrorAsFatal() const { return HasNoErrorAsFatal; }
- void setNoErrorAsFatal(bool Value) { HasNoErrorAsFatal = Value; }
+ bool hasNoErrorAsFatal() const { return HasNoErrorAsFatal; }
+ void setNoErrorAsFatal(bool Value) { HasNoErrorAsFatal = Value; }
- /// Whether this mapping attempted to map the diagnostic to a warning, but
- /// was overruled because the diagnostic was already mapped to an error or
- /// fatal error.
- bool wasUpgradedFromWarning() const { return WasUpgradedFromWarning; }
- void setUpgradedFromWarning(bool Value) { WasUpgradedFromWarning = Value; }
+ /// Whether this mapping attempted to map the diagnostic to a warning, but
+ /// was overruled because the diagnostic was already mapped to an error or
+ /// fatal error.
+ bool wasUpgradedFromWarning() const { return WasUpgradedFromWarning; }
+ void setUpgradedFromWarning(bool Value) {
+ WasUpgradedFromWarning = Value;
+ }
- /// Serialize this mapping as a raw integer.
- unsigned serialize() const {
- return (IsUser << 7) | (IsPragma << 6) | (HasNoWarningAsError << 5) |
- (HasNoErrorAsFatal << 4) | (WasUpgradedFromWarning << 3) | Severity;
- }
- /// Deserialize a mapping.
- static DiagnosticMapping deserialize(unsigned Bits) {
- DiagnosticMapping Result;
- Result.IsUser = (Bits >> 7) & 1;
- Result.IsPragma = (Bits >> 6) & 1;
- Result.HasNoWarningAsError = (Bits >> 5) & 1;
- Result.HasNoErrorAsFatal = (Bits >> 4) & 1;
- Result.WasUpgradedFromWarning = (Bits >> 3) & 1;
- Result.Severity = Bits & 0x7;
- return Result;
- }
+ /// Serialize this mapping as a raw integer.
+ unsigned serialize() const {
+ return (IsUser << 7) | (IsPragma << 6) | (HasNoWarningAsError << 5) |
+ (HasNoErrorAsFatal << 4) | (WasUpgradedFromWarning << 3) |
+ Severity;
+ }
+ /// Deserialize a mapping.
+ static DiagnosticMapping deserialize(unsigned Bits) {
+ DiagnosticMapping Result;
+ Result.IsUser = (Bits >> 7) & 1;
+ Result.IsPragma = (Bits >> 6) & 1;
+ Result.HasNoWarningAsError = (Bits >> 5) & 1;
+ Result.HasNoErrorAsFatal = (Bits >> 4) & 1;
+ Result.WasUpgradedFromWarning = (Bits >> 3) & 1;
+ Result.Severity = Bits & 0x7;
+ return Result;
+ }
- bool operator==(DiagnosticMapping Other) const {
- return serialize() == Other.serialize();
- }
+ bool operator==(DiagnosticMapping Other) const {
+ return serialize() == Other.serialize();
+ }
};
/// Used for handling and querying diagnostic IDs.
@@ -502,6 +505,6 @@ private:
friend class DiagnosticsEngine;
};
-} // end namespace clang
+} // end namespace clang
#endif
|
clang-format seems to be having a stroke here. It’s suggesting indenting I think we should just ignore this because it’d probably take reformatting the entire file (or at least everything before the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this!
const char *Upper = ComponentUpper.c_str(); | ||
|
||
OS << llvm::format(R"c++( | ||
namespace clang { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all so common (differing only by the one name change) that I wonder if tablegen is the right place for this, instead of just a predefined file. BUT I can't htink of a way to do that which doesn't require preprocessor string-replacement inside of a #include
or define
identifier, which, IIRC is UB?
SO I guess this is ok and the only way we can reasonably do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUT I can't htink of a way to do that which doesn't require preprocessor string-replacement inside of a
#include
ordefine
identifier, which, IIRC is UB?
Yeah, I think the preprocessor directives are the main problem, e.g. the #define ASTSTART
; there isn’t really a way to do this just in the preprocessor unfortunately...
} // end namespace diag_compat | ||
} // end namespace clang | ||
)c++", | ||
Upper, Comp, Upper, Comp, Comp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unfortunate part of this interface... Does llvm::format
not support the std::format
positional arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unfortunate part of this interface... Does
llvm::format
not support thestd::format
positional arguments?
It uses snprintf
... which doesn’t support them on Windows. I tried...
The component diagnostic headers (i.e.
DiagnosticAST.h
and friends) all follow the same format, and there’s enough of them (and in them) to where updating all of them has become rather tedious (at least it was for me while working on #132348), so this patch instead generates all of them (or rather their contents) via Tablegen.Also, it seems that
%enum_select
currently wouldn’t work inDiagnosticCommonKinds.td
because the infrastructure for that was missing fromDiagnosticIDs.h
; this patch should fix that as well.