[clang] [Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (PR #132348)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 21 06:15:21 PDT 2025
================
@@ -769,6 +770,51 @@ StringRef DiagnosticIDs::getNearestOption(diag::Flavor Flavor,
return Best;
}
+unsigned DiagnosticIDs::getCompatDiagId(const LangOptions &LangOpts,
+ unsigned CompatDiagId) {
+ struct CompatDiag {
+ unsigned StdVer;
+ unsigned DiagId;
+ unsigned PreDiagId;
+ };
+
+ // We encode the standard version such that C++98 < C++11 < C++14 etc. The
+ // actual numbers don't really matter for this, but the definitions of the
+ // compat diags in the Tablegen file use the standard version number (i.e.
+ // 98, 11, 14, etc.), so we base the encoding here on that.
+#define DIAG_COMPAT_IDS_BEGIN()
+#define DIAG_COMPAT_IDS_END()
+#define DIAG_COMPAT_ID(Value, Name, Std, Diag, DiagPre) \
+ {Std == 98 ? 1998 : 2000 + Std, diag::Diag, diag::DiagPre},
----------------
erichkeane wrote:
Since this function is only handling C++ compat instead of C compat as well... should we name this `getCXXCompatDiagId`? OR BETTER: Can we just expand this whole thing to work for C as well?
https://github.com/llvm/llvm-project/pull/132348
More information about the cfe-commits
mailing list