Are there any helper methods to traverse the AST, basic blocks etc. generated by LLVM compiler for a C code ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re trying to load a module (from a .bc file compiled from a .c file by
clang -emit-llvm) and traverse its functions, basic blocks, etc., then you might want to start with thellvm::Moduleclass. It has functions for iterating through global variables and functions. Then thellvm::Functionclass has functions for iterating through basic blocks. Then thellvm::BasicBlockclass has functions for iterating through instructions.Or if you’d prefer, you can traverse the AST structure created by Clang. Here’s some example code: http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/.