llvm / llvm/llvm-project

[analyzer] Support C++26 structured-binding packs

Open
#182,346 17 comments 0 reactions 0 assignees View on GitHub
c++26 clang:static analyzer crash
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Issue is occuring when analyzing file using compilation database. But without it clang-tidy only complains about missing include files.

`clang-tidy --config-file=../../.clang-tidy -p ../../build/Desktop_clang-Debug party_in_quest_location2.cpp`

```
Stack dump:
0. Program arguments: clang-tidy --config-file=../../.clang-tidy -p ../../build/Desktop_clang-Debug party_in_quest_location2.cpp
1. parser at end of file
2. While analyzing stack:
#0 Calling boost::pfr::detail::for_each_field_impl(const struct CDS::Attributes &, class (lambda at /home/uni/projects/craftsdwarfship/systems/heroes-ai/party_in_quest_location2.cpp:144:43) &&, std::index_sequence<0UL, 1UL, 2UL, 3UL>, struct std::is_rvalue_reference) at line /home/uni/projects/craftsdwarfship/build/Desktop_clang-Debug/vcpkg_installed/x64-linux/include/boost/pfr/detail/for_each_field.hpp:30:9
#1 Calling boost::pfr::detail::for_each_field(const struct CDS::Attributes &, class (lambda at /home/uni/projects/craftsdwarfship/systems/heroes-ai/party_in_quest_location2.cpp:144:43) &&) at line /home/uni/projects/craftsdwarfship/build/Desktop_clang-Debug/vcpkg_installed/x64-linux/include/boost/pfr/core.hpp:258:12
#2 Calling boost::pfr::for_each_field(const struct CDS::Attributes &, class (lambda at /home/uni/projects/craftsdwarfship/systems/heroes-ai/party_in_quest_location2.cpp:144:43) &&) at line 144
#3 Calling CDS::(anonymous namespace)::rewardFight(entt::registry &, const GameState &, SystemContext &, std::span, const CombatSimulationState &)::(anonymous class)::operator()(const entt::entity &) at line /usr/bin/../lib64/gcc/x86_64-suse-linux/15/../../../../include/c++/15/bits/invoke.h:63:14
#4 Calling std::__invoke_impl(__invoke_other, class (lambda at /home/uni/projects/craftsdwarfship/systems/heroes-ai/party_in_quest_location2.cpp:142:31) &, const enum entt::entity &) at line /usr/bin/../lib64/gcc/x86_64-suse-linux/15/../../../../include/c++/15/bits/invoke.h:98:14
#5 Calling std::__invoke(class (lambda at /home/uni/projects/craftsdwarfship/systems/heroes-ai/party_in_quest_location2.cpp:142:31) &, const enum entt::entity &) at line /usr/bin/../lib64/gcc/x86_64-suse-linux/15/../../../../include/c++/15/bits/ranges_algo.h:190:4
#6 Calling std::ranges::__for_each_fn::operator()(class __gnu_cxx::__normal_iterator >, class __gnu_cxx::__normal_iterator >, class (lambda at /home/uni/projects/craftsdwarfship/systems/heroes-ai/party_in_quest_location2.cpp:142:31), struct std::identity) at line /usr/bin/../lib64/gcc/x86_64-suse-linux/15/../../../../include/c++/15/bits/ranges_algo.h:200:9
#7 Calling std::ranges::__for_each_fn::operator()(const class std::vector &, class (lambda at /home/uni/projects/craftsdwarfship/systems/heroes-ai/party_in_quest_location2.cpp:142:31), struct std::identity) at line 146
#8 Calling CDS::(anonymous namespace)::rewardFight(entt::registry &, const GameState &, SystemContext &, std::span, const CombatSimulationState &)
3. /home/uni/projects/craftsdwarfship/build/Desktop_clang-Debug/vcpkg_installed/x64-linux/include/boost/pfr/detail/for_each_field_impl.hpp:47:18: Error evaluating statement
4. /home/uni/projects/craftsdwarfship/build/Desktop_clang-Debug/vcpkg_installed/x64-linux/include/boost/pfr/detail/for_each_field_impl.hpp:47:18: Error evaluating statement
#0 0x00007fead48fef39 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM.so.21.1+0x6fef39)
#1 0x00007fead48fbe13 llvm::sys::RunSignalHandlers() (/lib64/libLLVM.so.21.1+0x6fbe13)
#2 0x00007fead48ff718 (/lib64/libLLVM.so.21.1+0x6ff718)
#3 0x00007fead3a42910 __restore_rt (/lib64/libc.so.6+0x42910)
#4 0x00007feadedd758e clang::ento::ExprEngine::VisitCommonDeclRefExpr(clang::Expr const*, clang::NamedDecl const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/lib64/libclang-cpp.so.21.1+0x29d758e)
#5 0x00007feadedd0d2a clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/lib64/libclang-cpp.so.21.1+0x29d0d2a)
#6 0x00007feadedcdb69 clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) (/lib64/libclang-cpp.so.21.1+0x29cdb69)
#7 0x00007feadedaf086 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) (/lib64/libclang-cpp.so.21.1+0x29af086)
#8 0x00007feadedae93e clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr) (/lib64/libclang-cpp.so.21.1+0x29ae93e)
#9 0x00007feadf0f6fc0 (/lib64/libclang-cpp.so.21.1+0x2cf6fc0)
#10 0x00007feadf0f5331 (/lib64/libclang-cpp.so.21.1+0x2cf5331)
#11 0x00007feadeabbfec clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/lib64/libclang-cpp.so.21.1+0x26bbfec)
#12 0x00007feadcac5fd9 clang::ParseAST(clang::Sema&, bool, bool) (/lib64/libclang-cpp.so.21.1+0x6c5fd9)
#13 0x00007feadea785fd clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.21.1+0x26785fd)
#14 0x00007feade9bd22e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib64/libclang-cpp.so.21.1+0x25bd22e)
#15 0x00007feadecbc0fe clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr, clang::FileManager*, std::shared_ptr, clang::DiagnosticConsumer*) (/lib64/libclang-cpp.so.21.1+0x28bc0fe)
#16 0x000056167c5b835c (/usr/bin/clang-tidy-21+0x74935c)
#17 0x00007feadecbbd9d clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr, std::shared_ptr) (/lib64/libclang-cpp.so.21.1+0x28bbd9d)
#18 0x00007feadecba9dc clang::tooling::ToolInvocation::run() (/lib64/libclang-cpp.so.21.1+0x28ba9dc)
#19 0x00007feadecbdf32 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/lib64/libclang-cpp.so.21.1+0x28bdf32)
#20 0x000056167c5b3c36 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef, std::allocator>>, llvm::IntrusiveRefCntPtr, bool, bool, llvm::StringRef) (/usr/bin/clang-tidy-21+0x744c36)
#21 0x000056167bf3d3de clang::tidy::clangTidyMain(int, char const**) (/usr/bin/clang-tidy-21+0xce3de)
#22 0x00007fead3a2b2fb __libc_start_call_main (/lib64/libc.so.6+0x2b2fb)
#23 0x00007fead3a2b3cb __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2b3cb)
#24 0x000056167bf39dc5 _start (/usr/bin/clang-tidy-21+0xcadc5)
/home/uni/projects/craftsdwarfship/systems/heroes-ai/party_in_quest_location2.cpp: terminated by signal 11
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the provided clang-tidy command and compilation database, using party_in_quest_location2.cpp. Start from the stack trace in boost/pfr/detail/for_each_field_impl.hpp and the analyzer path reported in the trace. Done means clang-tidy handles C++26 structured-binding packs without terminating by signal 11.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.