Hi Brian,
Thanks for letting me know about this. I’ve been able to reproduce the issue thanks to your reproducer and realized there’s some missing include in FileCheck.h, namely for StringRef(“llvm/ADT/StringRef.h”), Expected (“llvm/Support/Error.h”), Optional (“llvm/ADT/Optional.h”) and std::string (). However that does not solve the problem. Still, this warrants a patch in itself IMO. Unsurprisingly, changing all the Expectedstd::string for Expected in FileCheck.h let the compilation proceed but I can see some other uses of Expectedstd::string in headers so that ought not to be a problem. Please find below the backtrace when building the first stage llvm with debug info:
#0 __GI_raise (sig=sig@entry=6) at …/sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff687b801 in __GI_abort () at abort.c:79
#2 0x00007ffff686b39a in __assert_fail_base (fmt=0x7ffff69f27d8 “%s%s%s:%u: %s%sAssertion `%s’ failed.\n%n”,
assertion=assertion@entry=0x55555f5b0b98 “CachedFieldIndex && "failed to find field in parent"”,
file=file@entry=0x55555f5afa88 “/home/thomasp/repos/llvm-project-modules-crash/clang/lib/AST/Decl.cpp”, line=line@entry=3932,
function=function@entry=0x55555f5c3640 <clang::FieldDecl::getFieldIndex() const::PRETTY_FUNCTION> “unsigned int clang::FieldDecl::getFieldIndex() const”) at assert.c:92
#3 0x00007ffff686b412 in __GI___assert_fail (assertion=0x55555f5b0b98 “CachedFieldIndex && "failed to find field in parent"”,
file=0x55555f5afa88 “clang/lib/AST/Decl.cpp”, line=3932,
function=0x55555f5c3640 <clang::FieldDecl::getFieldIndex() const::PRETTY_FUNCTION> “unsigned int clang::FieldDecl::getFieldIndex() const”) at assert.c:101
#4 0x000055555c4e8773 in clang::FieldDecl::getFieldIndex (this=0x55557702a108) at clang/lib/AST/Decl.cpp:3932
#5 0x000055555929e37f in clang::CodeGen::CodeGenFunction::EmitLValueForField (this=0x7fffffff7d70, base=…, field=0x55557702a108)
at clang/lib/CodeGen/CGExpr.cpp:3965
#6 0x000055555929d8cc in clang::CodeGen::CodeGenFunction::EmitMemberExpr (this=0x7fffffff7d70, E=0x555577029f38) at clang/lib/CodeGen/CGExpr.cpp:3853
#7 0x000055555928e20b in clang::CodeGen::CodeGenFunction::EmitLValue (this=0x7fffffff7d70, E=0x555577029f38) at clang/lib/CodeGen/CGExpr.cpp:1346
#8 0x000055555928d636 in clang::CodeGen::CodeGenFunction::EmitCheckedLValue (this=0x7fffffff7d70, E=0x555577029f38, TCK=clang::CodeGen::CodeGenFunction::TCK_MemberAccess)
at clang/lib/CodeGen/CGExpr.cpp:1212
#9 0x000055555929d782 in clang::CodeGen::CodeGenFunction::EmitMemberExpr (this=0x7fffffff7d70, E=0x55557702a2b8) at clang/lib/CodeGen/CGExpr.cpp:3849
#10 0x000055555928e20b in clang::CodeGen::CodeGenFunction::EmitLValue (this=0x7fffffff7d70, E=0x55557702a2b8) at clang/lib/CodeGen/CGExpr.cpp:1346
#11 0x000055555929fb59 in clang::CodeGen::CodeGenFunction::EmitCastLValue (this=0x7fffffff7d70, E=0x55557702a2e8) at clang/lib/CodeGen/CGExpr.cpp:4264
#12 0x000055555928e36b in clang::CodeGen::CodeGenFunction::EmitLValue (this=0x7fffffff7d70, E=0x55557702a2e8) at clang/lib/CodeGen/CGExpr.cpp:1367
#13 0x000055555928d636 in clang::CodeGen::CodeGenFunction::EmitCheckedLValue (this=0x7fffffff7d70, E=0x55557702a2e8, TCK=clang::CodeGen::CodeGenFunction::TCK_MemberAccess)
at clang/lib/CodeGen/CGExpr.cpp:1212
#14 0x000055555929d782 in clang::CodeGen::CodeGenFunction::EmitMemberExpr (this=0x7fffffff7d70, E=0x55557702a380) at clang/lib/CodeGen/CGExpr.cpp:3849
#15 0x000055555928e20b in clang::CodeGen::CodeGenFunction::EmitLValue (this=0x7fffffff7d70, E=0x55557702a380) at clang/lib/CodeGen/CGExpr.cpp:1346
#16 0x00005555592998d5 in clang::CodeGen::CodeGenFunction::EmitArrayToPointerDecay (this=0x7fffffff7d70, E=0x55557702a380, BaseInfo=0x0, TBAAInfo=0x0)
at clang/lib/CodeGen/CGExpr.cpp:3307
#17 0x00005555592de962 in (anonymous namespace)::ScalarExprEmitter::VisitCastExpr (this=0x7fffffff7870, CE=0x55557702a3b0)
at clang/lib/CodeGen/CGExprScalar.cpp:2145
#18 0x00005555592ef299 in clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::VisitImplicitCastExpr (this=0x7fffffff7870, S=0x55557702a3b0)
at tools/clang/include/clang/AST/StmtNodes.inc:859
#19 0x00005555592edb8d in clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit (this=0x7fffffff7870, S=0x55557702a3b0)
at tools/clang/include/clang/AST/StmtNodes.inc:859
#20 0x00005555592d59c9 in (anonymous namespace)::ScalarExprEmitter::Visit (this=0x7fffffff7870, E=0x55557702a3b0) at clang/lib/CodeGen/CGExprScalar.cpp:424
#21 0x00005555592de09e in (anonymous namespace)::ScalarExprEmitter::VisitCastExpr (this=0x7fffffff7870, CE=0x55557702a3c8)
at clang/lib/CodeGen/CGExprScalar.cpp:2040
#22 0x00005555592d6732 in (anonymous namespace)::ScalarExprEmitter::VisitExplicitCastExpr (this=0x7fffffff7870, E=0x55557702a3c8)
at clang/lib/CodeGen/CGExprScalar.cpp:573
#23 0x00005555592ef759 in clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::VisitCXXNamedCastExpr (this=0x7fffffff7870, S=0x55557702a3c8)
at tools/clang/include/clang/AST/StmtNodes.inc:817
#24 0x00005555592ef227 in clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::VisitCXXReinterpretCastExpr (this=0x7fffffff7870, S=0x55557702a3c8)
at tools/clang/include/clang/AST/StmtNodes.inc:833
#25 0x00005555592edb45 in clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit (this=0x7fffffff7870, S=0x55557702a3c8)
at tools/clang/include/clang/AST/StmtNodes.inc:833
#26 0x00005555592d59c9 in (anonymous namespace)::ScalarExprEmitter::Visit (this=0x7fffffff7870, E=0x55557702a3c8) at clang/lib/CodeGen/CGExprScalar.cpp:424
#27 0x00005555592eb469 in clang::CodeGen::CodeGenFunction::EmitScalarExpr (this=0x7fffffff7d70, E=0x55557702a3c8, IgnoreResultAssign=false)
at clang/lib/CodeGen/CGExprScalar.cpp:4488
#28 0x0000555558f48431 in clang::CodeGen::CodeGenFunction::EmitReturnStmt (this=0x7fffffff7d70, S=…) at clang/lib/CodeGen/CGStmt.cpp:1097
#29 0x0000555558f4416e in clang::CodeGen::CodeGenFunction::EmitStmt (this=0x7fffffff7d70, S=0x55557702a408, Attrs=…) at clang/lib/CodeGen/CGStmt.cpp:144
#30 0x0000555558f44ddb in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope (this=0x7fffffff7d70, S=…, GetLast=false, AggSlot=…)
at clang/lib/CodeGen/CGStmt.cpp:386
#31 0x0000555558fc8045 in clang::CodeGen::CodeGenFunction::EmitFunctionBody (this=0x7fffffff7d70, Body=0x55557702a498)
at clang/lib/CodeGen/CodeGenFunction.cpp:1023
#32 0x0000555558fc8caf in clang::CodeGen::CodeGenFunction::GenerateCode (this=0x7fffffff7d70, GD=…, Fn=0x555579b00fc8, FnInfo=…)
at clang/lib/CodeGen/CodeGenFunction.cpp:1188
#33 0x0000555558ff07ad in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition (this=0x555561837460, GD=…, GV=0x555579b00fc8)
at clang/lib/CodeGen/CodeGenModule.cpp:4295
#34 0x0000555558fe9ad4 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition (this=0x555561837460, GD=…, GV=0x555579b00fc8)
at clang/lib/CodeGen/CodeGenModule.cpp:2740
#35 0x0000555558fe6d11 in clang::CodeGen::CodeGenModule::EmitDeferred (this=0x555561837460) at clang/lib/CodeGen/CodeGenModule.cpp:2118
#36 0x0000555558fe6d5f in clang::CodeGen::CodeGenModule::EmitDeferred (this=0x555561837460) at clang/lib/CodeGen/CodeGenModule.cpp:2124
#37 0x0000555558fe6d5f in clang::CodeGen::CodeGenModule::EmitDeferred (this=0x555561837460) at clang/lib/CodeGen/CodeGenModule.cpp:2124
#38 0x0000555558fddfb9 in clang::CodeGen::CodeGenModule::Release (this=0x555561837460) at clang/lib/CodeGen/CodeGenModule.cpp:393
#39 0x0000555559e08f29 in (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit (this=0x555561831d40, Ctx=…)
at clang/lib/CodeGen/ModuleBuilder.cpp:256
#40 0x0000555559e024b8 in clang::BackendConsumer::HandleTranslationUnit (this=0x555561831ab0, C=…) at clang/lib/CodeGen/CodeGenAction.cpp:238
#41 0x000055555b3c274c in clang::ParseAST (S=…, PrintStats=false, SkipFunctionBodies=false) at clang/lib/Parse/ParseAST.cpp:171
#42 0x00005555595bb943 in clang::ASTFrontendAction::ExecuteAction (this=0x55556180d440) at clang/lib/Frontend/FrontendAction.cpp:1035
#43 0x0000555559e0067f in clang::CodeGenAction::ExecuteAction (this=0x55556180d440) at clang/lib/CodeGen/CodeGenAction.cpp:1059
#44 0x00005555595bb332 in clang::FrontendAction::Execute (this=0x55556180d440) at clang/lib/Frontend/FrontendAction.cpp:934
#45 0x00005555595576c4 in clang::CompilerInstance::ExecuteAction (this=0x5555617e1a60, Act=…) at clang/lib/Frontend/CompilerInstance.cpp:944
#46 0x0000555559715a87 in clang::ExecuteCompilerInvocation (Clang=0x5555617e1a60) at clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:287
#47 0x000055555762f146 in cc1_main (Argv=…, Argv0=0x7fffffffd6a4 “build-s1/bin/clang-9”,
MainAddr=0x555557622e5a <GetExecutablePath[abi:cxx11](char const*, bool)>) at clang/tools/driver/cc1_main.cpp:250
#48 0x00005555576245cb in ExecuteCC1Tool (argv=…, Tool=…) at clang/tools/driver/driver.cpp:309
#49 0x0000555557624cbc in main (argc_=125, argv_=0x7fffffffcf48) at clang/tools/driver/driver.cpp:381
Note that I think this should give an error message rather than an assert but of course that does not change that there is a bug somewhere. I’ll keep looking.
Best regards,
Thomas