<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/108963>108963</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy: Crash with performance-unnecessary-value-param
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
VReichelt
</td>
</tr>
</table>
<pre>
Running `clang-tidy -checks="-*,performance-unnecessary-value-param"` on the following valid code
```
struct A
{
template<typename T> A(T&&) {}
};
struct B
{
~B();
};
struct C
{
A a;
C(B, int i) : a(i) {}
};
C c(B(), 0);
```
triggers an assertion
```
clang-tidy: /tmp/LLVM/llvm-project/llvm/include/llvm/ADT/DenseMap.h:1238: llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type* llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::operator->() const [with KeyT = const clang::FunctionDecl*; ValueT = std::unique_ptr<clang::FunctionParmMutationAnalyzer>; KeyInfoT = llvm::DenseMapInfo<const clang::FunctionDecl*, void>; Bucket = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >; bool IsConst = false; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::pointer = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >*; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >]: Assertion `isHandleInSync() && "invalid iterator access!"' failed.
```
This is a very recent regression on trunk. It worked fine a week ago with revision 1c334debecd7 and failed with revision f71061258484 .
Full stacktrace:
```
clang-tidy: /tmp/LLVM/llvm-project/llvm/include/llvm/ADT/DenseMap.h:1238: llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type* llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::operator->() const [with KeyT = const clang::FunctionDecl*; ValueT = std::unique_ptr<clang::FunctionParmMutationAnalyzer>; KeyInfoT = llvm::DenseMapInfo<const clang::FunctionDecl*, void>; Bucket = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >; bool IsConst = false; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::pointer = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >*; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >]: Assertion `isHandleInSync() && "invalid iterator access!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: LLVM/bin/clang-tidy -checks=-*,performance-unnecessary-value-param CTbug.cc
1. <eof> parser at end of file
2. ASTMatcher: Processing 'performance-unnecessary-value-param' against:
CXXConstructorDecl C::C : <CTbug.cc:14:3, col:23>
--- Bound Nodes Begin ---
functionDecl - { CXXConstructorDecl C::C : <CTbug.cc:14:3, col:23> }
param - { ParmVarDecl : <CTbug.cc:14:5> }
--- Bound Nodes End ---
#0 0x000000000475c248 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (LLVM/bin/clang-tidy+0x475c248)
#1 0x000000000475999c SignalHandler(int) Signals.cpp:0:0
#2 0x00007f2de91dbce0 __restore_rt (/lib64/libpthread.so.0+0x12ce0)
#3 0x00007f2de7c5aa9f raise (/lib64/libc.so.6+0x4ea9f)
#4 0x00007f2de7c2de05 abort (/lib64/libc.so.6+0x21e05)
#5 0x00007f2de7c2dcd9 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21cd9)
#6 0x00007f2de7c533f6 (/lib64/libc.so.6+0x473f6)
#7 0x00000000010b8192 clang::tidy::performance::UnnecessaryValueParamCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (LLVM/bin/clang-tidy+0x10b8192)
#8 0x00000000032bdbd9 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
#9 0x0000000003304427 clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (LLVM/bin/clang-tidy+0x3304427)
#10 0x00000000032c0174 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
#11 0x00000000032e409e clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#12 0x00000000032e4aea clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.9962) ASTMatchFinder.cpp:0:0
#13 0x00000000032f7eea clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseCXXRecordDecl(clang::CXXRecordDecl*) ASTMatchFinder.cpp:0:0
#14 0x00000000032e363d clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#15 0x00000000032e40a9 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#16 0x00000000032e4aea clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.9962) ASTMatchFinder.cpp:0:0
#17 0x00000000032f7705 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp:0:0
#18 0x00000000032e39bf clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#19 0x00000000032e40a9 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#20 0x00000000032e43a1 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (LLVM/bin/clang-tidy+0x32e43a1)
#21 0x00000000020bab18 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (LLVM/bin/clang-tidy+0x20bab18)
#22 0x0000000002319e2c clang::ParseAST(clang::Sema&, bool, bool) (LLVM/bin/clang-tidy+0x2319e2c)
#23 0x0000000002084ab9 clang::FrontendAction::Execute() (LLVM/bin/clang-tidy+0x2084ab9)
#24 0x000000000200bf29 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (LLVM/bin/clang-tidy+0x200bf29)
#25 0x00000000018bc0b9 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (LLVM/bin/clang-tidy+0x18bc0b9)
#26 0x000000000186915e 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
#27 0x00000000018b6e5b clang::tooling::ToolInvocation::run() (LLVM/bin/clang-tidy+0x18b6e5b)
#28 0x00000000018b996d clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (LLVM/bin/clang-tidy+0x18b996d)
#29 0x00000000018755a9 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) (LLVM/bin/clang-tidy+0x18755a9)
#30 0x0000000000aefca2 clang::tidy::clangTidyMain(int, char const**) (LLVM/bin/clang-tidy+0xaefca2)
#31 0x00007f2de7c46cf3 __libc_start_main (/lib64/libc.so.6+0x3acf3)
#32 0x0000000000ae595e _start (LLVM/bin/clang-tidy+0xae595e)
bin/TidyTest: line 1: 4173665 Aborted (core dumped) LLVM/bin/clang-tidy -checks="-*,performance-unnecessary-value-param" $1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z4jjW_jXOjQrKlr8vcgEm1KRm8k4qYfrtO0qWj0HbQmIlOR32Yn_7lmQDNuSD2Z7U9m6lK50YWX7Ocz6lI0O0ZisBcO3FUy-eXZHGrKW6_vIAjK6Bm6tSVrvrh0YIJlbIS3zKiViNDKt2aETXQL9pL5x5GI88PPFwsQVVS7UhgsKoEQIoaE3UbvREeAOjLVFk42HsJT6SApk1oFpyLr9b8CfCWYWorMDzZ54_6X4nfvfjPmqjGmrQ_mY6bS8QMrDZcmLACwuz24IgG0ALL7xBEw9nCw8n7idH9pF0tn985oXTvrQOfnoG_8-phzMP58f5rz1bnD07QeQwFaHCw9nUwwViwiDmKIV2Bs7Y-_wKRNvHHRdcIH_AaWir9rdRbLUCpRERiGgNyjAp3rDw0cGWl4fnZrP18Py3377ceXjO-dNmtFXyb0BN99HDcyYobyo4DkxmCw_PZyA03JHteO2FkwCHmUV0M8KJF072t28NKGKk8sLiV9gtrFpfbLi4q19hdytq6a6nDf0Gxl7d6kIKbbzwpoVy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