[PATCH] D92272: [clang-tidy] [clangd] Avoid multi-line diagnostic range for else-after-return diagnostic
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 03:34:23 PST 2020
njames93 added a comment.
This small fix is definitely worth while, the more involved patch may not ever land.
================
Comment at: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:322
DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage)
- << ControlFlowInterruptor;
+ << ControlFlowInterruptor << SourceRange(ElseLoc);
removeElseAndBrackets(Diag, *Result.Context, Else, ElseLoc);
----------------
There are more places where diag is called. Maybe add this to all callsites of diag that then emit fixes, otherwise this may miss a few cases.
================
Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:486
+ )cpp");
+ TestTU TU = TestTU::withCode(Main.code());
+ TU.ClangTidyChecks = "-*,llvm-else-after-return";
----------------
This needs rebasing, clang tidy interface for checks has changed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92272/new/
https://reviews.llvm.org/D92272
More information about the cfe-commits
mailing list