[clang] [Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (PR #132348)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 21 07:13:11 PDT 2025
================
@@ -1518,6 +1518,50 @@ static void verifyDiagnosticWording(const Record &Diag) {
// runs into odd situations like [[clang::warn_unused_result]],
// #pragma clang, or --unwindlib=libgcc.
}
+
+/// ClangDiagsCompatIDsEmitter - Emit a set of 'compatibility diagnostic ids'
+/// that map to a set of 2 regular diagnostic ids each and which are used to
+/// simplify emitting compatibility warnings.
+void clang::EmitClangDiagsCompatIDs(const llvm::RecordKeeper &Records,
----------------
Sirraide wrote:
The begin/end is so we don’t end up with this:
```c++
enum {
#include "foo.inc" // Defines no enumerators because there are no compat diags for this component
};
```
i.e. with
```c++
enum {
};
```
which is just an empty enum which is something that some compilers (including Clang) warn about, so the begin/end allows us to do `#define DIAG_COMPAT_IDS_BEGIN() enum {`, which gets around this because if there are *no* compat diags at all, this just generates an empty file.
> Is the idea that we'd have a different list for parse vs sema?
Yeah, it’s mainly so e.g. parser compatibility diagnostics aren’t visible in sema and vice versa, just like how non-compatibility diagnostics work.
https://github.com/llvm/llvm-project/pull/132348
More information about the cfe-commits
mailing list