[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [cdt-dev] Mapping a name to include statement
|
A short note on the problem you defined:
- a reference in a source-file may be declared multiple times, so there
is
no mapping from references to a declaration, however each reference
has
a list of declarations.
- a header file indirectly included can be included via different paths
through
the graph of inclusions. So you cannot map a declaration to a single
inclusion
statement, however each declaration can be associated with a list of
inclusion-
statements.
For this sort of analysis you could purly rely on the index, you can
follow the
include-hierarchy and you can find all declarations for a reference.
Here is
what you need:
* IIndex.findIncludes(IIndexFile)
* IIndex.findBinding(IName)
* IIndex.findNames(IBinding)
* IIndexName.getFile()
Markus.
> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Dmitry Smirnov
> Sent: Thursday, October 30, 2008 4:57 PM
> To: CDT General developers list.
> Subject: [cdt-dev] Mapping a name to include statement
> Importance: Low
>
> 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
>