如何从 Objective-C 代码中提取 AST? [英] How to extract AST from Objective-C code?

查看:26
本文介绍了如何从 Objective-C 代码中提取 AST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要分析Objective-C静态代码,主要是AST,在查看可能的工具后发现LLVM的Clang工具可以转储AST,所以我用终端用这个命令测试它:

I need to analyze Objective-C static code, mainly AST, after looking into the possible tools I found out that Clang tool from LLVM can dump the AST, so I used the terminal to test it using this command:

clang -cc1 -ast-dump ~/SomeTest.m

但我收到此错误:

In file included from /Users/myusername/SomeTest.m:9:
/Users/myusername/SomeTest.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
        ^
typedef __int128_t __int128_t;
typedef __uint128_t __uint128_t;
typedef SEL *SEL;
typedef id id;
typedef Class *Class;
struct __va_list_tag {
    unsigned int gp_offset;
    unsigned int fp_offset;
    void *overflow_arg_area;
    void *reg_save_area;
};
typedef struct __va_list_tag __va_list_tag;
typedef __va_list_tag __builtin_va_list[1];
@interface just4testViewController@end
@implementation just4testViewController
- (void) dealloc (CompoundStmt 0x7f86b183b110 </Users/myusername/SomeTest.m:14:1, line:16:1>)


- (void) didReceiveMemoryWarning (CompoundStmt 0x7f86b183b2a0 </Users/myusername/SomeTest.m:19:1, line:24:1>)


- (void) viewDidUnload (CompoundStmt 0x7f86b183b430 </Users/myusername/SomeTest.m:37:1, line:41:1>)


- (id) shouldAutorotateToInterfaceOrientation:(id)interfaceOrientation (CompoundStmt 0x7f86b183b648 </Users/myusername/SomeTest.m:44:1, line:47:1>)


@end
1 error generated.

知道为什么我会得到这个吗?我不介意使用任何工具从 Objective-C 代码中提取 AST,只要它可靠并提供输出文档

Any idea why I'm getting this? I don't mind using any tool to extract AST from Objective-C code as long as it is reliable and provide documentation for the output

推荐答案

编译器没有找到 UIKit 框架.你必须告诉它使用它:

The compiler does not find the UIKit framework. You have to tell it to use it:

clang -framework UIKit -cc1 -ast-dump ~/SomeTest.m

这篇关于如何从 Objective-C 代码中提取 AST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆