[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)
Dmitry Polukhin via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 21 12:56:46 PDT 2024
dmpolukhin wrote:
> And I am still slightly unclear about how we load the wrong lambda first.
Here is stack trace how decl from wrong module becomes canonical.
<details>
<summary>Full stack trace</summary>
```
frame #0: 0x000055555e651e29 clang`clang::ASTDeclReader::VisitCXXRecordDeclImpl(this=0x00007ffffffe0b70, D=0x0000555564f74508) at ASTReaderDecl.cpp:2244:17
frame #1: 0x000055555e699ff1 clang`clang::ASTDeclReader::VisitCXXRecordDecl(this=0x00007ffffffe0b70, D=0x0000555564f74508) at ASTReaderDecl.cpp:346:49
frame #2: 0x000055555e67c3c1 clang`clang::declvisitor::Base<std::add_pointer, clang::ASTDeclReader, void>::Visit(this=0x00007ffffffe0b70, D=0x0000555564f74508) at DeclNodes.inc:414:1
frame #3: 0x000055555e6466d4 clang`clang::ASTDeclReader::Visit(this=0x00007ffffffe0b70, D=0x0000555564f74508) at ASTReaderDecl.cpp:542:37
frame #4: 0x000055555e67b76f clang`clang::ASTReader::ReadDeclRecord(clang::GlobalDeclID)::$_2::operator()(this=0x00007ffffffe0720) const at ASTReaderDecl.cpp:4154:51
frame #5: 0x000055555e67b745 clang`void llvm::function_ref<void ()>::callback_fn<clang::ASTReader::ReadDeclRecord(clang::GlobalDeclID)::$_2>(callable=140737488226080) at STLFunctionalExtras.h:45:12
frame #6: 0x000055555b9904a9 clang`llvm::function_ref<void ()>::operator()(this=0x00007ffffffe05e0) const at STLFunctionalExtras.h:68:12
frame #7: 0x000055555e68ad7d clang`clang::runWithSufficientStackSpace(Diag=function_ref<void ()> @ 0x00007ffffffe05f0, Fn=function_ref<void ()> @ 0x00007ffffffe05e0) at Stack.h:46:7
frame #8: 0x000055555e67841e clang`clang::ASTReader::ReadDeclRecord(this=0x0000555564ee3040, ID=GlobalDeclID @ 0x00007ffffffe0e60) at ASTReaderDecl.cpp:4153:3
frame #9: 0x000055555e57e86a clang`clang::ASTReader::GetDecl(this=0x0000555564ee3040, ID=GlobalDeclID @ 0x00007ffffffe0ed0) at ASTReader.cpp:7898:5
frame #10: 0x000055555e5ae522 clang`clang::ASTReader::ReadDecl(this=0x0000555564ee3040, F=0x0000555564f1f9e0, R=0x00007ffffffe1098, I=0x00007ffffffe1090) at ASTReader.h:1979:12
frame #11: 0x000055555e5dff08 clang`clang::ASTRecordReader::readDecl(this=0x00007ffffffe1078) at ASTRecordReader.h:190:20
frame #12: 0x000055555e5dfe25 clang`clang::ASTRecordReader::readDeclRef(this=0x00007ffffffe1078) at ASTRecordReader.h:193:12
frame #13: 0x000055555e604c61 clang`clang::serialization::AbstractTypeReader<clang::ASTRecordReader>::readRecordType(this=0x00007ffffffe1020) at AbstractTypeReader.inc:714:47
frame #14: 0x000055555e5a6fe1 clang`clang::serialization::AbstractTypeReader<clang::ASTRecordReader>::read(this=0x00007ffffffe1020, kind=Record) at AbstractTypeReader.inc:112:14
frame #15: 0x000055555e58242a clang`clang::ASTReader::readTypeRecord(this=0x0000555564ee3040, ID=4294967408) at ASTReader.cpp:6780:21
frame #16: 0x000055555e57dd01 clang`clang::ASTReader::GetType(this=0x0000555564ee3040, ID=4294967408) at ASTReader.cpp:7499:26
frame #17: 0x000055555e584b75 clang`clang::ASTReader::getLocalType(this=0x0000555564ee3040, F=0x0000555564f1f9e0, LocalID=4152) at ASTReader.cpp:7513:10
frame #18: 0x000055555e5caa73 clang`clang::ASTReader::readType(this=0x0000555564ee3040, F=0x0000555564f1f9e0, Record=0x00007ffffffe37c8, Idx=0x00007ffffffe37c0) at ASTReader.h:1922:12
frame #19: 0x000055555e5a9618 clang`clang::ASTRecordReader::readType(this=0x00007ffffffe37a8) at ASTRecordReader.h:176:20
frame #20: 0x000055555e5a6bd5 clang`clang::ASTRecordReader::readQualType(this=0x00007ffffffe37a8) at ASTRecordReader.h:179:12
frame #21: 0x000055555e5a99b0 clang`clang::serialization::BasicReaderBase<clang::ASTRecordReader>::readTemplateArgument(this=0x00007ffffffe37a8) at AbstractBasicReader.inc:942:39
frame #22: 0x000055555e5af76b clang`clang::ASTRecordReader::readTemplateArgument(this=0x00007ffffffe37a8, Canonicalize=true) at ASTRecordReader.h:236:28
frame #23: 0x000055555e58bb46 clang`clang::ASTRecordReader::readTemplateArgumentList(this=0x00007ffffffe37a8, TemplArgs=0x00007ffffffe2f10, Canonicalize=true) at ASTReader.cpp:9313:25
frame #24: 0x000055555e648c29 clang`clang::ASTDeclReader::VisitFunctionDecl(this=0x00007ffffffe3750, FD=0x0000555564f70e38) at ASTReaderDecl.cpp:958:12
frame #25: 0x000055555e67c1ff clang`clang::declvisitor::Base<std::add_pointer, clang::ASTDeclReader, void>::Visit(this=0x00007ffffffe3750, D=0x0000555564f70e38) at DeclNodes.inc:238:1
frame #26: 0x000055555e6466d4 clang`clang::ASTDeclReader::Visit(this=0x00007ffffffe3750, D=0x0000555564f70e38) at ASTReaderDecl.cpp:542:37
frame #27: 0x000055555e67b76f clang`clang::ASTReader::ReadDeclRecord(clang::GlobalDeclID)::$_2::operator()(this=0x00007ffffffe3300) const at ASTReaderDecl.cpp:4154:51
frame #28: 0x000055555e67b745 clang`void llvm::function_ref<void ()>::callback_fn<clang::ASTReader::ReadDeclRecord(clang::GlobalDeclID)::$_2>(callable=140737488237312) at STLFunctionalExtras.h:45:12
frame #29: 0x000055555b9904a9 clang`llvm::function_ref<void ()>::operator()(this=0x00007ffffffe31c0) const at STLFunctionalExtras.h:68:12
frame #30: 0x000055555e68ad7d clang`clang::runWithSufficientStackSpace(Diag=function_ref<void ()> @ 0x00007ffffffe31d0, Fn=function_ref<void ()> @ 0x00007ffffffe31c0) at Stack.h:46:7
frame #31: 0x000055555e67841e clang`clang::ASTReader::ReadDeclRecord(this=0x0000555564ee3040, ID=GlobalDeclID @ 0x00007ffffffe3a40) at ASTReaderDecl.cpp:4153:3
frame #32: 0x000055555e57e86a clang`clang::ASTReader::GetDecl(this=0x0000555564ee3040, ID=GlobalDeclID @ 0x00007ffffffe3ab0) at ASTReader.cpp:7898:5
frame #33: 0x000055555e584d25 clang`clang::ASTReader::GetExternalDecl(this=0x0000555564ee3040, ID=GlobalDeclID @ 0x00007ffffffe3ae8) at ASTReader.cpp:7595:60
frame #34: 0x0000555563bac6bc clang`clang::RedeclarableTemplateDecl::loadLazySpecializationsImpl(this=0x0000555564f6dea8) const at DeclTemplate.cpp:353:42
frame #35: 0x0000555563bacb35 clang`clang::FunctionTemplateDecl::LoadLazySpecializations(this=0x0000555564f6dea8) const at DeclTemplate.cpp:444:3
frame #36: 0x0000555563bacb59 clang`clang::FunctionTemplateDecl::getSpecializations(this=0x0000555564f6dea8) const at DeclTemplate.cpp:449:3
frame #37: 0x0000555563bacb95 clang`clang::FunctionTemplateDecl::findSpecialization(this=0x0000555564f6dea8, Args=ArrayRef<clang::TemplateArgument> @ 0x00007ffffffe3bb0, InsertPos=0x00007ffffffe44b0) at DeclTemplate.cpp:456:33
frame #38: 0x0000555563167ec9 clang`clang::TemplateDeclInstantiator::VisitFunctionDecl(this=0x00007ffffffe46d8, D=0x0000555564f6e148, TemplateParams=0x0000000000000000, FunctionRewriteKind=None) at SemaTemplateInstantiateDecl.cpp:2106:27
frame #39: 0x0000555563170623 clang`clang::TemplateDeclInstantiator::VisitFunctionDecl(this=0x00007ffffffe46d8, D=0x0000555564f6e148) at SemaTemplateInstantiateDecl.cpp:3828:10
frame #40: 0x000055556314a6cb clang`clang::declvisitor::Base<std::add_pointer, clang::TemplateDeclInstantiator, clang::Decl*>::Visit(this=0x00007ffffffe46d8, D=0x0000555564f6e148) at DeclNodes.inc:238:1
frame #41: 0x00005555631e3094 clang`clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)::$_0::operator()(this=0x00007ffffffe4698) const at SemaTemplateInstantiateDecl.cpp:4099:27
frame #42: 0x00005555631e3065 clang`void llvm::function_ref<void ()>::callback_fn<clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)::$_0>(callable=140737488242328) at STLFunctionalExtras.h:45:12
frame #43: 0x000055555b9904a9 clang`llvm::function_ref<void ()>::operator()(this=0x00007ffffffe4600) const at STLFunctionalExtras.h:68:12
frame #44: 0x000055555e68ad7d clang`clang::runWithSufficientStackSpace(Diag=function_ref<void ()> @ 0x00007ffffffe4610, Fn=function_ref<void ()> @ 0x00007ffffffe4600) at Stack.h:46:7
frame #45: 0x0000555561a12ac0 clang`clang::Sema::runWithSufficientStackSpace(this=0x0000555564f38d00, Loc=(ID = 2147461292), Fn=function_ref<void ()> @ 0x00007ffffffe4668) at Sema.cpp:575:3
frame #46: 0x0000555563171987 clang`clang::Sema::SubstDecl(this=0x0000555564f38d00, D=0x0000555564f6e148, Owner=0x0000555564ee09f0, TemplateArgs=0x00007ffffffe4a50) at SemaTemplateInstantiateDecl.cpp:4098:3
frame #47: 0x0000555562eb8325 clang`clang::Sema::FinishTemplateArgumentDeduction(this=0x0000555564f38d00, FunctionTemplate=0x0000555564f6dea8, Deduced=0x00007ffffffe54f0, NumExplicitlySpecified=1, Specialization=0x00007ffffffe5840, Info=0x00007ffffffe5850, OriginalCallArgs=0x00007ffffffe5368, PartialOverloading=false, CheckNonDependent=function_ref<bool ()> @ 0x00007ffffffe4d50) at SemaTemplateDeduction.cpp:3882:7
frame #48: 0x0000555562fc11c9 clang`clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>)::$_2::operator()(this=0x00007ffffffe4f70) const at SemaTemplateDeduction.cpp:4572:14
frame #49: 0x0000555562fc10e5 clang`void llvm::function_ref<void ()>::callback_fn<clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>)::$_2>(callable=140737488244592) at STLFunctionalExtras.h:45:12
frame #50: 0x000055555b9904a9 clang`llvm::function_ref<void ()>::operator()(this=0x00007ffffffe4e50) const at STLFunctionalExtras.h:68:12
frame #51: 0x000055555e68ad7d clang`clang::runWithSufficientStackSpace(Diag=function_ref<void ()> @ 0x00007ffffffe4e60, Fn=function_ref<void ()> @ 0x00007ffffffe4e50) at Stack.h:46:7
frame #52: 0x0000555561a12ac0 clang`clang::Sema::runWithSufficientStackSpace(this=0x0000555564f38d00, Loc=(ID = 2147461369), Fn=function_ref<void ()> @ 0x00007ffffffe4eb8) at Sema.cpp:575:3
frame #53: 0x0000555562ebaa6b clang`clang::Sema::DeduceTemplateArguments(this=0x0000555564f38d00, FunctionTemplate=0x0000555564f6dea8, ExplicitTemplateArgs=0x00007ffffffe5c70, Args=ArrayRef<clang::Expr *> @ 0x00007ffffffe5670, Specialization=0x00007ffffffe5840, Info=0x00007ffffffe5850, PartialOverloading=false, AggregateDeductionCandidate=false, ObjectType=QualType @ 0x00007ffffffe5668, ObjectClassification=(Kind = 21845, Modifiable = 0), CheckNonDependent=function_ref<bool (llvm::ArrayRef<clang::QualType>)> @ 0x00007ffffffe56c8) at SemaTemplateDeduction.cpp:4571:3
frame #54: 0x0000555562be0db7 clang`clang::Sema::AddTemplateOverloadCandidate(this=0x0000555564f38d00, FunctionTemplate=0x0000555564f6dea8, FoundDecl=DeclAccessPair @ 0x00007ffffffe5a98, ExplicitTemplateArgs=0x00007ffffffe5c70, Args=ArrayRef<clang::Expr *> @ 0x00007ffffffe5a88, CandidateSet=0x00007ffffffe6088, SuppressUserConversions=false, PartialOverloading=false, AllowExplicit=true, IsADLCandidate=NotADL, PO=Normal, AggregateCandidateDeduction=false) at SemaOverload.cpp:7695:40
frame #55: 0x0000555562bf5221 clang`AddOverloadedCallCandidate(S=0x0000555564f38d00, FoundDecl=DeclAccessPair @ 0x00007ffffffe5be8, ExplicitTemplateArgs=0x00007ffffffe5c70, Args=ArrayRef<clang::Expr *> @ 0x00007ffffffe5bd8, CandidateSet=0x00007ffffffe6088, PartialOverloading=false, KnownValid=true) at SemaOverload.cpp:13506:7
frame #56: 0x0000555562bf4eb1 clang`clang::Sema::AddOverloadedCallCandidates(this=0x0000555564f38d00, ULE=0x0000555564f70658, Args=ArrayRef<clang::Expr *> @ 0x00007ffffffe5dc0, CandidateSet=0x00007ffffffe6088, PartialOverloading=false) at SemaOverload.cpp:13560:5
frame #57: 0x0000555562bf564e clang`clang::Sema::buildOverloadedCallSet(this=0x0000555564f38d00, S=0x0000000000000000, Fn=0x0000555564f70658, ULE=0x0000555564f70658, Args=clang::MultiExprArg @ 0x00007ffffffe5f38, RParenLoc=(ID = 2147461369), CandidateSet=0x00007ffffffe6088, Result=0x00007ffffffe6060) at SemaOverload.cpp:13866:3
frame #58: 0x0000555562bf5bb9 clang`clang::Sema::BuildOverloadedCallExpr(this=0x0000555564f38d00, S=0x0000000000000000, Fn=0x0000555564f70658, ULE=0x0000555564f70658, LParenLoc=(ID = 2147461369), Args=clang::MultiExprArg @ 0x00007ffffffe7ae0, RParenLoc=(ID = 2147461385), ExecConfig=0x0000000000000000, AllowTypoCorrection=true, CalleesAddressIsTaken=false) at SemaOverload.cpp:14074:7
frame #59: 0x000055556236593d clang`clang::Sema::BuildCallExpr(this=0x0000555564f38d00, Scope=0x0000000000000000, Fn=0x0000555564f70658, LParenLoc=(ID = 2147461369), ArgExprs=clang::MultiExprArg @ 0x00007ffffffe8058, RParenLoc=(ID = 2147461385), ExecConfig=0x0000000000000000, IsExecConfig=false, AllowRecovery=true) at SemaExpr.cpp:6476:16
frame #60: 0x000055556237ea9f clang`clang::Sema::ActOnCallExpr(this=0x0000555564f38d00, Scope=0x0000000000000000, Fn=0x0000555564f70658, LParenLoc=(ID = 2147461369), ArgExprs=clang::MultiExprArg @ 0x00007ffffffe81e0, RParenLoc=(ID = 2147461385), ExecConfig=0x0000000000000000) at SemaExpr.cpp:6362:7
frame #61: 0x000055556310a362 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::RebuildCallExpr(this=0x00007ffffffe91d0, Callee=0x0000555564f70658, LParenLoc=(ID = 2147461369), Args=clang::MultiExprArg @ 0x00007ffffffe8260, RParenLoc=(ID = 2147461385), ExecConfig=0x0000000000000000) at TreeTransform.h:2860:22
frame #62: 0x00005555630ebb32 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(this=0x00007ffffffe91d0, E=0x0000555564f6e340) at TreeTransform.h:12458:23
frame #63: 0x00005555630d9f70 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(this=0x00007ffffffe91d0, E=0x0000555564f6e340) at StmtNodes.inc:602:1
frame #64: 0x00005555631113e4 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDecltypeType(this=0x00007ffffffe91d0, TLB=0x00007ffffffe9088, TL=DecltypeTypeLoc @ 0x00007ffffffe8888) at TreeTransform.h:6644:31
frame #65: 0x00005555630cfd1c clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(this=0x00007ffffffe91d0, TLB=0x00007ffffffe9088, T=(Ty = 0x0000555564f6e3a0, Data = 0x0000555564f70640)) at TypeNodes.inc:39:1
frame #66: 0x00005555630cf30f clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(this=0x00007ffffffe91d0, DI=0x0000555564f70638) at TreeTransform.h:5015:34
frame #67: 0x00005555630d0e64 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(this=0x00007ffffffe91d0, T=QualType @ 0x00007ffffffe9180) at TreeTransform.h:4994:40
frame #68: 0x00005555630d0d9f clang`clang::Sema::SubstType(this=0x0000555564f38d00, T=QualType @ 0x00007ffffffe9230, TemplateArgs=0x00007ffffffe9570, Loc=(ID = 2147461333), Entity=(Ptr = 93825254449080)) at SemaTemplateInstantiate.cpp:2849:23
frame #69: 0x0000555562eb792d clang`clang::Sema::SubstituteExplicitTemplateArguments(this=0x0000555564f38d00, FunctionTemplate=0x0000555564f6dbd8, ExplicitTemplateArgs=0x00007ffffffea830, Deduced=0x00007ffffffea0b0, ParamTypes=0x00007ffffffea060, FunctionType=0x0000000000000000, Info=0x00007ffffffea410) at SemaTemplateDeduction.cpp:3560:9
frame #70: 0x0000555562fc10be clang`clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>)::$_0::operator()(this=0x00007ffffffea008) const at SemaTemplateDeduction.cpp:4405:16
frame #71: 0x0000555562fc1075 clang`void llvm::function_ref<void ()>::callback_fn<clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>)::$_0>(callable=140737488265224) at STLFunctionalExtras.h:45:12
frame #72: 0x000055555b9904a9 clang`llvm::function_ref<void ()>::operator()(this=0x00007ffffffe9a10) const at STLFunctionalExtras.h:68:12
frame #73: 0x000055555e68ad7d clang`clang::runWithSufficientStackSpace(Diag=function_ref<void ()> @ 0x00007ffffffe9a20, Fn=function_ref<void ()> @ 0x00007ffffffe9a10) at Stack.h:46:7
frame #74: 0x0000555561a12ac0 clang`clang::Sema::runWithSufficientStackSpace(this=0x0000555564f38d00, Loc=(ID = 2147461519), Fn=function_ref<void ()> @ 0x00007ffffffe9a78) at Sema.cpp:575:3
frame #75: 0x0000555562eba143 clang`clang::Sema::DeduceTemplateArguments(this=0x0000555564f38d00, FunctionTemplate=0x0000555564f6dbd8, ExplicitTemplateArgs=0x00007ffffffea830, Args=ArrayRef<clang::Expr *> @ 0x00007ffffffea230, Specialization=0x00007ffffffea400, Info=0x00007ffffffea410, PartialOverloading=false, AggregateDeductionCandidate=false, ObjectType=QualType @ 0x00007ffffffea228, ObjectClassification=(Kind = 0, Modifiable = 0), CheckNonDependent=function_ref<bool (llvm::ArrayRef<clang::QualType>)> @ 0x00007ffffffea288) at SemaTemplateDeduction.cpp:4404:5
frame #76: 0x0000555562be0db7 clang`clang::Sema::AddTemplateOverloadCandidate(this=0x0000555564f38d00, FunctionTemplate=0x0000555564f6dbd8, FoundDecl=DeclAccessPair @ 0x00007ffffffea658, ExplicitTemplateArgs=0x00007ffffffea830, Args=ArrayRef<clang::Expr *> @ 0x00007ffffffea648, CandidateSet=0x00007ffffffeac48, SuppressUserConversions=false, PartialOverloading=false, AllowExplicit=true, IsADLCandidate=NotADL, PO=Normal, AggregateCandidateDeduction=false) at SemaOverload.cpp:7695:40
frame #77: 0x0000555562bf5221 clang`AddOverloadedCallCandidate(S=0x0000555564f38d00, FoundDecl=DeclAccessPair @ 0x00007ffffffea7a8, ExplicitTemplateArgs=0x00007ffffffea830, Args=ArrayRef<clang::Expr *> @ 0x00007ffffffea798, CandidateSet=0x00007ffffffeac48, PartialOverloading=false, KnownValid=true) at SemaOverload.cpp:13506:7
frame #78: 0x0000555562bf4eb1 clang`clang::Sema::AddOverloadedCallCandidates(this=0x0000555564f38d00, ULE=0x0000555564f6e880, Args=ArrayRef<clang::Expr *> @ 0x00007ffffffea980, CandidateSet=0x00007ffffffeac48, PartialOverloading=false) at SemaOverload.cpp:13560:5
frame #79: 0x0000555562bf564e clang`clang::Sema::buildOverloadedCallSet(this=0x0000555564f38d00, S=0x0000000000000000, Fn=0x0000555564f6e880, ULE=0x0000555564f6e880, Args=clang::MultiExprArg @ 0x00007ffffffeaaf8, RParenLoc=(ID = 2147461519), CandidateSet=0x00007ffffffeac48, Result=0x00007ffffffeac20) at SemaOverload.cpp:13866:3
frame #80: 0x0000555562bf5bb9 clang`clang::Sema::BuildOverloadedCallExpr(this=0x0000555564f38d00, S=0x0000000000000000, Fn=0x0000555564f6e880, ULE=0x0000555564f6e880, LParenLoc=(ID = 2147461519), Args=clang::MultiExprArg @ 0x00007ffffffec6a0, RParenLoc=(ID = 2147461535), ExecConfig=0x0000000000000000, AllowTypoCorrection=true, CalleesAddressIsTaken=false) at SemaOverload.cpp:14074:7
frame #81: 0x000055556236593d clang`clang::Sema::BuildCallExpr(this=0x0000555564f38d00, Scope=0x0000000000000000, Fn=0x0000555564f6e880, LParenLoc=(ID = 2147461519), ArgExprs=clang::MultiExprArg @ 0x00007ffffffecc18, RParenLoc=(ID = 2147461535), ExecConfig=0x0000000000000000, IsExecConfig=false, AllowRecovery=true) at SemaExpr.cpp:6476:16
frame #82: 0x000055556237ea9f clang`clang::Sema::ActOnCallExpr(this=0x0000555564f38d00, Scope=0x0000000000000000, Fn=0x0000555564f6e880, LParenLoc=(ID = 2147461519), ArgExprs=clang::MultiExprArg @ 0x00007ffffffecda0, RParenLoc=(ID = 2147461535), ExecConfig=0x0000000000000000) at SemaExpr.cpp:6362:7
frame #83: 0x000055556310a362 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::RebuildCallExpr(this=0x00007ffffffee338, Callee=0x0000555564f6e880, LParenLoc=(ID = 2147461519), Args=clang::MultiExprArg @ 0x00007ffffffece20, RParenLoc=(ID = 2147461535), ExecConfig=0x0000000000000000) at TreeTransform.h:2860:22
frame #84: 0x00005555630ebb32 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(this=0x00007ffffffee338, E=0x0000555564f6e478) at TreeTransform.h:12458:23
frame #85: 0x00005555630d9f70 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(this=0x00007ffffffee338, E=0x0000555564f6e478) at StmtNodes.inc:602:1
frame #86: 0x00005555631113e4 clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDecltypeType(this=0x00007ffffffee338, TLB=0x00007ffffffee2e0, TL=DecltypeTypeLoc @ 0x00007ffffffed448) at TreeTransform.h:6644:31
frame #87: 0x00005555630cfd1c clang`clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(this=0x00007ffffffee338, TLB=0x00007ffffffee2e0, T=(Ty = 0x0000555564f6e4d0, Data = 0x0000555564f6e578)) at TypeNodes.inc:39:1
frame #88: 0x000055556311de01 clang`clang::QualType clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, clang::CXXRecordDecl*, clang::Qualifiers, bool)::$_0>(this=0x00007ffffffee338, TLB=0x00007ffffffee2e0, TL=FunctionProtoTypeLoc @ 0x00007ffffffee108, ThisContext=0x0000555564f6c570, ThisTypeQuals=(Mask = 0), TransformExceptionSpec=(unnamed class) @ 0x00007ffffffee0ff) at TreeTransform.h:6271:33
frame #89: 0x00005555630d13ec clang`clang::QualType (anonymous namespace)::TemplateInstantiator::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, clang::CXXRecordDecl*, clang::Qualifiers, bool)::$_0>(this=0x00007ffffffee338, TLB=0x00007ffffffee2e0, TL=FunctionProtoTypeLoc @ 0x00007ffffffee218, ThisContext=0x0000555564f6c570, ThisTypeQuals=(Mask = 0), TransformExceptionSpec=(unnamed class) @ 0x00007ffffffee20f) at SemaTemplateInstantiate.cpp:2409:21
frame #90: 0x00005555630d10a9 clang`clang::Sema::SubstFunctionDeclType(this=0x0000555564f38d00, T=0x0000555564f6e560, Args=0x00007ffffffefa50, Loc=(ID = 2147461488), Entity=(Ptr = 93825254448984), ThisContext=0x0000555564f6c570, ThisTypeQuals=(Mask = 0), EvaluateConstraints=false) at SemaTemplateInstantiate.cpp:2905:27
frame #91: 0x000055556316a2c5 clang`clang::TemplateDeclInstantiator::SubstFunctionType(this=0x00007ffffffef6c8, D=0x0000555564f6d340, Params=0x00007ffffffeef00) at SemaTemplateInstantiateDecl.cpp:4466:38
frame #92: 0x00005555631661fe clang`clang::TemplateDeclInstantiator::VisitCXXMethodDecl(this=0x00007ffffffef6c8, D=0x0000555564f6d340, TemplateParams=0x0000555564f6e760, FunctionRewriteKind=None) at SemaTemplateInstantiateDecl.cpp:2546:27
frame #93: 0x0000555563165afe clang`clang::TemplateDeclInstantiator::VisitFunctionTemplateDecl(this=0x00007ffffffef6c8, D=0x0000555564f6d198) at SemaTemplateInstantiateDecl.cpp:1933:47
frame #94: 0x000055556314a9f9 clang`clang::declvisitor::Base<std::add_pointer, clang::TemplateDeclInstantiator, clang::Decl*>::Visit(this=0x00007ffffffef6c8, D=0x0000555564f6d198) at DeclNodes.inc:518:1
frame #95: 0x00005555630d3b96 clang`clang::Sema::InstantiateClass(this=0x0000555564f38d00, PointOfInstantiation=(ID = 90), Instantiation=0x0000555564f6c570, Pattern=0x0000555564f4b348, TemplateArgs=0x00007ffffffefa50, TSK=TSK_ImplicitInstantiation, Complain=true) at SemaTemplateInstantiate.cpp:3522:36
frame #96: 0x00005555630d51e0 clang`clang::Sema::InstantiateClassTemplateSpecialization(this=0x0000555564f38d00, PointOfInstantiation=(ID = 90), ClassTemplateSpec=0x0000555564f6c570, TSK=TSK_ImplicitInstantiation, Complain=true) at SemaTemplateInstantiate.cpp:3969:10
frame #97: 0x00005555632a8f58 clang`clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*)::$_0::operator()(this=0x00007ffffffefdc8) const at SemaType.cpp:9183:23
frame #98: 0x00005555632a8f05 clang`void llvm::function_ref<void ()>::callback_fn<clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*)::$_0>(callable=140737488289224) at STLFunctionalExtras.h:45:12
frame #99: 0x000055555b9904a9 clang`llvm::function_ref<void ()>::operator()(this=0x00007ffffffefba0) const at STLFunctionalExtras.h:68:12
frame #100: 0x000055555e68ad7d clang`clang::runWithSufficientStackSpace(Diag=function_ref<void ()> @ 0x00007ffffffefbb0, Fn=function_ref<void ()> @ 0x00007ffffffefba0) at Stack.h:46:7
frame #101: 0x0000555561a12ac0 clang`clang::Sema::runWithSufficientStackSpace(this=0x0000555564f38d00, Loc=(ID = 90), Fn=function_ref<void ()> @ 0x00007ffffffefc08) at Sema.cpp:575:3
frame #102: 0x00005555632892b7 clang`clang::Sema::RequireCompleteTypeImpl(this=0x0000555564f38d00, Loc=(ID = 90), T=QualType @ 0x00007ffffffeff00, Kind=AcceptSizeless, Diagnoser=0x00007ffffffeffe8) at SemaType.cpp:9182:9
frame #103: 0x0000555563288b93 clang`clang::Sema::RequireCompleteType(this=0x0000555564f38d00, Loc=(ID = 90), T=QualType @ 0x00007ffffffeff60, Kind=AcceptSizeless, Diagnoser=0x00007ffffffeffe8) at SemaType.cpp:8908:7
frame #104: 0x0000555561bd4ade clang`clang::Sema::RequireCompleteType(this=0x0000555564f38d00, Loc=(ID = 90), T=QualType @ 0x00007ffffffeffa0, Diagnoser=0x00007ffffffeffe8) at Sema.h:14947:12
frame #105: 0x00005555623821ce clang`clang::Sema::CheckCallReturnType(this=0x0000555564f38d00, ReturnType=QualType @ 0x00007fffffff0020, Loc=(ID = 90), CE=0x0000555564f6cff8, FD=0x0000555564f6ce00) at SemaExpr.cpp:20030:7
frame #106: 0x0000555562380e07 clang`clang::Sema::BuildResolvedCallExpr(this=0x0000555564f38d00, Fn=0x0000555564f6cfe0, NDecl=0x0000555564f6ce00, LParenLoc=(ID = 112), Args=ArrayRef<clang::Expr *> @ 0x00007fffffff0b58, RParenLoc=(ID = 113), Config=0x0000000000000000, IsExecConfig=false, UsesADL=NotADL) at SemaExpr.cpp:6822:7
frame #107: 0x0000555562bf61aa clang`FinishOverloadedCallExpr(SemaRef=0x0000555564f38d00, S=0x0000555564f55fa0, Fn=0x0000555564f69b10, ULE=0x0000555564f69b10, LParenLoc=(ID = 112), Args=clang::MultiExprArg @ 0x00007fffffff1020, RParenLoc=(ID = 113), ExecConfig=0x0000000000000000, CandidateSet=0x00007fffffff1148, Best=0x00007fffffff1100, OverloadResult=OR_Success, AllowTypoCorrection=true) at SemaOverload.cpp:13962:20
frame #108: 0x0000555562bf5e95 clang`clang::Sema::BuildOverloadedCallExpr(this=0x0000555564f38d00, S=0x0000555564f55fa0, Fn=0x0000555564f69b10, ULE=0x0000555564f69b10, LParenLoc=(ID = 112), Args=clang::MultiExprArg @ 0x00007fffffff2ba0, RParenLoc=(ID = 113), ExecConfig=0x0000000000000000, AllowTypoCorrection=true, CalleesAddressIsTaken=false) at SemaOverload.cpp:14103:10
frame #109: 0x000055556236593d clang`clang::Sema::BuildCallExpr(this=0x0000555564f38d00, Scope=0x0000555564f55fa0, Fn=0x0000555564f69b10, LParenLoc=(ID = 112), ArgExprs=clang::MultiExprArg @ 0x00007fffffff3118, RParenLoc=(ID = 113), ExecConfig=0x0000000000000000, IsExecConfig=false, AllowRecovery=true) at SemaExpr.cpp:6476:16
frame #110: 0x000055556237ea9f clang`clang::Sema::ActOnCallExpr(this=0x0000555564f38d00, Scope=0x0000555564f55fa0, Fn=0x0000555564f69b10, LParenLoc=(ID = 112), ArgExprs=clang::MultiExprArg @ 0x00007fffffff32a0, RParenLoc=(ID = 113), ExecConfig=0x0000000000000000) at SemaExpr.cpp:6362:7
frame #111: 0x0000555561896acb clang`clang::Parser::ParsePostfixExpressionSuffix(this=0x0000555564f44790, LHS=(Value = 93825254464272)) at ParseExpr.cpp:2244:23
frame #112: 0x000055556189bf0c clang`clang::Parser::ParseCastExpression(this=0x0000555564f44790, ParseKind=AnyCastExpr, isAddressOfOperand=false, NotCastExpr=0x00007fffffff72a7, isTypeCast=NotTypeCast, isVectorLiteral=false, NotPrimaryExpression=0x0000000000000000) at ParseExpr.cpp:1946:9
frame #113: 0x0000555561894f39 clang`clang::Parser::ParseCastExpression(this=0x0000555564f44790, ParseKind=AnyCastExpr, isAddressOfOperand=false, isTypeCast=NotTypeCast, isVectorLiteral=false, NotPrimaryExpression=0x0000000000000000) at ParseExpr.cpp:712:20
frame #114: 0x0000555561893431 clang`clang::Parser::ParseAssignmentExpression(this=0x0000555564f44790, isTypeCast=NotTypeCast) at ParseExpr.cpp:182:20
frame #115: 0x00005555618932df clang`clang::Parser::ParseExpression(this=0x0000555564f44790, isTypeCast=NotTypeCast) at ParseExpr.cpp:133:18
frame #116: 0x000055556192f2b8 clang`clang::Parser::ParseExprStatement(this=0x0000555564f44790, StmtCtx=Compound) at ParseStmt.cpp:563:19
frame #117: 0x000055556192d5ea clang`clang::Parser::ParseStatementOrDeclarationAfterAttributes(this=0x0000555564f44790, Stmts=0x00007fffffff8240, StmtCtx=Compound, TrailingElseLoc=0x0000000000000000, CXX11Attrs=0x00007fffffff7cd8, GNUAttrs=0x00007fffffff7c48) at ParseStmt.cpp:292:14
frame #118: 0x000055556192cc5d clang`clang::Parser::ParseStatementOrDeclaration(this=0x0000555564f44790, Stmts=0x00007fffffff8240, StmtCtx=Compound, TrailingElseLoc=0x0000000000000000) at ParseStmt.cpp:124:20
frame #119: 0x0000555561935ef2 clang`clang::Parser::ParseCompoundStatementBody(this=0x0000555564f44790, isStmtExpr=false) at ParseStmt.cpp:1257:11
frame #120: 0x00005555619375e4 clang`clang::Parser::ParseFunctionStatementBody(this=0x0000555564f44790, Decl=0x0000555564f4abe8, BodyScope=0x00007fffffff86a0) at ParseStmt.cpp:2535:21
frame #121: 0x000055556185b880 clang`clang::Parser::ParseFunctionDefinition(this=0x0000555564f44790, D=0x00007fffffff90c0, TemplateInfo=0x00007fffffffa5a0, LateParsedAttrs=0x00007fffffff8f08) at Parser.cpp:1520:10
frame #122: 0x00005555619047a9 clang`clang::Parser::ParseDeclGroup(this=0x0000555564f44790, DS=0x00007fffffffa640, Context=File, Attrs=0x00007fffffffad78, TemplateInfo=0x00007fffffffa5a0, DeclEnd=0x0000000000000000, FRI=0x0000000000000000) at ParseDecl.cpp:2434:17
frame #123: 0x000055556185a637 clang`clang::Parser::ParseDeclOrFunctionDefInternal(this=0x0000555564f44790, Attrs=0x00007fffffffad78, DeclSpecAttrs=0x00007ffffffface8, DS=0x00007fffffffa640, AS=AS_none) at Parser.cpp:1244:10
frame #124: 0x0000555561859b2e clang`clang::Parser::ParseDeclarationOrFunctionDefinition(this=0x0000555564f44790, Attrs=0x00007fffffffad78, DeclSpecAttrs=0x00007ffffffface8, DS=0x0000000000000000, AS=AS_none) at Parser.cpp:1266:12
frame #125: 0x00005555618593b9 clang`clang::Parser::ParseExternalDeclaration(this=0x0000555564f44790, Attrs=0x00007fffffffad78, DeclSpecAttrs=0x00007ffffffface8, DS=0x0000000000000000) at Parser.cpp:1069:14
frame #126: 0x00005555618571fb clang`clang::Parser::ParseTopLevelDecl(this=0x0000555564f44790, Result=0x00007fffffffafb8, ImportState=0x00007fffffffafb4) at Parser.cpp:758:12
frame #127: 0x0000555561851e2c clang`clang::ParseAST(S=0x0000555564f38d00, PrintStats=false, SkipFunctionBodies=false) at ParseAST.cpp:171:20
frame #128: 0x000055555e2c5ee1 clang`clang::ASTFrontendAction::ExecuteAction(this=0x0000555564eb06d0) at FrontendAction.cpp:1192:3
frame #129: 0x000055555e2c58fc clang`clang::FrontendAction::Execute(this=0x0000555564eb06d0) at FrontendAction.cpp:1078:8
frame #130: 0x000055555e1de2e6 clang`clang::CompilerInstance::ExecuteAction(this=0x0000555564ea8a80, Act=0x0000555564eb06d0) at CompilerInstance.cpp:1061:33
frame #131: 0x000055555e4a3528 clang`clang::ExecuteCompilerInvocation(Clang=0x0000555564ea8a80) at ExecuteCompilerInvocation.cpp:280:25
frame #132: 0x000055555aec82e9 clang`cc1_main(Argv=ArrayRef<const char *> @ 0x00007fffffffba08, Argv0="llvm-project/build/bin/clang", MainAddr=0x000055555aeba5f0) at cc1_main.cpp:285:15
frame #133: 0x000055555aebbd32 clang`ExecuteCC1Tool(ArgV=0x00007fffffffcd18, ToolContext=0x00007fffffffd550) at driver.cpp:215:12
frame #134: 0x000055555aebaa9b clang`clang_main(Argc=12, Argv=0x00007fffffffd728, ToolContext=0x00007fffffffd550) at driver.cpp:256:12
frame #135: 0x000055555aeed535 clang`main(argc=12, argv=0x00007fffffffd728) at clang-driver.cpp:17:10
frame #136: 0x00007ffff7829590 libc.so.6`__libc_start_call_main + 128
frame #137: 0x00007ffff7829640 libc.so.6`__libc_start_main@@GLIBC_2.34 + 128
frame #138: 0x000055555aeba525 clang`_start + 37
```
</details>
Short version:
```
frame #0: clang::ASTDeclReader::VisitCXXRecordDeclImpl: reading CXXRecordDecl for lambda imported in ./folly-conv.h - will become canonical because it is the first decl seen
frame #24: clang::ASTDeclReader::VisitFunctionDecl: reading FunctionDecl template specialization of `__declval` for lambda imported in ./folly-conv.h
frame #34: RedeclarableTemplateDecl::loadLazySpecializationsImpl: load all specialization for `__declval` imported in ./thrift_cpp2_base.h
frame #55: AddOverloadedCallCandidate: call for `__declval` imported in ./thrift_cpp2_base.h
frame #77: AddOverloadedCallCandidate: call for `declval` imported in ./thrift_cpp2_base.h
frame #95: clang::Sema::InstantiateClass: instantiation of Expected<unsigned int, const char *> member thenOrThrow
frame #107: FinishOverloadedCallExpr call tryTo<unsigned int>
```
My testing on real code showed that reverting the order of loading specialization is not enough if instead of two modules there are much more modules. Therefore I'm keep working on a solution that works on real example with many modules.
https://github.com/llvm/llvm-project/pull/104512
More information about the cfe-commits
mailing list