[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

Alan Zhao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 24 16:00:19 PDT 2022


ayzhao marked 11 inline comments as done.
ayzhao added a comment.

In D129531#3873872 <https://reviews.llvm.org/D129531#3873872>, @royjacobson wrote:

> Thanks for working on it! It looks really good. Please remember to update the feature test macro (__cpp_aggregate_paren_init).

Done

> Also, I think there's no test coverage for the ASTReader/Writer changes? I would like to see some as well.

I added a precompiled header test. Currently, the ASTReader/Writer change is broken with the following error:

                                                                                                                           "hunter-bidens-laptop." 15:58 24-Oct-22
  $ bin/llvm-lit -vv --debug ../clang/test/PCH/cxx_paren_init.cpp
  [553/553] Creating executable symlink bin/clang
  llvm-lit: /llvm-project/llvm/utils/lit/lit/discovery.py:62: note: loading suite config '/llvm-project/build/tools/clang/test/lit.site.cfg.py'
  llvm-lit: /llvm-project/llvm/utils/lit/lit/LitConfig.py:116: note: load_config from '/llvm-project/clang/test/lit.cfg.py'
  llvm-lit: /llvm-project/llvm/utils/lit/lit/llvm/config.py:456: note: using clang: /llvm-project/build/bin/clang
  llvm-lit: /llvm-project/llvm/utils/lit/lit/TestingConfig.py:129: note: ... loaded config '/llvm-project/clang/test/lit.cfg.py'
  llvm-lit: /llvm-project/llvm/utils/lit/lit/TestingConfig.py:129: note: ... loaded config '/llvm-project/build/tools/clang/test/lit.site.cfg.py'
  llvm-lit: /llvm-project/llvm/utils/lit/lit/discovery.py:136: note: resolved input '../clang/test/PCH/cxx_paren_init.cpp' to 'Clang'::('PCH', 'cxx_paren_init.cpp')
  -- Testing: 1 tests, 1 workers --
  FAIL: Clang :: PCH/cxx_paren_init.cpp (1 of 1)
  ******************** TEST 'Clang :: PCH/cxx_paren_init.cpp' FAILED ********************
  Script:
  --
  : 'RUN: at line 1';   /llvm-project/build/bin/clang -cc1 -internal-isystem /llvm-project/build/lib/clang/16.0.0/include -nostdsysteminc -x c++ -std=c++20 -emit-pc
  h -o /llvm-project/build/tools/clang/test/PCH/Output/cxx_paren_init.cpp.tmp /llvm-project/clang/test/PCH/cxx_paren_init.h
  : 'RUN: at line 2';   /llvm-project/build/bin/clang -cc1 -internal-isystem /llvm-project/build/lib/clang/16.0.0/include -nostdsysteminc -x c++ -std=c++20 -include
  -pch /llvm-project/build/tools/clang/test/PCH/Output/cxx_paren_init.cpp.tmp -fsyntax-only -S -o -
  --
  Exit Code: 139
  
  Command Output (stderr):
  --
  + : 'RUN: at line 1'
  + /llvm-project/build/bin/clang -cc1 -internal-isystem /llvm-project/build/lib/clang/16.0.0/include -nostdsysteminc -x c++ -std=c++20 -emit-pch -o /dev/shm/ayzhao
  _llvm/llvm-project/build/tools/clang/test/PCH/Output/cxx_paren_init.cpp.tmp /llvm-project/clang/test/PCH/cxx_paren_init.h
  + : 'RUN: at line 2'
  + /llvm-project/build/bin/clang -cc1 -internal-isystem /llvm-project/build/lib/clang/16.0.0/include -nostdsysteminc -x c++ -std=c++20 -include-pch /dev/shm/ayzhao
  _llvm/llvm-project/build/tools/clang/test/PCH/Output/cxx_paren_init.cpp.tmp -fsyntax-only -S -o -
  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: /llvm-project/build/bin/clang -cc1 -internal-isystem /llvm-project/build/lib/clang/16.0.0/include -nostdsysteminc -x c++ -std=c++20 -in
  clude-pch /llvm-project/build/tools/clang/test/PCH/Output/cxx_paren_init.cpp.tmp -fsyntax-only -S -o -
  1.      <eof> parser at end of file
  2.      /llvm-project/clang/test/PCH/cxx_paren_init.h:4:3: LLVM IR generation of declaration 'foo'
  3.      /llvm-project/clang/test/PCH/cxx_paren_init.h:4:3: Generating code for declaration 'foo'
   #0 0x000055ac3d88eeea llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /src/llvm_tmpfs/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:11
   #1 0x000055ac3d88f09b PrintStackTraceSignalHandler(void*) /src/llvm_tmpfs/llvm-project/llvm/lib/Support/Unix/Signals.inc:636:1
   #2 0x000055ac3d88d6e6 llvm::sys::RunSignalHandlers() /src/llvm_tmpfs/llvm-project/llvm/lib/Support/Signals.cpp:104:5
   #3 0x000055ac3d88f7c5 SignalHandler(int) /src/llvm_tmpfs/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
   #4 0x00007fbe3c83daf0 (/lib/x86_64-linux-gnu/libc.so.6+0x3daf0)
   #5 0x000055ac3dd9e32c clang::Stmt::getStmtClass() const /src/llvm_tmpfs/llvm-project/clang/include/clang/AST/Stmt.h:1166:44
   #6 0x000055ac3e40c735 clang::ImplicitValueInitExpr::classof(clang::Stmt const*) /src/llvm_tmpfs/llvm-project/clang/include/clang/AST/Expr.h:5527:30
   #7 0x000055ac3e40c715 llvm::isa_impl<clang::ImplicitValueInitExpr, clang::Expr, void>::doit(clang::Expr const&) /src/llvm_tmpfs/llvm-project/llvm/include/llvm/Support/Casting.h:64:46
   #8 0x000055ac3e40c6f3 llvm::isa_impl_cl<clang::ImplicitValueInitExpr, clang::Expr const*>::doit(clang::Expr const*) /src/llvm_tmpfs/llvm-project/llvm/include/llvm/Support/Casting.h:110:5
   #9 0x000055ac3e40c678 llvm::isa_impl_wrap<clang::ImplicitValueInitExpr, clang::Expr const*, clang::Expr const*>::doit(clang::Expr const* const&) /src/llvm_tmpfs/llvm-project/llvm/include/llvm/Support/Casting.h:137:5
  #10 0x000055ac3e40c652 llvm::isa_impl_wrap<clang::ImplicitValueInitExpr, clang::Expr const* const, clang::Expr const*>::doit(clang::Expr const* const&) /src/llvm_tmpfs/llvm-project/llvm/include/llvm/Support/Casting.h:127:5
  #11 0x000055ac3e40c625 llvm::CastIsPossible<clang::ImplicitValueInitExpr, clang::Expr const*, void>::isPossible(clang::Expr const* const&) /src/llvm_tmpfs/llvm-project/llvm/include/llvm/Support/Casting.h:255:5
  #12 0x000055ac3e40d3d2 llvm::CastInfo<clang::ImplicitValueInitExpr, clang::Expr* const, void>::isPossible(clang::Expr* const&) /src/llvm_tmpfs/llvm-project/llvm/include/llvm/Support/Casting.h:510:5
  #13 0x000055ac3e40d385 bool llvm::isa<clang::ImplicitValueInitExpr, clang::Expr*>(clang::Expr* const&) /src/llvm_tmpfs/llvm-project/llvm/include/llvm/Support/Casting.h:549:3
  #14 0x000055ac3e4088ac (anonymous namespace)::AggExprEmitter::EmitInitializationToLValue(clang::Expr*, clang::CodeGen::LValue) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:1536:44
  #15 0x000055ac3e402d1e (anonymous namespace)::AggExprEmitter::VisitCXXParenListInitExpr(clang::CXXParenListInitExpr*) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:1628:5
  #16 0x000055ac3e3fe04d clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) /src/llvm_tmpfs/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:877:1
  #17 0x000055ac3e3fba35 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:108:3
  #18 0x000055ac3e40a9ed (anonymous namespace)::AggExprEmitter::VisitCastExpr(clang::CastExpr*) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:864:5
  #19 0x000055ac3e40992d clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::VisitExplicitCastExpr(clang::ExplicitCastExpr*) /src/llvm_tmpfs/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:973:1
  #20 0x000055ac3e403c1d clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::VisitCXXFunctionalCastExpr(clang::CXXFunctionalCastExpr*) /src/llvm_tmpfs/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:989:1
  #21 0x000055ac3e3fe17f clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) /src/llvm_tmpfs/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:989:1
  #22 0x000055ac3e3fba35 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:108:3
  #23 0x000055ac3e3fb655 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:2046:1
  #24 0x000055ac3dfab89b clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGStmt.cpp:0:7
  #25 0x000055ac3dfa8491 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGStmt.cpp:153:75
  #26 0x000055ac3dfb1e5f clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CGStmt.cpp:496:3
  #27 0x000055ac3df8295d clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1239:5
  #28 0x000055ac3df83732 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1448:3
  #29 0x000055ac3de1cd02 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5321:3
  #30 0x000055ac3de13639 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3596:12
  #31 0x000055ac3de18b3a clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3337:5
  #32 0x000055ac3de11d50 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:6180:5
  #33 0x000055ac3ef4e7b0 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:188:73
  #34 0x000055ac3ef470e0 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:232:12
  #35 0x000055ac3ef4724b clang::BackendConsumer::HandleInterestingDecl(clang::DeclGroupRef) /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:260:5
  #36 0x000055ac3f013cc3 clang::ASTReader::PassInterestingDeclToConsumer(clang::Decl*) /src/llvm_tmpfs/llvm-project/clang/lib/Serialization/ASTReader.cpp:7740:1
  #37 0x000055ac3f0ebeba clang::ASTReader::PassInterestingDeclsToConsumer() /src/llvm_tmpfs/llvm-project/clang/lib/Serialization/ASTReaderDecl.cpp:3965:3
  #38 0x000055ac3f013e27 clang::ASTReader::StartTranslationUnit(clang::ASTConsumer*) /src/llvm_tmpfs/llvm-project/clang/lib/Serialization/ASTReader.cpp:0:5
  #39 0x000055ac417efb74 clang::ParseAST(clang::Sema&, bool, bool) /src/llvm_tmpfs/llvm-project/clang/lib/Parse/ParseAST.cpp:151:20
  #40 0x000055ac3ed606ac clang::ASTFrontendAction::ExecuteAction() /src/llvm_tmpfs/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1164:1
  #41 0x000055ac3ef432f4 clang::CodeGenAction::ExecuteAction() /src/llvm_tmpfs/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1145:5
  #42 0x000055ac3ed600ac clang::FrontendAction::Execute() /src/llvm_tmpfs/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1059:7
  #43 0x000055ac3ec8f16c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /src/llvm_tmpfs/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1043:23
  #44 0x000055ac3ef2c007 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /src/llvm_tmpfs/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:266:8
  #45 0x000055ac3b82a5e0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /src/llvm_tmpfs/llvm-project/clang/tools/driver/cc1_main.cpp:250:13
  #46 0x000055ac3b81c49c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /src/llvm_tmpfs/llvm-project/clang/tools/driver/driver.cpp:316:5
  #47 0x000055ac3b81b325 clang_main(int, char**) /src/llvm_tmpfs/llvm-project/clang/tools/driver/driver.cpp:388:5
  #48 0x000055ac3b84a8b2 main /src/llvm_tmpfs/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:11:35
  #49 0x00007fbe3c82920a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  #50 0x00007fbe3c8292bc call_init ./csu/../csu/libc-start.c:128:20
  #51 0x00007fbe3c8292bc __libc_start_main ./csu/../csu/libc-start.c:376:5
  #52 0x000055ac3b81aba1 _start (/llvm-project/build/bin/clang+0x54d9ba1)
  /llvm-project/build/tools/clang/test/PCH/Output/cxx_paren_init.cpp.script: line 2: 1747518 Segmentation fault      /llvm-project/build/bin/clang -cc1 -internal-is
  ystem /llvm-project/build/lib/clang/16.0.0/include -nostdsysteminc -x c++ -std=c++20 -include-pch /llvm-project/build/tools/clang/test/PCH/Output/cxx_paren_init.c
  pp.tmp -fsyntax-only -S -o -
  
  --
  
  ********************
  ********************
  Failed Tests (1):
    Clang :: PCH/cxx_paren_init.cpp
  
  
  Testing Time: 48.40s
    Failed: 1

I'm currently looking into this - I suspect it has to do with `CXXParenListInitExpr` storing all it's subexpressions in an `llvm::TrailingObjects` base class, but I have yet to confirm one way or another.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129531/new/

https://reviews.llvm.org/D129531



More information about the cfe-commits mailing list