Author: Ken Matsui Date: 2022-04-28T22:22:27-04:00 New Revision: 52ce95a1a55424256f0d56e32392396896ed7f76
URL: https://github.com/llvm/llvm-project/commit/52ce95a1a55424256f0d56e32392396896ed7f76 DIFF: https://github.com/llvm/llvm-project/commit/52ce95a1a55424256f0d56e32392396896ed7f76.diff LOG: [NFC] Prevent shadowing a variable declared in `if` Prevents confusion over which `S` is referenced in the final `else` branch if such use is added. Reviewed By: hubert.reinterpretcast Differential Revision: https://reviews.llvm.org/D124556 Added: Modified: clang/lib/Basic/Diagnostic.cpp Removed: ################################################################################ diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 3315012685d69..d14134f99ee95 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -983,13 +983,13 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, if (const char *S = tok::getPunctuatorSpelling(Kind)) // Quoted token spelling for punctuators. Out << '\'' << S << '\''; - else if (const char *S = tok::getKeywordSpelling(Kind)) + else if ((S = tok::getKeywordSpelling(Kind))) // Unquoted token spelling for keywords. Out << S; - else if (const char *S = getTokenDescForDiagnostic(Kind)) + else if ((S = getTokenDescForDiagnostic(Kind))) // Unquoted translatable token name. Out << S; - else if (const char *S = tok::getTokenName(Kind)) + else if ((S = tok::getTokenName(Kind))) // Debug name, shouldn't appear in user-facing diagnostics. Out << '<' << S << '>'; else _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits