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

    <tr>
        <th>Summary</th>
        <td>
            [Clang-tidy] Crash when using tbb::block_ranged
        </td>
    </tr>

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

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

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

<pre>
    clang-tidy version:
$ clang-tidy --version
LLVM (http://llvm.org/):
  LLVM version 17.0.5
  Optimized build.

clang-tidy command:
`clang-tidy b.cpp --checks=modernize-loop-convert`

Description:
clang-tidy will crash in the following code.
You can install the latest version tbb by https://github.com/oneapi-src/oneTBB.
and add -I<oneTBB>/include in the include path.
```
#include "tbb/blocked_range.h"
int main()
{
    tbb::blocked_range<int> r {0,100};
    for(auto i = r.begin(); i!=r.end(); ++i) {
        // ...
    }
    return 0;
}
```

Crash stack:
```
$ clang-tidy foo.cpp --checks=modernize-loop-convert
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 foo.cpp --checks=modernize-loop-convert
1.      <eof> parser at end of file
2. ASTMatcher: Processing 'modernize-loop-convert' against:
 ForStmt : <foo.cpp:5:5, line:7:5>
--- Bound Nodes Begin ---
 beginCall - { CXXMemberCallExpr : <foo.cpp:5:18, col:26> }
    endCall - { CXXMemberCallExpr : <foo.cpp:5:32, col:38> }
    forLoopIterator - { ForStmt : <foo.cpp:5:5, line:7:5> }
    initVar - { VarDecl i : <foo.cpp:5:9, col:26> }
--- Bound Nodes End ---
 #0 0x00007f71adb259a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (clang/dev/bin/../lib/libLLVMSupport.so.18git+0x1c39a7)
 #1 0x00007f71adb2375e llvm::sys::RunSignalHandlers() (clang/dev/bin/../lib/libLLVMSupport.so.18git+0x1c175e)
 #2 0x00007f71adb2608f SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f71afb8b730 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12730)
 #4 0x00007f71aefd1b1b clang::tidy::modernize::LoopConvertCheck::getIteratorLoopQualifiers(clang::ASTContext*, clang::ast_matchers::BoundNodes const&, clang::tidy::modernize::LoopConvertCheck::RangeDescriptor&) (clang/dev/bin/../lib/libclangTidyModernizeModule.so.18git+0x175b1b)
 #5 0x00007f71aefd1d01 clang::tidy::modernize::LoopConvertCheck::determineRangeDescriptor(clang::ASTContext*, clang::ast_matchers::BoundNodes const&, clang::ForStmt const*, clang::tidy::modernize::LoopFixerKind, clang::Expr const*, llvm::SmallVector<clang::tidy::modernize::Usage, 8u> const&, clang::tidy::modernize::LoopConvertCheck::RangeDescriptor&) (clang/dev/bin/../lib/libclangTidyModernizeModule.so.18git+0x175d01)
 #6 0x00007f71aefd2530 clang::tidy::modernize::LoopConvertCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (clang/dev/bin/../lib/libclangTidyModernizeModule.so.18git+0x176530)
 #7 0x00007f71aeafef90 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
 #8 0x00007f71aeb2c83c clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (clang/dev/bin/../lib/libclangASTMatchers.so.18git+0x8483c)
 #9 0x00007f71aeafe9ea clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
#10 0x00007f71aeb10c35 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseCompoundStmt(clang::CompoundStmt*, 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
#11 0x00007f71aeb0e5c6 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
#12 0x00007f71aeb2c28f clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionHelper(clang::FunctionDecl*) ASTMatchFinder.cpp:0:0
#13 0x00007f71aeb07092 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionDecl(clang::FunctionDecl*) ASTMatchFinder.cpp:0:0
#14 0x00007f71aeb019b5 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#15 0x00007f71aeb0988b clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp:0:0
#16 0x00007f71aeb01c8b clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#17 0x00007f71aead37aa clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (clang/dev/bin/../lib/libclangASTMatchers.so.18git+0x2b7aa)
#18 0x00007f71abfa31dc clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (clang/dev/bin/../lib/../lib/libclangFrontend.so.18git+0x1ab1dc)
#19 0x00007f71a9daaec4 clang::ParseAST(clang::Sema&, bool, bool) (clang/dev/bin/../lib/../lib/../lib/libclangParse.so.18git+0x4dec4)
#20 0x00007f71abf65ea9 clang::FrontendAction::Execute() (clang/dev/bin/../lib/../lib/libclangFrontend.so.18git+0x16dea9)
#21 0x00007f71abed7ae6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (clang/dev/bin/../lib/../lib/libclangFrontend.so.18git+0xdfae6)
#22 0x00007f71aeb8bdeb clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (clang/dev/bin/../lib/libclangTooling.so.18git+0x3bdeb)
#23 0x00007f71aebbb532 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
#24 0x00007f71aeb8bb71 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (clang/dev/bin/../lib/libclangTooling.so.18git+0x3bb71)
#25 0x00007f71aeb8a935 clang::tooling::ToolInvocation::run() (clang/dev/bin/../lib/libclangTooling.so.18git+0x3a935)
#26 0x00007f71aeb8d5ba clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (clang/dev/bin/../lib/libclangTooling.so.18git+0x3d5ba)
#27 0x00007f71aebb6092 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) (clang/dev/bin/../lib/libclangTidy.so.18git+0x21092)
#28 0x00007f71afb711d6 clang::tidy::clangTidyMain(int, char const**) (clang/dev/bin/../lib/libclangTidyMain.so.18git+0xd1d6)
#29 0x00007f71ad05109b __libc_start_main /build/glibc-6iIyft/glibc-2.28/csu/../csu/libc-start.c:342:3
#30 0x00005560ad0c2d4a _start (clang/dev/bin/clang-tidy+0x1d4a)
Segmentation fault

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl9z4ygS_zTkhbJLQpYlPeTBsePa1E1uc5Ps3N6TC0Hb5kYCF6BMsp_-Cv2zUJyZeCdTN3e1qcSx-NP0r_tH0yCoMWInAS5RfIXi1QWt7F7py0LIHewgIhe54s-XrKByN7GCP-NH0EYoiaIFClYoWCAyw4PqyaRrUNd--PDpFiOS7q09uC5kjci6KB7LqdK7-inrJWFct2774zCZBtO4q_r1YEUp_gCO80oUfNoOXn8OhmeqLKnkR-3mwaA2n7LDAU8mbA_ss0HRqlQctBR_wKRQ6jBhSj6CtmgeDMWvwDAtDnaIeiD0iygKzDQ1eywktnvAW1UU6ouQO8wUh1bVf6kKMyqxkMbSoqgbFtSCsT1im-c4f8bOVqY31k7YfZVPmSoRWSsJ9CAmRrPm4eHqqhVPJceUczy5QdGyqUHRNSJrIVlRceh06x4P1O6nvY3a39ahUdcIEWLzHJF1Xij2GfhGU7mD6R4R0rQV0uKSColI6jzZ9E-uOqdhB8khiRaeBBQthbQousYao-QqQGQZBgFKViga9N0qjUhKK6uwwChaYT3NYdcPFl1hgUiIopWeguTHUkSuELkSiGTY08X9NDbF0-n0WO7G7R802EpLHPSa9LVjM9Wfy9rvxlL2ecg5357eBNkq9UYW1r3vPlwv7q-xqfJSWExxXu2whoPSFlv1Naq4Sdb-mxy0-jcw69hgTAXGmcARpvOzI0bD4Jyyz1ZT1rH23iHDvCoPPbxg2pjyTqudpiWmeleVIK3T4zuAhq1YFC1BbR03DlQb0Jha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