Page MenuHomePhabricator

[clang] Fix redundant functional cast in ConstantExpr
Needs ReviewPublic

Authored by Izaron on Feb 6 2022, 1:57 PM.

Details

Summary

When removing nested ConstantExprs, the tree transformer
doesn't remove redundant CXXFunctionalCasts that were created
"above" consteval constructors. After a while it generates a call
to a constructor, therefore violating the C++17 mandatory copy
elision rule.

Fixes https://github.com/llvm/llvm-project/issues/53244
and https://github.com/llvm/llvm-project/issues/53245

Diff Detail

Event Timeline

Izaron requested review of this revision.Feb 6 2022, 1:57 PM
Izaron created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 6 2022, 1:57 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Izaron added a comment.Feb 6 2022, 2:10 PM

There are some godbolt links in the github issues.

Expression A{}.f(); generates the call of the move constructor from nowhere as well - https://godbolt.org/z/MceYedKzj

With the patch this node (that lives inside an another ConstantExpr node):

MemberExpr 0x55555e48b3d8 '<bound member function type>' .f 0x55555e48aa98
`-MaterializeTemporaryExpr 0x55555e48b3c0 'struct A' xvalue
  `-CXXFunctionalCastExpr 0x55555e48b398 'struct A' functional cast to struct A <NoOp>
    `-ConstantExpr 0x55555e48b200 'struct A'
      `-CXXTemporaryObjectExpr 0x55555e48b1d0 'struct A' 'void (void)' list

transforms to this:

MemberExpr 0x55555e48b3d8 '<bound member function type>' .f 0x55555e48aa98
`-MaterializeTemporaryExpr 0x55555e48b3c0 'struct A' xvalue
  `-CXXTemporaryObjectExpr 0x55555e48b1d0 'struct A' 'void (void)' list

I reviewed other github issues about consteval. This patch doesn't fix other known issues as I checked.

P.S. If this review is eventually approved, kindly please merge the commit on my behalf =) As I don't have merge access. My name is Evgeny Shulgin and email is izaronplatz@gmail.com. Sorry for inconvenience!

I think this makes sense to me, I'd like to see it captured in an AST test though.

I haven't had the chance to review this yet (in C standards meetings again this week), but I did notice that https://reviews.llvm.org/D119477 seems to be touching on a related (or possibly the same) issue. Can you coordinate with the other patch author to make sure nobody is writing patches (or reviewing them) that conflict? Thanks!

kimgr added a subscriber: kimgr.Feb 15 2022, 8:35 AM

Thanks for the heads-up! I'm a little busy this week, but I need to think about potential interference between these two changes. Off the top of my head it looks like they should get along fine, but there may be subtleties.

kimgr added a comment.Feb 19 2022, 5:21 AM

First sanity check: applying this patch on my branch causes no test failures either in the tools/clang/unittests/Tooling/ToolingTests or ninja check-clang-semacxx. Hopefully I can think this through more deeply soon.

kimgr added a comment.EditedFeb 19 2022, 10:17 AM

I can also confirm that main and my branch (containing https://reviews.llvm.org/D119477 and https://reviews.llvm.org/D119476) both assert on the same line:

$ cat ../../bug-53244.cc 
struct A {       
    consteval A() {}
    A(const A&) = delete;
    consteval void f() {}
};

int main() {
    A{A{}}.f();
}

$ bin/clang -std=c++20 ../../bug-53244.cc
clang-14: /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExprCXX.cpp:1453: clang::ExprResult clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo *, clang::SourceLocation, clang::MultiExprArg, clang::SourceLocation, bool): Assertion `(!ListInitialization || (Exprs.size() == 1 && isa<InitListExpr>(Exprs[0]))) && "List initialization must have initializer list as expression."' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /home/kimgr/code/llvm-project/out/main/bin/clang-14 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name bug-53244.cc -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/kimgr/code/llvm-project/out/main -resource-dir /home/kimgr/code/llvm-project/out/main/lib/clang/15.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /home/kimgr/code/llvm-project/out/main/lib/clang/15.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/kimgr/code/llvm-project/out/main -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/bug-53244-192e65.o -x c++ ../../bug-53244.cc
1.      <eof> parser at end of file
2.      ../../bug-53244.cc:7:12: parsing function body 'main'
 #0 0x000000000698e43a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/kimgr/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
 #1 0x000000000698e5eb PrintStackTraceSignalHandler(void*) /home/kimgr/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x000000000698cc9a llvm::sys::RunSignalHandlers() /home/kimgr/code/llvm-project/llvm/lib/Support/Signals.cpp:97:5
 #3 0x000000000698ed15 SignalHandler(int) /home/kimgr/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f8769c493c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #5 0x00007f87696dd18b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007f87696bc859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
 #7 0x00007f87696bc729 get_sysdep_segment_value /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
 #8 0x00007f87696bc729 _nl_load_domain /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
 #9 0x00007f87696cdf36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#10 0x000000000af7d719 clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExprCXX.cpp:1454:39
#11 0x000000000ade829d clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::RebuildCXXFunctionalCastExpr(clang::TypeSourceInfo*, clang::SourceLocation, clang::Expr*, clang::SourceLocation, bool) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:3019:22
#12 0x000000000adac3d5 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformCXXFunctionalCastExpr(clang::CXXFunctionalCastExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:11728:23
#13 0x000000000ada4a8f clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:929:1
#14 0x000000000adcd51c clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExprs(clang::Expr* const*, unsigned int, bool, llvm::SmallVectorImpl<clang::Expr*>&, bool*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:4047:29
#15 0x000000000adae285 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformInitListExpr(clang::InitListExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:11246:7
#16 0x000000000ada507e clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:1147:1
#17 0x000000000adac2d8 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformCXXFunctionalCastExpr(clang::CXXFunctionalCastExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:11719:20
#18 0x000000000ada4a8f clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:929:1
#19 0x000000000adafff2 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformMaterializeTemporaryExpr(clang::MaterializeTemporaryExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:13562:23
#20 0x000000000ada5173 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:1177:1
#21 0x000000000adb0257 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformMemberExpr(clang::MemberExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:10927:34
#22 0x000000000ada51d5 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:1189:1
#23 0x000000000adab9b2 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformCallExpr(clang::CallExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:10891:36
#24 0x000000000adabef5 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformCXXMemberCallExpr(clang::CXXMemberCallExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:11590:23
#25 0x000000000ada499a clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:887:1
#26 0x000000000adadce2 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExprWithCleanups(clang::ExprWithCleanups*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:12757:23
#27 0x000000000ada4f58 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:1107:1
#28 0x000000000ada3933 RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExpr.cpp:16835:32
#29 0x000000000ad90435 HandleImmediateInvocations(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExpr.cpp:16864:23
#30 0x000000000ad88cf4 clang::Sema::PopExpressionEvaluationContext() /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExpr.cpp:16930:19
#31 0x000000000a91baea ExitFunctionBodyRAII::~ExitFunctionBodyRAII() /home/kimgr/code/llvm-project/clang/lib/Sema/SemaDecl.cpp:14600:3
#32 0x000000000a8f2f2b clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaDecl.cpp:14983:3
#33 0x000000000a8f1317 clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaDecl.cpp:14589:3
#34 0x000000000a50505f clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /home/kimgr/code/llvm-project/clang/lib/Parse/ParseStmt.cpp:2379:18
#35 0x000000000a4c71a0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:1378:3
#36 0x000000000a577a20 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/kimgr/code/llvm-project/clang/lib/Parse/ParseDecl.cpp:2053:27
#37 0x000000000a4c611f clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:1138:10
#38 0x000000000a4c57d0 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:1154:12
#39 0x000000000a4c50cf clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:976:12
#40 0x000000000a4c345b clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:720:12
#41 0x000000000a4be6e4 clang::ParseAST(clang::Sema&, bool, bool) /home/kimgr/code/llvm-project/clang/lib/Parse/ParseAST.cpp:158:16
#42 0x0000000007bee7bc clang::ASTFrontendAction::ExecuteAction() /home/kimgr/code/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1076:1
#43 0x0000000007dc0d52 clang::CodeGenAction::ExecuteAction() /home/kimgr/code/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1107:5
#44 0x0000000007bee1bc clang::FrontendAction::Execute() /home/kimgr/code/llvm-project/clang/lib/Frontend/FrontendAction.cpp:971:7
#45 0x0000000007b2762c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/kimgr/code/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1036:23
#46 0x0000000007daa037 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/kimgr/code/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:263:8
#47 0x000000000499f23d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/kimgr/code/llvm-project/clang/tools/driver/cc1_main.cpp:248:13
#48 0x000000000499278e ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/kimgr/code/llvm-project/clang/tools/driver/driver.cpp:317:5
#49 0x0000000004991821 main /home/kimgr/code/llvm-project/clang/tools/driver/driver.cpp:388:5
#50 0x00007f87696be0b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#51 0x000000000499107e _start (/home/kimgr/code/llvm-project/out/main/bin/clang-14+0x499107e)

So I would argue that these two patch sets are independent and solves different problems.

kimgr added a comment.Feb 20 2022, 2:41 AM

Having looked at this some more, I wonder if this patch is covering for another problem. Running even the simplest example fails on an assertion in Sema::BuildCXXTypeConstructExpr: https://godbolt.org/z/fMPcsh4f3.

It looks like that function is creating the majority of CXXFunctionalCastExprs, so the way the patch shaves off CXXFunctionalCastExpr might be compensating for something that should never happen. I don't know much about this, so I can't say for sure.