<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57568>57568</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy crashes in `readability::BracesAroundStatementsCheck::check` since LLVM 14
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AMS21
      </td>
    </tr>
</table>

<pre>
    Running the following commands
```sh
git clone --recursive https://github.com/AMS21/DLXEmu
cd DLXEmu
git checkout b678c647e938f51441c85549c67fe780d0f74708
cmake . -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
clang-tidy DLXLib/src/StatusRegister.cpp
```

Results in clang-tidy-14.0.6 crashing while clang-tidy-13.0.1 doesn't crash
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: clang-tidy DLXLib/src/StatusRegister.cpp
1.      <eof> parser at end of file
 #0 0x000055fc3b8c4d94 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055fc3b8c24fb SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f6f77769a40 (/usr/lib/libc.so.6+0x38a40)
 #3 0x000055fc3ac17150 clang::Stmt::getEndLoc() const (/usr/local/llvm-14.0.6/bin/clang-tidy+0x3755150)
 #4 0x000055fc3884cee0 clang::tidy::readability::BracesAroundStatementsCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x138aee0)
 #5 0x000055fc3a845ef1 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
 #6 0x000055fc3a8730c1 clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x33b10c1)
 #7 0x000055fc3a847816 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
 #8 0x000055fc3a869ba0 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseReturnStmt(clang::ReturnStmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) ASTMatchFinder.cpp:0:0
 #9 0x000055fc3a864d92 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseStmt(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) ASTMatchFinder.cpp:0:0
#10 0x000055fc3a864f4b clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseStmt(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) (.constprop.0) ASTMatchFinder.cpp:0:0
#11 0x000055fc3a86896c clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionHelper(clang::FunctionDecl*) ASTMatchFinder.cpp:0:0
#12 0x000055fc3a85e2d2 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#13 0x000055fc3a86063f clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) ASTMatchFinder.cpp:0:0
#14 0x000055fc3a85ed79 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#15 0x000055fc3a86063f clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) ASTMatchFinder.cpp:0:0
#16 0x000055fc3a86e9c7 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp:0:0
#17 0x000055fc3a85fca3 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#18 0x000055fc3a85ff0d clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x339df0d)
#19 0x000055fc399b3f88 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x24f1f88)
#20 0x000055fc39bbd7d9 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x26fb7d9)
#21 0x000055fc3997c2b9 clang::FrontendAction::Execute() (/usr/local/llvm-14.0.6/bin/clang-tidy+0x24ba2b9)
#22 0x000055fc398fe8e9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x243c8e9)
#23 0x000055fc3920eda9 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x1d4cda9)
#24 0x000055fc391aff35 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) ClangTidy.cpp:0:0
#25 0x000055fc392079ec clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x1d459ec)
#26 0x000055fc3920b3b5 clang::tooling::ToolInvocation::run() (/usr/local/llvm-14.0.6/bin/clang-tidy+0x1d493b5)
#27 0x000055fc3920d229 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x1d4b229)
#28 0x000055fc391baa90 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) (/usr/local/llvm-14.0.6/bin/clang-tidy+0x1cf8a90)
#29 0x000055fc382b30d6 clang::tidy::clangTidyMain(int, char const**) (/usr/local/llvm-14.0.6/bin/clang-tidy+0xdf10d6)
#30 0x00007f6f777542d0 (/usr/lib/libc.so.6+0x232d0)
#31 0x00007f6f7775438a __libc_start_main (/usr/lib/libc.so.6+0x2338a)
#32 0x000055fc382ab0d5 _start /build/glibc/src/glibc/csu/../sysdeps/x86_64/start.S:117:0
zsh: segmentation fault (core dumped)  clang-tidy DLXLib/src/StatusRegister.cpp
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWltT4zoS_jXhRUXK98tDHkISaqiFgQJ2dt5SsiQnWnxJSTID--tPS87FMuGW7JyidocKTnRx99dft1qS5aymz6Pbpqp4tUBqyVBeF0X9S5dIXZa4onLgTAfOeBA57Ucu24oFV4gUdcXQ6algpBGSPzK0VGolB_544J3DB_osm2wIkqAwvrrzXPieXv6clU0rhFDULRqZS0Ye6kahLIoTEgUxS_0kD90gcEkShkFKojhnceJQJ4-D2EnWkkr8wNAQnU4nV-N_zOaznzfXt_fzyfXVzcXlTH9fjb9P7wDa2fX15cCfXn_f9p1sut1CPSkwGL9t-vnzRePAO9OfVq2uOFWcPmtDLnkGBkpB4HqnsGrkLVtwqZgYktWqR-S6aK63TDaFkohXaCfx1A2GzjBCRGC51B75teQFszr40MFFtGayGnixarvu1XNzORvfzZBsshJIxihrFkiwVS0UUvVbbiuKx83X6UrU_2ZEQZFL2TAJPxCECMAmRUOZCSADAWWYPCiBCRu26oEN8oBoU660FlPlDJH5uxH1QuASYbFoSlYpjQN9nld3LW7gT1idD_wZWmEhmUBYIQYY6xzlQF_bGQ0830HOkwN_YZgTP0tIQNMAwPBKGbD3Gv0dX1S4-AY2FkwMvOSx5nTgAU0papukAeCPHfO_le32ZHtBnqG-MND0riBvLSjOozyO4yjFgQP1CRDRSKH9YqiBKxnKehhBYDpPfgK9QPROjN_Fg4kbu6HTcqzd4YN7StX-WjA1q-hlTYySFLJAJZWtsSa42EREG6JQyjhE4PnObS2QOAxBkwUl6EJJkoAwZkExN5tfgmGKM15wta440y6RY1E3FdVhwEy4THTCaDuY3AFYO-KwVPMSK2gRsq250qVzXlFwwq6iHYGtuQMv0qYfaLQL9INNltGhxX8ShCx30ZsoITiYgLhoSwAFV3X1XNaNRBUumVwBFVrFzoLx3f0PLrmqu2ZZNY-6YKrf4-hMU_y9pkxajICKDnv7IzayTY19h3zK1J3qe8HYWcOLraN2-HXqe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