================ @@ -850,11 +854,17 @@ class alignas(void *) Stmt { LLVM_PREFERRED_TYPE(ExprBitfields) unsigned : NumExprBits; - /// Whether this CXXDefaultInitExprBitfields rewrote its argument and stores - /// a copy. + /// Whether this CXXDefaultInitExpr rewrote its argument and stores + /// a copy, unlike HasRebuiltInit, when this flag is true, the argument may + /// be partial rebuilt. ---------------- yronglin wrote:
For example: ```c++ struct A {}; struct B { A a = A{}; }; B c{}, d{}; ``` ``` |-CXXRecordDecl 0x13f1289d8 <line:2:1, line:4:1> line:2:8 referenced struct B definition | |-DefinitionData pass_in_registers aggregate standard_layout trivially_copyable literal has_constexpr_non_copy_move_ctor can_const_default_init | | |-DefaultConstructor exists non_trivial constexpr needs_implicit defaulted_is_constexpr | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param | | |-MoveConstructor exists simple trivial needs_implicit | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param | | |-MoveAssignment exists simple trivial needs_implicit | | `-Destructor simple irrelevant trivial constexpr needs_implicit | |-CXXRecordDecl 0x13f128b10 <col:1, col:8> col:8 implicit struct B | `-FieldDecl 0x13f149808 <line:3:5, col:13> col:7 a 'A' | `-CXXFunctionalCastExpr 0x13f149aa0 <col:11, col:13> 'A' functional cast to A <NoOp> | `-InitListExpr 0x13f1498f0 <col:12, col:13> 'A' |-VarDecl 0x13f149b18 <line:6:1, col:5> col:3 c 'B' listinit | `-InitListExpr 0x13f149c10 <col:4, col:5> 'B' | `-CXXDefaultInitExpr 0x13f149c58 <col:5> 'A' has rewritten init | `-CXXFunctionalCastExpr 0x13f149aa0 <line:3:11, col:13> 'A' functional cast to A <NoOp> | `-InitListExpr 0x13f1498f0 <col:12, col:13> 'A' `-VarDecl 0x13f149ea0 <line:6:1, col:10> col:8 d 'B' listinit `-InitListExpr 0x13f149f48 <col:9, col:10> 'B' `-CXXDefaultInitExpr 0x13f149f90 <col:10> 'A' has rewritten init `-CXXFunctionalCastExpr 0x13f149aa0 <line:3:11, col:13> 'A' functional cast to A <NoOp> `-InitListExpr 0x13f1498f0 <col:12, col:13> 'A' ``` The sub-expr in `CXXDefaultInitExpr` will appears multiple times in the AST. We can't add the default argument if it's not rewritten because we could end up with the same expression appearing multiple times. https://github.com/llvm/llvm-project/pull/117437 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits