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

    <tr>
        <th>Summary</th>
        <td>
            Crash in modernize-use-ranges check
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          matthew-f
      </td>
    </tr>
</table>

<pre>
    The modernize-use-ranges check is crashing. This is the backtrace:
```
1.      <eof> parser at end of file
2.      ASTMatcher: Processing 'modernize-use-ranges' against:
        CallExpr : </home/catdev/cathexis/source/trunk/500_tmp/enterprise/cloud/servers/user/logins.cpp:241:4, line:243:31>
--- Bound Nodes Begin ---
    ArgName0 - { DeclRefExpr : </home/catdev/cathexis/source/trunk/500_tmp/enterprise/cloud/servers/user/logins.cpp:241:16> }
    CallExpr0:2:0 - { CallExpr : </home/catdev/cathexis/source/trunk/500_tmp/enterprise/cloud/servers/user/logins.cpp:241:4, line:243:31> }
    FuncDecl - { FunctionDecl std::_V2::rotate : </usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algo.h:1403:5 <Spelling=/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11/bits/c++config.h:169:32>, /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algo.h:1416:5> }
--- Bound Nodes End ---
 #0 0x000059a2eef79530 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/llvm-20240723/bin/clang-tidy+0x48f6530)
 #1 0x000059a2eef76b0e SignalHandler(int) Signals.cpp:0:0
 #2 0x0000768f8a242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000059a2ebfb09bc clang::tidy::utils::UseRangesCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/usr/local/llvm-20240723/bin/clang-tidy+0x192d9bc)
 #4 0x000059a2edab7e36 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
 #5 0x000059a2edae5b8f clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/usr/local/llvm-20240723/bin/clang-tidy+0x3462b8f)
 #6 0x000059a2edab8a30 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
 #7 0x000059a2edadd4d0 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseObjCAvailabilityCheckExpr(clang::ObjCAvailabilityCheckExpr*, 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
 #8 0x000059a2edad5950 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
 #9 0x000059a2edad5adb 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
#10 0x000059a2edadf90f clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionHelper(clang::FunctionDecl*) ASTMatchFinder.cpp:0:0
#11 0x000059a2edadfb83 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseCXXMethodDecl(clang::CXXMethodDecl*) ASTMatchFinder.cpp:0:0
#12 0x000059a2edad02cf clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#13 0x000059a2edad03d9 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.0) ASTMatchFinder.cpp:0:0
#14 0x000059a2edadbad8 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp:0:0
#15 0x000059a2edad02cf clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#16 0x000059a2edad0605 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/usr/local/llvm-20240723/bin/clang-tidy+0x344d605)
#17 0x000059a2ec84a900 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/llvm-20240723/bin/clang-tidy+0x21c7900)
#18 0x000059a2ecad633c clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/llvm-20240723/bin/clang-tidy+0x245333c)
#19 0x000059a2ec80a449 clang::FrontendAction::Execute() (/usr/local/llvm-20240723/bin/clang-tidy+0x2187449)
#20 0x000059a2ec777c39 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/llvm-20240723/bin/clang-tidy+0x20f4c39)
#21 0x000059a2ec01ca04 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/local/llvm-20240723/bin/clang-tidy+0x1999a04)
#22 0x000059a2ebfbe9fe 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
#23 0x000059a2ec016035 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/usr/local/llvm-20240723/bin/clang-tidy+0x1993035)
#24 0x000059a2ec0185db clang::tooling::ToolInvocation::run() (/usr/local/llvm-20240723/bin/clang-tidy+0x19955db)
#25 0x000059a2ec01a78f clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/usr/local/llvm-20240723/bin/clang-tidy+0x199778f)
#26 0x000059a2ebfc7dea 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-20240723/bin/clang-tidy+0x1944dea)
#27 0x000059a2eb23425a clang::tidy::clangTidyMain(int, char const**) (/usr/local/llvm-20240723/bin/clang-tidy+0xbb125a)
#28 0x0000768f8a229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#29 0x0000768f8a229e40 call_init ./csu/../csu/libc-start.c:128:20
#30 0x0000768f8a229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#31 0x000059a2eb22a4d5 _start (/usr/local/llvm-20240723/bin/clang-tidy+0xba74d5)
Segmentation fault (core dumped)
```

The problem is the 'Qualified name is not found in 'Replaces'. As a hack, this fixes it:
```
auto Iter = Replaces.find(Qualified);

if (Iter == Replaces.end()) {
 return;
}
```

In the instance when it crashed, the 'Qualified' name was `::std::_V2::rotate`. The 'Replaces' map does contain '::std::rotate'

I don't know this code at all, and from the assert it looks like this is not expected, so I'm afraid I'm not submitting a proper fix.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1v4zaz_jXMDWFDoiRLusiF46zRAGfbnMTt6Z1BUSObDUUKJJVNzq8_ICXbkuJss_XZt_u-KOA4Fj-Gz8wzw-GHqDF8JwGuUXKDktsr2tq90tc1tXYPX2bVVaHK1-vNHnCtStCS_y_MWgMzTeUODGZ7YE-YG8w0NXsud3O82XPjSuwecEHZk9WUAYqWKLhFwRItgv7jH8M5CnIUrUBVKPqEG6oNaEwtBlliVeGKC-haEtdy-bj5TC3bg0bREt9rxcAYLncYkfQcPkRSTHeUS2NPCIJ8RYX49NJo7KSgaIXIeq9qQGTNqC3hufuxhxduEFkb1WrmKq1u5RMi6yQItrZuEFmDtKAbzY3vK1Rbuvagn0G7nq0BjchaqB2XZs6aBkVLEocoWsaIrLDgEnxJhKJlFKLoU4dwNpvhG9XKEv-sSjD4BnZc4tls1lVjjPFS736mNQR4hlF6g2-BiQeo_l6dwoWjEKW3J5gHQweuEYqWB7w_LAFj-OtWMmfaHrV7tFxJX2Rs6VwqWm5_I90PrSy1MFCpNX5wXiCy3jGGyPolW2wX8Uxw2b7MdrJFZB2GiKzn87dfXDLRll4vRG78p2tccOutYsWWip2a753t48DpkLiRHxsQgssdim7_H0Gc6XUeV1_KlKz4rgO3yJ19iXNwssL_ass4v1wmI3KnEfZJloP4QiQKcPASBEGQ5JQAVGmeRAEW4rnuqDavpvtxr7m0j5ayp42f5kh2aqTpl60yVgOtEVk4zbm0iOQYkexkA8WocP_Fcz0jAYmDlEReFek9msrdzPLyFZGb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