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

Hi,

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
includes.

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)
test.h:
------------------
int value;

test2.h
-----------------------
#include "test.h"

test.c
---------------------------

int main()
{
  value = 10;
}

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

Dmitry


Back to the top