[clang] [clang][diagnostics] add '-Wundef-true' warning option (PR #128265)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 1 14:49:27 PST 2025
================
@@ -257,7 +257,10 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
// preprocessor keywords and it wasn't macro expanded, it turns
// into a simple 0
if (ValueLive) {
- PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+ if (II->getName() == "true")
+ PP.Diag(PeekTok, diag::warn_pp_undef_true_identifier);
+ else
+ PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
const DiagnosticsEngine &DiagEngine = PP.getDiagnostics();
// If 'Wundef' is enabled, do not emit 'undef-prefix' diagnostics.
----------------
zygoloid wrote:
We should check the same DiagID we used above in the `isIgnored` check too; the logic is meant to be "if we just issued a diagnostic then don't produce another".
https://github.com/llvm/llvm-project/pull/128265
More information about the cfe-commits
mailing list