[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Mapping a name to include statement
|
Good question. I'm interested in the answer for the opposite reason,
to find unnecessarily included files so the include statements can be
removed. It should be possible to open the include file as a separate
compilation unit to compare its declarations to the target file's, but
hopefully there is an easier alternative.
Tom
On Thu, Oct 30, 2008 at 8:56 AM, Dmitry Smirnov <divis1969@xxxxxxxxx> wrote:
> 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
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>