[all-commits] [llvm/llvm-project] 986d0d: [Clang] Fix AST dump for {CXXDefaultArgExpr, CXXDe...

yronglin via All-commits all-commits at lists.llvm.org
Fri Apr 12 08:17:51 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 986d0dba85f3239671c5151d9817b73de08664a0
      https://github.com/llvm/llvm-project/commit/986d0dba85f3239671c5151d9817b73de08664a0
  Author: yronglin <yronglin777 at gmail.com>
  Date:   2024-04-12 (Fri, 12 Apr 2024)

  Changed paths:
    M clang/include/clang/AST/ASTNodeTraverser.h
    M clang/include/clang/AST/JSONNodeDumper.h
    M clang/lib/AST/JSONNodeDumper.cpp
    M clang/lib/AST/TextNodeDumper.cpp
    A clang/test/AST/ast-dump-default-arg-json.cpp
    A clang/test/AST/ast-dump-default-init-json.cpp
    A clang/test/AST/ast-dump-default-init.cpp
    M clang/test/AST/ast-dump-for-range-lifetime.cpp
    M clang/unittests/AST/ASTTraverserTest.cpp

  Log Message:
  -----------
  [Clang] Fix AST dump for {CXXDefaultArgExpr, CXXDefaultInitExpr} (#88269)

This PR fix a AST dump issue since
https://github.com/llvm/llvm-project/pull/80001

When Clang dumps `CXXDefaultArgExpr`/`CXXDefaultInitExpr`, there has no
recursively dump the complete `CXXDefaultArgExpr`/`CXXDefaultInitExpr`.

Since this PR, Clang will recursively dump a
`CXXDefaultArgExpr`/`CXXDefaultInitExpr` node, even if the node has no
rewritten init.

*Consider*:
```
struct A {
  int arr[1];
};

struct B {
  const A &a = A{{0}};
};

void test() {
  B b{};
}
```

*Before*:
```
`-FunctionDecl <line:9:1, line:11:1> line:9:6 test 'void ()'
  `-CompoundStmt <col:13, line:11:1>
    `-DeclStmt <line:10:3, col:8>
      `-VarDecl <col:3, col:7> col:5 b 'B' listinit
        `-InitListExpr <col:6, col:7> 'B'
          `-CXXDefaultInitExpr <col:7> 'const A' lvalue has rewritten init
            `-ExprWithCleanups <line:6:16, col:21> 'const A' lvalue
```

*After*:
```
`-FunctionDecl 0x15a9455a8 <line:9:1, line:11:1> line:9:6 test 'void ()'
  `-CompoundStmt 0x15a945850 <col:13, line:11:1>
    `-DeclStmt 0x15a945838 <line:10:3, col:8>
      `-VarDecl 0x15a945708 <col:3, col:7> col:5 b 'B' listinit
        `-InitListExpr 0x15a9457b0 <col:6, col:7> 'B'
          `-CXXDefaultInitExpr 0x15a9457f8 <col:7> 'const A' lvalue has rewritten init
            `-ExprWithCleanups 0x15a945568 <line:6:16, col:21> 'const A' lvalue
              `-MaterializeTemporaryExpr 0x15a945500 <col:16, col:21> 'const A' lvalue extended by Field 0x15a945160 'a' 'const A &'
                `-ImplicitCastExpr 0x15a9454e8 <col:16, col:21> 'const A' <NoOp>
                  `-CXXFunctionalCastExpr 0x15a9454c0 <col:16, col:21> 'A' functional cast to A <NoOp>
                    `-InitListExpr 0x15a9452c0 <col:17, col:21> 'A'
                      `-InitListExpr 0x15a945308 <col:18, col:20> 'int[1]'
                        `-IntegerLiteral 0x15a945210 <col:19> 'int' 0
```

---------

Signed-off-by: yronglin <yronglin777 at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list