[clang-tidy] RedundantControlFlowCheck::issueDiagnostic - use cast<> instead of dyn_c...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 12 Feb 2022 11:05:59 +0000 (11:05 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 12 Feb 2022 11:05:59 +0000 (11:05 +0000)
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp

index 6af7763..dd63de3 100644 (file)
@@ -79,7 +79,7 @@ void RedundantControlFlowCheck::issueDiagnostic(
   SourceLocation Start;
   if (Previous != Block->body_rend())
     Start = Lexer::findLocationAfterToken(
-        dyn_cast<Stmt>(*Previous)->getEndLoc(), tok::semi, SM, getLangOpts(),
+        cast<Stmt>(*Previous)->getEndLoc(), tok::semi, SM, getLangOpts(),
         /*SkipTrailingWhitespaceAndNewLine=*/true);
   if (!Start.isValid())
     Start = StmtRange.getBegin();