libclang 不发出某些 AST 节点
libclang not emitting certain AST nodes
我稍后会在文件中使用 go-clang library to parse the following C file: aac.c. For some reason when I run the file through clang and dump the AST, I don't get AST output for certain functions. For example, the C file contains a forward declaration of aac_ioctl_send_raw_srb
and the actual definition。
鉴于此,我希望在输出中看到两个 AST 节点,但只有一个 FuncDecl
(前向声明)被转储:
clang -Xclang -ast-dump -fsyntax-only aac.c | grep "aac_ioctl_send_raw_srb" | wc -l
aac.c:38:10: fatal error: 'opt_aac.h' file not found
#include "opt_aac.h"
^
1 error generated.
1 <--- wc output
(忽略错误)
我使用 go-clang 库从我自己的应用程序中解析 C 文件得到了相同的结果。有没有解释为什么不转储定义?
我在 #llvm
IRC 中得到了一些帮助,有人建议错误实际上是 导致了这个问题。即使正在发出 other 个节点,LLVM 可能只是忽略它认为需要驻留在丢失的 #include
s 中的信息的节点。
我修复了包含路径,果然发出了我正在寻找的节点。
我稍后会在文件中使用 go-clang library to parse the following C file: aac.c. For some reason when I run the file through clang and dump the AST, I don't get AST output for certain functions. For example, the C file contains a forward declaration of aac_ioctl_send_raw_srb
and the actual definition。
鉴于此,我希望在输出中看到两个 AST 节点,但只有一个 FuncDecl
(前向声明)被转储:
clang -Xclang -ast-dump -fsyntax-only aac.c | grep "aac_ioctl_send_raw_srb" | wc -l
aac.c:38:10: fatal error: 'opt_aac.h' file not found
#include "opt_aac.h"
^
1 error generated.
1 <--- wc output
(忽略错误)
我使用 go-clang 库从我自己的应用程序中解析 C 文件得到了相同的结果。有没有解释为什么不转储定义?
我在 #llvm
IRC 中得到了一些帮助,有人建议错误实际上是 导致了这个问题。即使正在发出 other 个节点,LLVM 可能只是忽略它认为需要驻留在丢失的 #include
s 中的信息的节点。
我修复了包含路径,果然发出了我正在寻找的节点。