4

How to get abstract syntax tree of a C program with GCC?

I'm trying to automatically insert OpenMP pragmas to the input C program. I need to analyze nested for loops to find dependencies so that I can insert appropriate OpenMP pragmas.

So basically what I want to traverse and analyze the abstract syntax tree of the input C program.

How do I achieve this?

1
  • 3
    Look at the plugin feature of gcc if you absolutely want to use gcc, but I think looking at clang is a better option. (BTW, I fail to see how this is Unix or Linux related). Commented Feb 28, 2013 at 12:32

1 Answer 1

1

Use clang with -ast-print option, this is the cleanest way to do it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.