Windows Clang Ast 转储
Windows Clang Ast Dump
我正在 Windows 10 服务器上工作,我安装了 clang 7.0.0(来自 llvm),我正在尝试获取抽象语法树 (ast)在 C++ 中使用模板的几个程序,但是,我似乎无法获得完整的 ast。下面的命令是我在我的 windows 服务器和我的 运行ning linux 个人笔记本电脑上使用的,并且有 clang 7.0.0.
clang++ -c -fno-color-diagnostics -Xclang -ast-dump input.cpp > output.txt
文件 "input.cpp" 是一个简单的模拟模板 class:
template <class T>
class Thing {
private:
T a_ {};
public:
Thing() = default;
void set_thing(T a) { a_ = a; }
T& get_thing() { return a_; }
};
在我的 windows 服务器上,模板 class 的输出如下所示:
`-ClassTemplateDecl 0x21dcd03f4c8 <input.cpp:1:1, line:12:1> line:2:7 Thing
|-TemplateTypeParmDecl 0x21dcd03f378 <line:1:11, col:17> col:17 referenced class depth 0 index 0 T
`-CXXRecordDecl 0x21dcd03f430 <line:2:1, line:12:1> line:2:7 class Thing definition
|-DefinitionData standard_layout trivially_copyable has_user_declared_ctor can_const_default_init
| |-DefaultConstructor exists
| |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-CXXRecordDecl 0x21dcd03f730 <col:1, col:7> col:7 implicit referenced class Thing
|-AccessSpecDecl 0x21dcd03f7c8 <line:4:1, col:8> col:1 private
|-FieldDecl 0x21dcd03f800 <line:5:2, col:8> col:4 a_ 'T'
| `-InitListExpr 0x21dcd03fd30 <col:7, col:8> 'void'
|-AccessSpecDecl 0x21dcd03f850 <line:6:1, col:7> col:1 public
|-CXXConstructorDecl 0x21dcd03f920 <line:7:2, col:18> col:2 Thing<T> 'void ()' default
|-CXXMethodDecl 0x21dcd03fae0 <line:8:2, col:20> col:7 set_thing 'void (T)'
| |-ParmVarDecl 0x21dcd03f9e0 <col:17, col:19> col:19 a 'T'
| `-<<<NULL>>>
`-CXXMethodDecl 0x21dcd03fc70 <line:11:2, col:15> col:5 get_thing 'T &()'
`-<<<NULL>>>
在我个人的笔记本电脑上,输出如下所示:
`-ClassTemplateDecl 0x64dfc38 <input.cpp:1:1, line:12:1> line:2:7 Thing
|-TemplateTypeParmDecl 0x64dfae8 <line:1:11, col:17> col:17 referenced class depth 0 index 0 T
`-CXXRecordDecl 0x64dfba0 <line:2:1, line:12:1> line:2:7 class Thing definition
|-DefinitionData standard_layout trivially_copyable has_user_declared_ctor can_const_default_init
| |-DefaultConstructor exists
| |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-CXXRecordDecl 0x64dfea0 <col:1, col:7> col:7 implicit referenced class Thing
|-AccessSpecDecl 0x64dff38 <line:4:1, col:8> col:1 private
|-FieldDecl 0x64dff70 <line:5:2, col:8> col:4 referenced a_ 'T'
| `-InitListExpr 0x64e0490 <col:7, col:8> 'void'
|-AccessSpecDecl 0x64dffb8 <line:6:1, col:7> col:1 public
|-CXXConstructorDecl 0x64e0080 <line:7:2, col:18> col:2 Thing<T> 'void ()' default
|-CXXMethodDecl 0x64e0240 <line:8:2, line:10:2> line:8:7 set_thing 'void (T)'
| |-ParmVarDecl 0x64e0140 <col:17, col:19> col:19 referenced a 'T'
| `-CompoundStmt 0x64e0570 <col:22, line:10:2>
| `-BinaryOperator 0x64e0548 <line:9:3, col:8> '<dependent type>' '='
| |-MemberExpr 0x64e04e8 <col:3> 'T' lvalue ->a_ 0x64dff70
| | `-CXXThisExpr 0x64e04d0 <col:3> 'Thing<T> *' this
| `-DeclRefExpr 0x64e0520 <col:8> 'T' lvalue ParmVar 0x64e0140 'a' 'T'
`-CXXMethodDecl 0x64e03d0 <line:11:2, col:30> col:5 get_thing 'T &()'
`-CompoundStmt 0x64e05f0 <col:17, col:30>
`-ReturnStmt 0x64e05d8 <col:19, col:26>
`-MemberExpr 0x64e05a0 <col:26> 'T' lvalue ->a_ 0x64dff70
`-CXXThisExpr 0x64e0588 <col:26> 'Thing<T> *' this
当我 运行 windows 上的命令时,我的注意力集中在树的 "NULL" 节点上,但在我的笔记本电脑上看不到。我想知道我可以采取什么措施来获得 windows 上的后者输出。我尝试过其他版本,如 clang 6.0.0,但没有成功。我也曾尝试使用命令 clang++ -cc1 -ast-dump input.cpp,但是,它在引用 here 时存在问题。
注意:我使用html代码片段来格式化ast树,因为它能够最好地格式化它。
clang++ -c -fno-delayed-template-parsing -fno-color-diagnostics -Xclang -ast-dump input.cpp
我正在 Windows 10 服务器上工作,我安装了 clang 7.0.0(来自 llvm),我正在尝试获取抽象语法树 (ast)在 C++ 中使用模板的几个程序,但是,我似乎无法获得完整的 ast。下面的命令是我在我的 windows 服务器和我的 运行ning linux 个人笔记本电脑上使用的,并且有 clang 7.0.0.
clang++ -c -fno-color-diagnostics -Xclang -ast-dump input.cpp > output.txt
文件 "input.cpp" 是一个简单的模拟模板 class:
template <class T>
class Thing {
private:
T a_ {};
public:
Thing() = default;
void set_thing(T a) { a_ = a; }
T& get_thing() { return a_; }
};
在我的 windows 服务器上,模板 class 的输出如下所示:
`-ClassTemplateDecl 0x21dcd03f4c8 <input.cpp:1:1, line:12:1> line:2:7 Thing
|-TemplateTypeParmDecl 0x21dcd03f378 <line:1:11, col:17> col:17 referenced class depth 0 index 0 T
`-CXXRecordDecl 0x21dcd03f430 <line:2:1, line:12:1> line:2:7 class Thing definition
|-DefinitionData standard_layout trivially_copyable has_user_declared_ctor can_const_default_init
| |-DefaultConstructor exists
| |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-CXXRecordDecl 0x21dcd03f730 <col:1, col:7> col:7 implicit referenced class Thing
|-AccessSpecDecl 0x21dcd03f7c8 <line:4:1, col:8> col:1 private
|-FieldDecl 0x21dcd03f800 <line:5:2, col:8> col:4 a_ 'T'
| `-InitListExpr 0x21dcd03fd30 <col:7, col:8> 'void'
|-AccessSpecDecl 0x21dcd03f850 <line:6:1, col:7> col:1 public
|-CXXConstructorDecl 0x21dcd03f920 <line:7:2, col:18> col:2 Thing<T> 'void ()' default
|-CXXMethodDecl 0x21dcd03fae0 <line:8:2, col:20> col:7 set_thing 'void (T)'
| |-ParmVarDecl 0x21dcd03f9e0 <col:17, col:19> col:19 a 'T'
| `-<<<NULL>>>
`-CXXMethodDecl 0x21dcd03fc70 <line:11:2, col:15> col:5 get_thing 'T &()'
`-<<<NULL>>>
在我个人的笔记本电脑上,输出如下所示:
`-ClassTemplateDecl 0x64dfc38 <input.cpp:1:1, line:12:1> line:2:7 Thing
|-TemplateTypeParmDecl 0x64dfae8 <line:1:11, col:17> col:17 referenced class depth 0 index 0 T
`-CXXRecordDecl 0x64dfba0 <line:2:1, line:12:1> line:2:7 class Thing definition
|-DefinitionData standard_layout trivially_copyable has_user_declared_ctor can_const_default_init
| |-DefaultConstructor exists
| |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-CXXRecordDecl 0x64dfea0 <col:1, col:7> col:7 implicit referenced class Thing
|-AccessSpecDecl 0x64dff38 <line:4:1, col:8> col:1 private
|-FieldDecl 0x64dff70 <line:5:2, col:8> col:4 referenced a_ 'T'
| `-InitListExpr 0x64e0490 <col:7, col:8> 'void'
|-AccessSpecDecl 0x64dffb8 <line:6:1, col:7> col:1 public
|-CXXConstructorDecl 0x64e0080 <line:7:2, col:18> col:2 Thing<T> 'void ()' default
|-CXXMethodDecl 0x64e0240 <line:8:2, line:10:2> line:8:7 set_thing 'void (T)'
| |-ParmVarDecl 0x64e0140 <col:17, col:19> col:19 referenced a 'T'
| `-CompoundStmt 0x64e0570 <col:22, line:10:2>
| `-BinaryOperator 0x64e0548 <line:9:3, col:8> '<dependent type>' '='
| |-MemberExpr 0x64e04e8 <col:3> 'T' lvalue ->a_ 0x64dff70
| | `-CXXThisExpr 0x64e04d0 <col:3> 'Thing<T> *' this
| `-DeclRefExpr 0x64e0520 <col:8> 'T' lvalue ParmVar 0x64e0140 'a' 'T'
`-CXXMethodDecl 0x64e03d0 <line:11:2, col:30> col:5 get_thing 'T &()'
`-CompoundStmt 0x64e05f0 <col:17, col:30>
`-ReturnStmt 0x64e05d8 <col:19, col:26>
`-MemberExpr 0x64e05a0 <col:26> 'T' lvalue ->a_ 0x64dff70
`-CXXThisExpr 0x64e0588 <col:26> 'Thing<T> *' this
当我 运行 windows 上的命令时,我的注意力集中在树的 "NULL" 节点上,但在我的笔记本电脑上看不到。我想知道我可以采取什么措施来获得 windows 上的后者输出。我尝试过其他版本,如 clang 6.0.0,但没有成功。我也曾尝试使用命令 clang++ -cc1 -ast-dump input.cpp,但是,它在引用 here 时存在问题。
注意:我使用html代码片段来格式化ast树,因为它能够最好地格式化它。
clang++ -c -fno-delayed-template-parsing -fno-color-diagnostics -Xclang -ast-dump input.cpp