LLVM infrastructure provides numerous interfaces to meet various requirements. However, lots of interfaces lack clear documents and example code. It is time-consuming for newcomers, including me, to find the ideal APIs and figure out their usage. To tackle this, I will write a series of articles that contain LLVM Interface in titles focusing on the useful APIs for program analysis. The contents of them will be short and concentrate more on concrete use cases than internal principles.
在很多博客中,在和其他人的交流中,我常常听到这样描述clang和LLVM:clang是一个编译器前端,生成中间文件交给LLVM处理。依我来看,这样说是不准确的。
LLVM中提供了一组便捷好用的命令行参数处理接口,本文针对不同的场景介绍如何使用它们。
Static analysis is often assigned to LLVM infrastructure for its rich interfaces for manipulating codebase. However, I leveraged tree-sitter frequently to perform static analysis on C code recently. After implementing some fundamental analyses (such as CFG, call graph, slicing, and so on), I further constructed some advanced methods. I dug out many new bugs in OpenSSL and Linux kernel. After experiencing it first hand, I think tree-sitter is enough to cope with lightweight code analysis such as code searching-like tasks (Weggli does achieve this by tree-sitter).