diff --git a/clang/include/clang/Basic/CMakeLists.txt b/clang/include/clang/Basic/CMakeLists.txt index 4d5e1eaa3fac..265ea1fc0649 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 41e2598f7cc3..be9e303d9262 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 5ead092b946c..8e2635ffbd78 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 08e66e805183..f2a325c4e167 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 761716d78144..4c0aa8cd2669 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 864a23a49e4c..e00dcedd68ab 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 3506f05daae5..923ddd3b45ba 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 f936d4fb7a40..80d52a0d0111 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 4619bfeea05a..9d814522270e 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 6fa90f785bbf..f20f4fcd2d3d 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 e2a4368a59c4..1e025bdf0241 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 b3f3a10925f0..380060e51d0f 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 { \ - enum { -#define DIAG_ENUM_ITEM(IDX, NAME) NAME = IDX, -#define DIAG_ENUM_END() \ - } \ - ; \ - } -#include "clang/Basic/DiagnosticRefactoringEnums.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/DiagnosticRefactoringCompatIDs.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/DiagnosticRefactoringInterface.inc" #endif // LLVM_CLANG_BASIC_DIAGNOSTICREFACTORING_H diff --git a/clang/include/clang/Basic/DiagnosticSema.h b/clang/include/clang/Basic/DiagnosticSema.h index 943b2f64f427..26a5f719a299 100644 --- a/clang/include/clang/Basic/DiagnosticSema.h +++ b/clang/include/clang/Basic/DiagnosticSema.h @@ -10,45 +10,6 @@ #define LLVM_CLANG_BASIC_DIAGNOSTICSEMA_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 SEMASTART -#include "clang/Basic/DiagnosticSemaKinds.inc" -#undef DIAG - NUM_BUILTIN_SEMA_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/DiagnosticSemaEnums.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/DiagnosticSemaCompatIDs.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/DiagnosticSemaInterface.inc" #endif // LLVM_CLANG_BASIC_DIAGNOSTICSEMA_H diff --git a/clang/include/clang/Basic/DiagnosticSerialization.h b/clang/include/clang/Basic/DiagnosticSerialization.h index c8fb034e9bd4..27df12e5f098 100644 --- a/clang/include/clang/Basic/DiagnosticSerialization.h +++ b/clang/include/clang/Basic/DiagnosticSerialization.h @@ -10,44 +10,6 @@ #define LLVM_CLANG_BASIC_DIAGNOSTICSERIALIZATION_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 SERIALIZATIONSTART -#include "clang/Basic/DiagnosticSerializationKinds.inc" -#undef DIAG - NUM_BUILTIN_SERIALIZATION_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/DiagnosticSerializationEnums.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/DiagnosticSerializationCompatIDs.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/DiagnosticSerializationInterface.inc" #endif // LLVM_CLANG_BASIC_DIAGNOSTICSERIALIZATION_H diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 73facbc91671..cb309fb2e19e 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -20,6 +20,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Format.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/StringToOffsetTable.h" @@ -1562,6 +1563,60 @@ void clang::EmitClangDiagsCompatIDs(const llvm::RecordKeeper &Records, OS << "DIAG_COMPAT_IDS_END()\n"; } +/// ClangDiagsIntefaceEmitter - Emit the diagnostics interface header for +/// a Clang component. +void clang::EmitClangDiagsInterface(llvm::raw_ostream &OS, + const std::string &Component) { + if (Component.empty()) + PrintFatalError("'-gen-clang-diags-iface' requires a component name"); + + std::string ComponentUpper = StringRef(Component).upper(); + const char *Comp = Component.c_str(); + const char *Upper = ComponentUpper.c_str(); + + OS << llvm::format(R"c++( +namespace clang { +namespace diag { +enum { +#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \ + SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY) \ + ENUM, +#define %sSTART +#include "clang/Basic/Diagnostic%sKinds.inc" +#undef DIAG + NUM_BUILTIN_%s_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/Diagnostic%sEnums.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/Diagnostic%sCompatIDs.inc" +#undef DIAG_COMPAT_ID +#undef DIAG_COMPAT_IDS_BEGIN +#undef DIAG_COMPAT_IDS_END +} // end namespace diag_compat +} // end namespace clang +)c++", + Upper, Comp, Upper, Comp, Comp); +} + /// ClangDiagsEnumsEmitter - The top-level class emits .def files containing /// declarations of Clang diagnostic enums for selects. void clang::EmitClangDiagsEnums(const RecordKeeper &Records, raw_ostream &OS, diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp index 4d3d56ed4b9d..a2c6f002f735 100644 --- a/clang/utils/TableGen/TableGen.cpp +++ b/clang/utils/TableGen/TableGen.cpp @@ -53,6 +53,7 @@ enum ActionType { GenClangDiagsEnums, GenClangDiagGroups, GenClangDiagsIndexName, + GenClangDiagsInterface, GenClangCommentNodes, GenClangDeclNodes, GenClangStmtNodes, @@ -187,6 +188,8 @@ cl::opt Action( "Generate Clang diagnostic groups"), clEnumValN(GenClangDiagsIndexName, "gen-clang-diags-index-name", "Generate Clang diagnostic name index"), + clEnumValN(GenClangDiagsInterface, "gen-clang-diags-iface", + "Generate Clang diagnostic interface headers"), clEnumValN(GenClangBasicReader, "gen-clang-basic-reader", "Generate Clang BasicReader classes"), clEnumValN(GenClangBasicWriter, "gen-clang-basic-writer", @@ -417,6 +420,9 @@ bool ClangTableGenMain(raw_ostream &OS, const RecordKeeper &Records) { case GenClangDiagsIndexName: EmitClangDiagsIndexName(Records, OS); break; + case GenClangDiagsInterface: + EmitClangDiagsInterface(OS, ClangComponent); + break; case GenClangCommentNodes: EmitClangASTNodes(Records, OS, CommentNodeClassName, ""); break; diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h index c26ce2825ea9..54031147d38e 100644 --- a/clang/utils/TableGen/TableGenBackends.h +++ b/clang/utils/TableGen/TableGenBackends.h @@ -102,6 +102,8 @@ void EmitClangDiagGroups(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS); void EmitClangDiagsIndexName(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangDiagsInterface(llvm::raw_ostream &OS, + const std::string &Component); void EmitClangSACheckers(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);