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

    <tr>
        <th>Summary</th>
        <td>
            readability-simplify-boolean-expr crashes on invalid code
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

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

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

<pre>
    The following code causes clang-tidy to crash due to trying to return a bool in a void function
```cpp
void bar(bool Cond) {
  if (Cond)
    return true;
  return false;
}
```
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/nathan/src/llvm-project/build/Debug/bin/clang-tidy test.cpp -checks=-*,readability-simplify-boolean-expr --
1.      <eof> parser at end of file
2.      ASTMatcher: Processing 'readability-simplify-boolean-expr' against:
        TranslationUnitDecl : <<invalid sloc>>
No bound nodes
 #0 0x00007f8d8bc6359a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/nathan/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
 #1 0x00007f8d8bc6374b PrintStackTraceSignalHandler(void*) /home/nathan/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x00007f8d8bc61df6 llvm::sys::RunSignalHandlers() /home/nathan/src/llvm-project/llvm/lib/Support/Signals.cpp:103:5
 #3 0x00007f8d8bc63e65 SignalHandler(int) /home/nathan/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f8d91265420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #5 0x00007f8d8ce35e9c clang::Stmt::getStmtClass() const /home/nathan/src/llvm-project/clang/include/clang/AST/Stmt.h:1164:44
 #6 0x00007f8d8d5eac19 clang::Stmt::getBeginLoc() const /home/nathan/src/llvm-project/clang/lib/AST/Stmt.cpp:337:3
 #7 0x00007f8d8e54054e clang::tidy::readability::SimplifyBooleanExprCheck::replaceCompoundReturnWithCondition(clang::ASTContext const&, clang::ReturnStmt const*, bool, clang::IfStmt const*) /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:696:27
 #8 0x00007f8d8e59c240 clang::tidy::readability::SimplifyBooleanExprCheck::Visitor::VisitCompoundStmt(clang::CompoundStmt*) /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:508:9
 #9 0x00007f8d8e56ecfd clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::WalkUpFromCompoundStmt(clang::CompoundStmt*) /home/nathan/src/llvm-project/build/Debug/tools/clang/include/clang/AST/StmtNodes.inc:73:1
#10 0x00007f8d8e56eafc clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseCompoundStmt(clang::CompoundStmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*>>>>*) /home/nathan/src/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:2385:1
#11 0x00007f8d8e56b62d clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::dataTraverseNode(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*>>>>*) /home/nathan/src/llvm-project/build/Debug/tools/clang/include/clang/AST/StmtNodes.inc:73:1
#12 0x00007f8d8e54f1d4 clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseStmt(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*>>>>*) /home/nathan/src/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:700:7
#13 0x00007f8d8e5c3ffb clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseFunctionHelper(clang::FunctionDecl*) /home/nathan/src/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:2217:5
#14 0x00007f8d8e54a6eb clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseFunctionDecl(clang::FunctionDecl*) /home/nathan/src/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:2228:1
#15 0x00007f8d8e542120 clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseDecl(clang::Decl*) /home/nathan/src/llvm-project/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:421:1
#16 0x00007f8d8e5acda8 clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseDeclContextHelper(clang::DeclContext*) /home/nathan/src/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1506:7
#17 0x00007f8d8e54ebf1 clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) /home/nathan/src/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1607:1
#18 0x00007f8d8e542655 clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseDecl(clang::Decl*) /home/nathan/src/llvm-project/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:627:1
#19 0x00007f8d8e541772 clang::RecursiveASTVisitor<clang::tidy::readability::SimplifyBooleanExprCheck::Visitor>::TraverseAST(clang::ASTContext&) /home/nathan/src/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:201:5
#20 0x00007f8d8e54153f clang::tidy::readability::SimplifyBooleanExprCheck::Visitor::traverse() /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:299:21
#21 0x00007f8d8e53f4d7 clang::tidy::readability::SimplifyBooleanExprCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:634:3
#22 0x00007f8d8de59bfe clang::tidy::ClangTidyCheck::run(clang::ast_matchers::MatchFinder::MatchResult const&) /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:46:1
#23 0x00007f8d8d9b9b48 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) /home/nathan/src/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1260:7
#24 0x00007f8d8dabf69a clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) /home/nathan/src/llvm-project/clang/lib/ASTMatchers/ASTMatchersInternal.cpp:105:5
#25 0x00007f8d8d9b9665 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) /home/nathan/src/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1056:7
#26 0x00007f8d8d9b9332 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchDispatch(clang::Decl const*) /home/nathan/src/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1075:5
#27 0x00007f8d8d9b913d void clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::match<clang::Decl>(clang::Decl const&) /home/nathan/src/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:720:3
#28 0x00007f8d8d9bc26d clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) /home/nathan/src/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1448:3
#29 0x00007f8d8d92f8f2 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseAST(clang::ASTContext&) /home/nathan/src/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:201:5
#30 0x00007f8d8d92f74c clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) /home/nathan/src/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1678:11
#31 0x00007f8d8d9bbc42 clang::ast_matchers::internal::(anonymous namespace)::MatchASTConsumer::HandleTranslationUnit(clang::ASTContext&) /home/nathan/src/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1541:3
#32 0x00007f8d882c1353 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) /home/nathan/src/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp:297:23
#33 0x00007f8d82a88a41 clang::ParseAST(clang::Sema&, bool, bool) /home/nathan/src/llvm-project/clang/lib/Parse/ParseAST.cpp:182:12
#34 0x00007f8d88284d1c clang::ASTFrontendAction::ExecuteAction() /home/nathan/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1141:1
#35 0x00007f8d8828471c clang::FrontendAction::Execute() /home/nathan/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1036:7
#36 0x00007f8d8819d1ac clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/nathan/src/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1036:23
#37 0x00007f8d8dcff2a3 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/nathan/src/llvm-project/clang/lib/Tooling/Tooling.cpp:423:14
#38 0x00007f8d8ddfd8d9 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*) /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:562:37
#39 0x00007f8d8dcff141 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) /home/nathan/src/llvm-project/clang/lib/Tooling/Tooling.cpp:398:18
#40 0x00007f8d8dcfe534 clang::tooling::ToolInvocation::run() /home/nathan/src/llvm-project/clang/lib/Tooling/Tooling.cpp:383:3
#41 0x00007f8d8dd0049f clang::tooling::ClangTool::run(clang::tooling::ToolAction*) /home/nathan/src/llvm-project/clang/lib/Tooling/Tooling.cpp:577:11
#42 0x00007f8d8ddfb92c 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) /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:583:8
#43 0x00007f8d91237562 clang::tidy::clangTidyMain(int, char const**) /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:500:7
#44 0x000055d4c6e27d82 main /home/nathan/src/llvm-project/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp:20:3
#45 0x00007f8d8b2f5083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#46 0x000055d4c6e27c9e _start (/home/nathan/src/llvm-project/build/Debug/bin/clang-tidy+0x1c9e)
[1]    1698402 segmentation fault (core dumped)  /home/nathan/src/llvm-project/build/Debug/bin/clang-tidy test.cpp  --

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztW0tz4jgQ_jXk4oKy5fchh4QkNama2U1NMrtHStgyaMfYlCRnw_767ZZtbBmSSTIQ5jAUBdbDUvenr1vveZluzh-WzMrKPC__5cXCSsqUWQmtJJNWktNiMVY83ViqtBJB5dJKK4YBJTaYG54EU5UoLGrNyzK3OD49ljy1sqpIFC-LkX01si9GgV1_k_W6jtGZ5lSMSKTfnJZFOiKxNQov6wyWxTMLUpuENtJqa1SiYiN3m7mJzWguu-hReDWof2_w7vP1xf21Jav5iitUpVpAeetSKNRwqdRajtyLEbmB74KrZTWfJOUKAnn-2P6N16L8hyUKglzKikl4sGiRAiRJXgGoCnCuMZzT5LsSNGGTuvp7BRGA7GqNtegoG5LiO1EuBF1ZVCyqFSsUCgGI3CzLFYO_gqolLeBBimRXiHnFc8Dt5oqBNhjmmLXfpEyqCTSHNU6WLPkOhV-NRwS0nApGUzrnOVebseSrdc6zzRgbidFizJ7WwhqPazEdFHPkTlmZjdxra02FZMKiymKgeJlZGc9ZnZNgzov7hy9UQXUCNQH1EiYl8mhEwh9WCnksuqC8kGoLE5T5IGghc4pU-1ZwdcWS3NI4uVP48uKR5kA0mZcJSIhf_eIfJfC1AiEL4LtsODQirm3ZTzZ8wixKo3kSuH5MLd3KUKV7ITeyfrgTvFC63R6wIYGmXSZB_52VUoFCwI0A8AQKKE3tVzZdyyo-h9_7ao1EhCdQ7wkj-KIAkk-AV1CZH_jw6zidCs5QhdCbWwN56zI-AT1zhhaIxqjb_jhCBi5BITsZyUBGJ82CfTB_rQpDVDCq6ABCttKhMwK5bBeB7KRzhwiywLeGkB2xTT07NOHyegLFDgl8j9jWbCbAgkvBZuCmNC5N6U9RMAu8cc6L6mm8KKo6Ya2WaGITWU7sEbm0nxwPSukcK1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