[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 14:23:47 PDT 2025
================
@@ -155,6 +155,38 @@ class DefaultWarnNoWerror {
}
class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
+// C++ compatibility warnings.
+multiclass CXXCompat<
+ string message,
+ int std_ver,
+ bit ext_warn = true,
+ string std_ver_override = ""#std_ver> {
+ // 'X is a C++YZ extension'.
+ def compat_pre_cxx#std_ver#_#NAME :
+ Diagnostic<!strconcat(message, " a C++", std_ver_override, " extension"),
+ CLASS_EXTENSION,
+ !if(ext_warn, SEV_Warning, SEV_Ignored)>,
+ InGroup<!cast<DiagGroup>("CXX"#std_ver)>;
+
+ // 'X is incompatible with C++98' (if std_ver == 11).
+ // 'X is incompatible with C++ standards before C++YZ' (otherwise).
+ def compat_cxx#std_ver#_#NAME :
+ Warning<!if(!eq(std_ver, 11),
+ !strconcat(message, " incompatible with C++98"),
+ !strconcat(message, " incompatible with C++ standards before C++", std_ver_override))>,
+ InGroup<!cast<DiagGroup>(!if(!eq(std_ver, 11),
+ "CXX98Compat",
+ "CXXPre"#std_ver#"Compat"))>,
+ DefaultIgnore;
+}
+
+multiclass CXX11Compat<string message, bit ext_warn = true> : CXXCompat<message, 11, ext_warn>;
----------------
AaronBallman wrote:
The helper function would address my concerns such that we probably don't need to rename the diagnostics at all.
https://github.com/llvm/llvm-project/pull/132129
More information about the cfe-commits
mailing list