How to obtain the "tree" of each if-condition in gcc plugin?

39 views Asked by At

I'm developing a plugin inside which I need to obtain the ast of parenthesized condition from an if in each function, the location_t of such if is also required, BTW.

From gcc source perspective, I can easily get what I want in c-parser.c by adding only one line:

static void
c_parser_if_statement (c_parser *parser, bool *if_p, vec<tree> *chain)
{
  ...

  loc = c_parser_peek_token (parser)->location;
  cond = c_parser_paren_condition (parser);
  
  My_Method(loc, cond); // new
  ...
}

However, I don't know how to acquire this from gcc plugin without modifying gcc source. I would appreciate it if anyone can help.

0

There are 0 answers