[clang-tools-extra] 740575d - [clangd] Fix readability-else-after-return 'Adding a note without main diagnostic' crash

Nathan James via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 04:02:06 PDT 2020


Author: njames93
Date: 2020-06-16T12:01:56+01:00
New Revision: 740575dc232b25de0a4bedb41e825ee2e5a056ea

URL: https://github.com/llvm/llvm-project/commit/740575dc232b25de0a4bedb41e825ee2e5a056ea
DIFF: https://github.com/llvm/llvm-project/commit/740575dc232b25de0a4bedb41e825ee2e5a056ea.diff

LOG: [clangd] Fix readability-else-after-return 'Adding a note without main diagnostic' crash

Fix a crash in clangd caused by an (admittidly incorrect) Remark diagnositic being emitted from readability-else-after-return.
This crash doesn't occur in clang-tidy so there are no tests there for this.

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D81785

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
index b3b4e0de2bf0..a13c172c7f76 100644
--- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -188,9 +188,8 @@ void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) {
     if (IsLastInScope) {
       // If the if statement is the last statement its enclosing statements
       // scope, we can pull the decl out of the if statement.
-      DiagnosticBuilder Diag =
-          diag(ElseLoc, WarningMessage, clang::DiagnosticIDs::Level::Remark)
-          << ControlFlowInterruptor;
+      DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage)
+                               << ControlFlowInterruptor;
       if (checkInitDeclUsageInElse(If) != nullptr) {
         Diag << tooling::fixit::createReplacement(
                     SourceRange(If->getIfLoc()),


        


More information about the cfe-commits mailing list