[clang] [Clang] [NFC] Introduce helpers for defining compatibilty warnings (PR #132129)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 20 07:13:02 PDT 2025
AaronBallman wrote:
> > One question I have is whether we can also add a helper function for emitting these diagnostics.
>
> I was thinking about that too. My first idea was that if we can rely on the order of records in tablegen influencing the order of diagnostic IDs, then one idea is to have some `CompatDiag()` function that can be called as
>
> ```c++
> CompatDiag(loc, getLangOpts().CPlusPlusXY, diag::compat_cxx_xy_foo)
> ```
>
> where `CompatDiag()` is basically defined as
>
> ```c++
> auto Sema::CompatDiag(SourceLocation Loc, bool Std, unsigned DiagId) {
> return Diag(Loc, Std ? DiagId : DiagId + 1);
> ```
>
> but I’m not sure we can rely on that always doing the right thing.
Yeah, I'm not certain that will always work (but it could be fine). I was thinking more along the lines of having tablegen emit something to help with it.
> > the helper function handles translating that to the getLangOpts() dance with the correct diagnostic.
>
> That would be a bit more involved I think as we’d have to actually modify the diagnostics generator, but I think it _should_ be possible; I haven’t looked into that yet though.
+1 but it could be a follow-up.
https://github.com/llvm/llvm-project/pull/132129
More information about the cfe-commits
mailing list