-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[diagtool] Make the BuiltinDiagnosticsByID table sorted #120321
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,28 +23,29 @@ llvm::ArrayRef<DiagnosticRecord> diagtool::getBuiltinDiagnosticsByName() { | |
| return llvm::ArrayRef(BuiltinDiagnosticsByName); | ||
| } | ||
|
|
||
|
|
||
| // FIXME: Is it worth having two tables, especially when this one can get | ||
| // out of sync easily? | ||
| // clang-format off | ||
| static const DiagnosticRecord BuiltinDiagnosticsByID[] = { | ||
| #define DIAG(ENUM, CLASS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \ | ||
| SHOWINSYSHEADER, SHOWINSYSMACRO, DEFER, CATEGORY) \ | ||
| {#ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t)}, | ||
| #include "clang/Basic/DiagnosticCommonKinds.inc" | ||
| #include "clang/Basic/DiagnosticCrossTUKinds.inc" | ||
| #include "clang/Basic/DiagnosticDriverKinds.inc" | ||
| #include "clang/Basic/DiagnosticFrontendKinds.inc" | ||
| #include "clang/Basic/DiagnosticSerializationKinds.inc" | ||
| #include "clang/Basic/DiagnosticLexKinds.inc" | ||
| #include "clang/Basic/DiagnosticParseKinds.inc" | ||
| #include "clang/Basic/DiagnosticASTKinds.inc" | ||
| #include "clang/Basic/DiagnosticCommentKinds.inc" | ||
| #include "clang/Basic/DiagnosticCrossTUKinds.inc" | ||
|
||
| #include "clang/Basic/DiagnosticSemaKinds.inc" | ||
| #include "clang/Basic/DiagnosticAnalysisKinds.inc" | ||
| #include "clang/Basic/DiagnosticRefactoringKinds.inc" | ||
| #include "clang/Basic/DiagnosticInstallAPIKinds.inc" | ||
| #undef DIAG | ||
| }; | ||
| // clang-format on | ||
|
|
||
| static bool orderByID(const DiagnosticRecord &Left, | ||
| const DiagnosticRecord &Right) { | ||
|
|
||
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.
Add a comment about why we turn off clang-format:
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.
also it's unclear where the "ground truth" for this order is coming from. AFAICT, order is defined by https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticIDs.h#L49-L65
and enforced by very subtle interactions between tablegen and how particular headers include these.
since this order needs to be preserved in multiple places, can you put together a wrapper header, which includes individual diagnostic kinds in the specific order and explain the relationship between these pieces? (I'd rather have a solution that puts all of this logic into tablegen instead, generating enums with a particular order once, but I can see that's a much bigger change that you might not want to sign up).
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.
"since this order needs to be preserved in multiple places, can you put together a wrapper header, which includes individual diagnostic kinds in the specific order and explain the relationship between these pieces?"
@kadircet I added a new file DiagnosticsID.inc as a "wrapper header".