Anil Altinay
Anil Altinay

Reputation: 81

AST of whole program

I would like to do transformations on AST of a c program but I need to have access to all ASTs created for the program to do right changes. LLVM processes one translation unit at a time and because of it, I do not have access to AST of all the translation units at the same time. Do you have any suggestion how I can access all the ASTs created for a program, do analysis on the ASTs and do modifications on the ASTs?

As a summary:

  1. I need to have access to ASTs of the program at the same time.
  2. Do analysis on ASTs.
  3. Modify ASTs based on my analysis and create llvm IR from modified ASTs.

Upvotes: 2

Views: 346

Answers (1)

keyboardsmoke
keyboardsmoke

Reputation: 156

You can try using llvm-link on all of your generated .ll files (from clang with -S -emit-llvm) to create one large llvm source.

You have access to everything at that point.

Upvotes: 1

Related Questions