[clangd][clang]didOpen-only assertion ` !isTemplateImplicitInstantiation(D)`
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
It's reduced from https://github.com/llvm/llvm-project/blob/main/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp
```cxx
template < typename T > auto f() {
return [](auto x) {
using A = T::U< decltype(x) >;
struct S : A {
using typename A::type;
type f
}return S()}}
struct X {
template < typename > struct U {
using type = int;
int test() {
auto s = f< X >()(0);
s.f
```
backtrace
```
llvm::ArrayRef, const clang::Expr*, const clang::Decl*, const clang::DeclContext*): Assertion `!
isTemplateImplicitInstantiation(D)' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reprod
uce the bug.
#0 0x00006518529288f2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /llvm/lib/Support/Unix/Signals.inc:884:3
#1 0x000065185292566c llvm::sys::RunSignalHandlers() /llvm/lib/Support/Signals.cpp:108:20
#2 0x0000651852925ee1 SignalHandler(int, siginfo_t*, void*) /llvm/lib/Support/Unix/Signals.inc:448:14
#3 0x0000738e6c845330 (+0x45330)
#4 0x0000738e6c89eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x0000738e6c89eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x0000738e6c89eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x0000738e6c84527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x0000738e6c8288ff abort ./stdlib/abort.c:81:7
#9 0x0000738e6c82881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x0000738e6c83b517 (+0x3b517)
#11 0x00006518541fbfc2 llvm::isa_impl_cl::doit(clang::Decl const*) /llvm/include/
llvm/Support/Casting.h:109:5
#12 0x00006518541fbfc2 llvm::isa_impl_cl::doit(clang::Decl const*) /llvm/include/
llvm/Support/Casting.h:108:22
#13 0x00006518541fbfc2 llvm::isa_impl_wrap::doit(clang::Decl const*
const&) /llvm/include/llvm/Support/Casting.h:137:41
#14 0x00006518541fbfc2 llvm::isa_impl_wrap::doit(clang::Decl const*
const&) /llvm/include/llvm/Support/Casting.h:129:13
#15 0x00006518541fbfc2 llvm::CastIsPossible::isPossible(clang::Decl const* const&)
/llvm/include/llvm/Support/Casting.h:257:62
#16 0x00006518541fbfc2 llvm::CastInfo::isPossible(clang::Decl const* const&)
/llvm/include/llvm/Support/Casting.h:509:38
#17 0x00006518541fbfc2 bool llvm::isa(clang::Decl const* const&) /llvm/include/llvm/
Support/Casting.h:548:47
#18 0x00006518541fbfc2 clang::index::IndexingContext::handleDeclOccurrence(clang::Decl const*, clang::SourceLocation, bool,
clang::Decl const*, unsigned int, llvm::ArrayRef, clang::Expr const*, clang::Decl const*,
clang::DeclContext const*) /clang/lib/Index/IndexingContext.cpp:442:36
#19 0x00006518541fc2da clang::index::IndexingContext::handleReference(clang::NamedDecl const*, clang::SourceLocation, clang::NamedDecl
const*, clang::DeclContext const*, unsigned int, llvm::ArrayRef, clang::Expr const*) /clang/
lib/Index/IndexingContext.cpp:101:48
#20 0x000065185422e018 llvm::SmallVectorTemplateCommon::isSmall() const /llvm/include/
llvm/ADT/SmallVector.h:148:39
#21 0x000065185422e018 llvm::SmallVectorImpl::~SmallVectorImpl() /llvm/include/llvm/ADT/
SmallVector.h:609:23
#22 0x000065185422e018 llvm::SmallVector::~SmallVector() /llvm/include/llvm/ADT/
SmallVector.h:1230:3
#23 0x000065185422e018 VisitMemberExpr /clang/lib/Index/IndexBody.cpp:184:3
#24 0x000065185422e018 WalkUpFromMemberExpr /tools/clang/include/clang/AST/StmtNodes.inc:318:1
#25 0x000065185422e018 clang::RecursiveASTVisitor<(anonymous namespace)::BodyIndexer>::TraverseMemberExpr(clang::MemberExpr*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo>>>*) /clang/include/clang/AST/
RecursiveASTVisitor.h:2653:1
#26 0x0000651854226a7d llvm::SmallVectorTemplateCommon, llvm::PointerIntPairInfo>>,
void>::begin() /llvm/include/llvm/ADT/SmallVector.h:276:45
#27 0x0000651854226a7d llvm::SmallVectorTemplateCommon, llvm::PointerIntPairInfo>>,
void>::end() /llvm/include/llvm/ADT/SmallVector.h:278:32
#28 0x0000651854226a7d clang::RecursiveASTVisitor<(anonymous namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo>>>*) /clang/include/clang/AST/
RecursiveASTVisitor.h:707:19
#29 0x0000651854226bd7 llvm::SmallVectorTemplateCommon::isSmall() const /llvm/include/llvm/ADT/
SmallVector.h:148:39
#30 0x0000651854226bd7 llvm::SmallVectorImpl::~SmallVectorImpl() /llvm/include/llvm/ADT/SmallVector.h:609:23
#31 0x0000651854226bd7 llvm::SmallVector::~SmallVector() /llvm/include/llvm/ADT/SmallVector.h:1230:3
#32 0x0000651854226bd7 ~BodyIndexer /clang/lib/Index/IndexBody.cpp:23:7
#33 0x0000651854226bd7 clang::index::IndexingContext::indexBody(clang::Stmt const*, clang::NamedDecl const*, clang::DeclContext
const*) /clang/lib/Index/IndexBody.cpp:524:3
#34 0x00006518541fee80 (anonymous namespace)::IndexingDeclVisitor::VisitFunctionDecl(clang::FunctionDecl const*) /clang/lib/
Index/IndexDecl.cpp:299:27
#35 0x0000651854201a6b clang::index::IndexingContext::indexDecl(clang::Decl const*) /clang/lib/Index/IndexDecl.cpp:789:3
#36 0x0000651854201c0c clang::index::IndexingContext::indexDeclContext(clang::DeclContext const*) /clang/lib/Index/
IndexDecl.cpp:800:5
#37 0x00006518542004a0 llvm::SmallVectorTemplateCommon::isSmall() const /llvm/include/
llvm/ADT/SmallVector.h:148:39
#38 0x00006518542004a0 llvm::SmallVectorImpl::~SmallVectorImpl() /llvm/include/llvm/ADT/
SmallVector.h:609:23
#39 0x00006518542004a0 llvm::SmallVector::~SmallVector() /llvm/include/llvm/ADT/
SmallVector.h:1230:3
#40 0x00006518542004a0 VisitTagDecl /clang/lib/Index/IndexDecl.cpp:371:7
#41 0x00006518542004a0 VisitRecordDecl /tools/clang/include/clang/AST/DeclNodes.inc:428:1
#42 0x00006518542004a0 VisitCXXRecordDecl /tools/clang/include/clang/AST/DeclNodes.inc:432:1
#43 0x00006518542004a0 clang::declvisitor::Base::Visit(clang::Decl const*) /tools/clang/include/clang/AST/DeclNodes.inc:432:1
#44 0x0000651854201a6b clang::index::IndexingContext::indexDecl(clang::Decl const*) /clang/lib/Index/IndexDecl.cpp:789:3
#45 0x0000651854201c0c clang::index::IndexingContext::indexDeclContext(clang::DeclContext const*) /clang/lib/Index/
IndexDecl.cpp:800:5
#46 0x00006518542004a0 llvm::SmallVectorTemplateCommon::isSmall() const /llvm/include/
llvm/ADT/SmallVector.h:148:39
#47 0x00006518542004a0 llvm::SmallVectorImpl::~SmallVectorImpl() /llvm/include/llvm/ADT/
SmallVector.h:609:23
#48 0x00006518542004a0 llvm::SmallVector::~SmallVector() /llvm/include/llvm/ADT/
SmallVector.h:1230:3
#49 0x00006518542004a0 VisitTagDecl /clang/lib/Index/IndexDecl.cpp:371:7
#50 0x00006518542004a0 VisitRecordDecl /tools/clang/include/clang/AST/DeclNodes.inc:428:1
#51 0x00006518542004a0 VisitCXXRecordDecl /tools/clang/include/clang/AST/DeclNodes.inc:432:1
#52 0x00006518542004a0 clang::declvisitor::Base::Visit(clang::Decl const*) /tools/clang/include/clang/AST/DeclNodes.inc:432:1
#53 0x0000651854201a6b clang::index::IndexingContext::indexDecl(clang::Decl const*) /clang/lib/Index/IndexDecl.cpp:789:3
#54 0x00006518541f9907 clang::index::indexTopLevelDecls(clang::ASTContext&, clang::Preprocessor&, llvm::ArrayRef,
clang::index::IndexDataConsumer&, clang::index::IndexingOptions) /clang/lib/Index/IndexingAction.cpp:294:24
#55 0x000065185416c9a2 std::_Function_base::~_Function_base() /bits/std_function.h:243:11
#56 0x000065185416c9a2 std::function::~function() /bits/std_function.h:334:11
#57 0x000065185416c9a2 clang::index::IndexingOptions::~IndexingOptions() /clang/include/clang/Index/IndexingOptions.h:20:8
#58 0x000065185416c9a2 clang::clangd::(anonymous namespace)::indexSymbols(clang::ASTContext&, clang::Preprocessor&,
llvm::ArrayRef, clang::clangd::MainFileMacros const*, clang::include_cleaner::PragmaIncludes const&, bool,
llvm::StringRef, bool, clang::clangd::SymbolOrigin) /clang-tools-extra/clangd/index/FileIndex.cpp:82:28
#59 0x000065185416d406 clang::clangd::indexMainDecls(clang::clangd::ParsedAST&) /clang-tools-extra/clangd/index/
FileIndex.cpp:228:71
#60 0x000065185416d481 clang::clangd::FileIndex::updateMain(llvm::StringRef, clang::clangd::ParsedAST&) /clang-tools-extra/
clangd/index/FileIndex.cpp:473:25
#61 0x0000651853db9891 clang::clangd::(anonymous namespace)::UpdateIndexCallbacks::onMainAST(llvm::StringRef,
clang::clangd::ParsedAST&, llvm::function_ref)>) /clang-tools-extra/clangd/
ClangdServer.cpp:139:5
#62 0x0000651854017b62 clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics(std::unique_ptr>, clang::clangd::ParseInputs, std::vector>) /clang-tools-extra/clangd/TUScheduler.cpp:1251:24
#63 0x0000651854017f50 std::unique_ptr>::~unique_ptr()
/bits/unique_ptr.h:403:12
#64 0x0000651854017f50 clang::clangd::(anonymous namespace)::ASTWorker::updatePreamble(std::unique_ptr>, clang::clangd::ParseInputs, std::shared_ptr,
std::vector>, clang::clangd::WantDiagnostics)::'lambda'()::operator()()
(.part.0) /clang-tools-extra/clangd/TUScheduler.cpp:1147:24
#65 0x000065185400c2aa clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref)
/clang-tools-extra/clangd/TUScheduler.cpp:1328:1
#66 0x000065185400f9fa clang::clangd::(anonymous namespace)::ASTWorker::run() /clang-tools-extra/clangd/
TUScheduler.cpp:1462:5
#67 0x00006518541f2b6e llvm::detail::UniqueFunctionBase::operator=(llvm::detail::UniqueFunctionBase&&) /llvm/
include/llvm/ADT/FunctionExtras.h:329:5
#68 0x00006518541f2b6e llvm::detail::UniqueFunctionBase::operator=(llvm::detail::UniqueFunctionBase&&) /llvm/
include/llvm/ADT/FunctionExtras.h:321:23
#69 0x00006518541f2b6e llvm::unique_function::operator=(llvm::unique_function&&) /llvm/include/llvm/ADT/
FunctionExtras.h:352:20
#70 0x00006518541f2b6e operator() /clang-tools-extra/clangd/support/Threading.cpp:103:14
#71 0x00006518541f2b6e operator())::&> /llvm/include/llvm/Support/thread.h:46:16
#72 0x00006518541f2b6e __invoke_impl):: > >(void*)::,
clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function)::&> /bits/
invoke.h:61:36
#73 0x00006518541f2b6e __invoke):: > >(void*)::,
clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function)::&> /bits/
invoke.h:96:40
#74 0x00006518541f2b6e __apply_impl):: > >(void*)::,
std::tuple):: >&, 0>
/tuple:2302:27
#75 0x00006518541f2b6e apply):: > >(void*)::,
std::tuple):: >&>
/tuple:2313:31
#76 0x00006518541f2b6e GenericThreadProxy):: > > /llvm/include/llvm/Support/thread.h:44:15
#77 0x00006518541f2b6e void* llvm::thread::ThreadProxy)::'lambda0'()>>(void*) /llvm/include/llvm/Support/thread.h:62:36
#78 0x0000738e6c89caa4 start_thread ./nptl/pthread_create.c:447:8
#79 0x0000738e6c929c6c clone3 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80:0
Signalled during AST worker action: Build AST
Filename: /p8-cxx0x.cpp
Directory:
Command Line: /usr/lib/llvm-18/bin/clang++ --driver-mode=g++ -std=c++26 -fsyntax-only -resource-dir=/lib/clang/23 --
/p8-cxx0x.cpp
Version: 1
Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
/run_clangd_didopen_workspace.sh: line 91: 33 Exit 120 { emit_lsp "$INIT"; emit_lsp "$INITIALIZED";
emit_lsp "$DIDOPEN"; sleep "$DIDOPEN_WAIT_SECS"; emit_lsp "$SHUTDOWN"; emit_lsp "$EXIT"; }
34 Aborted (core dumped) | ( cd "$WORKDIR"; "$TARGET" "${TARGET_ARGS[@]}" )
```
Contributor guide
Assessment
This issue has not been assessed yet.