Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Mapping a name to include statement


I need to perform some analisys of inclusions in C files. Particulary,
I need to find out whether any declaration or definition of top-level
included file (or its sub-includes) is used in the translation unit.

What is the best way for this?

I'm going to visit all the names in the root translation unit, find
all the declarations and definitions of this name (with
getDeclarationsInAST()) and check whether these declarations are from

The last step is something unclear for me.
How can figure out that some name is declared/defined in the context
of top-level include?

Some small example (in case my description was unclear)
int value;

#include "test.h"


int main()
  value = 10;

I need to figure out that 'value' was defined in context of test2.h inclusion.


Back to the top