gpt4 book ai didi

objective-c - 如何从 Objective-C 代码中提取 AST?

转载 作者:太空狗 更新时间:2023-10-30 03:33:12 25 4
gpt4 key购买 nike

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

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,只要它可靠并为输出提供文档即可

最佳答案

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

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

关于objective-c - 如何从 Objective-C 代码中提取 AST?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10649594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com