cae7291

Parsing C struct members with clang AST dump

Jun 12th, 2024
1,323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. ==> main.c <==
  2. struct A {
  3. int a;
  4. int b;
  5. double barge;
  6. };
  7.  
  8. struct B { int x; int y; struct A st; };
  9.  
  10. ==> command <==
  11. clang -Xclang -ast-dump -fsyntax-only -fno-color-diagnostics main.c > main.ast
  12. ==> main.ast <==
  13. TranslationUnitDecl 0x56335152e758 <<invalid sloc>> <invalid sloc>
  14. |-TypedefDecl 0x56335152eff0 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
  15. | `-BuiltinType 0x56335152ecf0 '__int128'
  16. |-TypedefDecl 0x56335152f058 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
  17. | `-BuiltinType 0x56335152ed10 'unsigned __int128'
  18. |-TypedefDecl 0x56335152f318 <<invalid sloc>> <invalid sloc> implicit __NSConstantString 'struct __NSConstantString_tag'
  19. | `-RecordType 0x56335152f130 'struct __NSConstantString_tag'
  20. | `-Record 0x56335152f0a8 '__NSConstantString_tag'
  21. |-TypedefDecl 0x56335152f3b0 <<invalid sloc>> <invalid sloc> implicit __builtin_ms_va_list 'char *'
  22. | `-PointerType 0x56335152f370 'char *'
  23. | `-BuiltinType 0x56335152e7f0 'char'
  24. |-TypedefDecl 0x563351568aa8 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list 'struct __va_list_tag [1]'
  25. | `-ConstantArrayType 0x563351568a50 'struct __va_list_tag [1]' 1
  26. | `-RecordType 0x5633515688d0 'struct __va_list_tag'
  27. | `-Record 0x563351568840 '__va_list_tag'
  28. |-RecordDecl 0x563351568af8 <main.c:1:1, line:5:1> line:1:8 struct A definition
  29. | |-FieldDecl 0x563351568bb8 <line:2:2, col:6> col:6 a 'int'
  30. | |-FieldDecl 0x563351568c18 <line:3:2, col:6> col:6 b 'int'
  31. | `-FieldDecl 0x563351568c78 <line:4:2, col:9> col:9 barge 'double'
  32. `-RecordDecl 0x563351568cc0 <line:7:1, col:39> col:8 struct B definition
  33. |-FieldDecl 0x563351568d88 <col:12, col:16> col:16 x 'int'
  34. |-FieldDecl 0x563351568de8 <col:19, col:23> col:23 y 'int'
  35. `-FieldDecl 0x563351568e88 <col:26, col:35> col:35 st 'struct A':'struct A'
  36.  
Advertisement
Add Comment
Please, Sign In to add comment