Skip to content

Conversation

@changkhothuychung
Copy link

@changkhothuychung changkhothuychung commented Apr 22, 2025

Given this program

using info = decltype(^^int);

constexpr int f() { return 42; }
template <int T> constexpr int g() { return T; }



int Test() {
    int x = 11;
    int y = [:^^x:];

    int w = [:^^f:]();
    int z = [:^^g<42>:]();
}

Generated ast dump is

FunctionDecl 0x555e579f0118 <clang/test/Reflection/ast-dump-splice-specifier.cpp:18:1, line:49:1> line:18:6 Test 'void ()'
`-CompoundStmt 0x555e57a0ca28 <col:13, line:49:1>
  |-DeclStmt 0x555e579f0298 <line:19:5, col:15>
  | `-VarDecl 0x555e579f01f8 <col:5, col:13> col:9 used x 'int' cinit
  |   `-IntegerLiteral 0x555e579f0260 <col:13> 'int' 11
  |-DeclStmt 0x555e579f0468 <line:20:5, col:20>
  | `-VarDecl 0x555e579f02d0 <col:5, col:18> col:9 y 'int' cinit
  |   `-ImplicitCastExpr 0x555e579f0438 <col:13, col:18> 'int' <LValueToRValue>
  |     `-CXXSpliceExpr 0x555e579f0408 <col:13, col:18> 'int' lvalue
  |       |-SpliceSpecifier 0x555e579f03c8 <col:13, col:18>
  |       | `-CXXReflectExpr 0x555e579f0358 <col:15, col:17> 'meta::info'
  |       `-DeclRefExpr 0x555e579f03e8 <col:13> 'int' lvalue Var 0x555e579f01f8 'x' 'int'
  |-DeclStmt 0x555e579f0690 <line:31:5, col:22>
  | `-VarDecl 0x555e579f04a0 <col:5, col:21> col:9 w 'int' cinit
  |   `-CallExpr 0x555e579f0658 <col:13, col:21> 'int'
  |     `-ImplicitCastExpr 0x555e579f0640 <col:13, col:18> 'int (*)()' <FunctionToPointerDecay>
  |       `-CXXSpliceExpr 0x555e579f05d8 <col:13, col:18> 'int ()' lvalue
  |         |-SpliceSpecifier 0x555e579f0598 <col:13, col:18>
  |         | `-CXXReflectExpr 0x555e579f0528 <col:15, col:17> 'meta::info'
  |         `-DeclRefExpr 0x555e579f05b8 <col:13> 'int ()' lvalue Function 0x555e579efcd0 'f' 'int ()'
  `-DeclStmt 0x555e57a0ca10 <line:40:5, col:26>
    `-VarDecl 0x555e579f06c8 <col:5, col:25> col:9 z 'int' cinit
      `-CallExpr 0x555e57a0c9d8 <col:13, col:25> 'int'
        `-ImplicitCastExpr 0x555e57a0c9c0 <col:13, col:22> 'int (*)()' <FunctionToPointerDecay>
          `-CXXSpliceExpr 0x555e57a0c990 <col:13, col:22> 'int ()' lvalue
            |-SpliceSpecifier 0x555e57a0c8e0 <col:13, col:22>
            | `-CXXReflectExpr 0x555e57a0c870 <col:15, col:17> 'meta::info'
            `-DeclRefExpr 0x555e57a0c900 <col:13> 'int ()' lvalue Function 0x555e57a0c600 'g' 'int ()'
            ```

Signed-off-by: changkhothuychung <[email protected]>
@changkhothuychung changkhothuychung force-pushed the ast-dump-splice-specifier branch from 754a0b9 to b44a31d Compare April 22, 2025 19:10
@changkhothuychung changkhothuychung force-pushed the ast-dump-splice-specifier branch from fc54703 to 7954551 Compare April 28, 2025 14:23
@changkhothuychung changkhothuychung changed the title ast dump for splice specifier ast dump for splice specifier and reflection splice type Apr 28, 2025
@changkhothuychung
Copy link
Author

since we dont need to add code to ASTNodeTraverser.h now, I removed the code in JSONNodeDumper and just do TextNodeDumper now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant