[cfe-dev] Decls are not synonyms for the symbols they represent
Nico Weber
nicolasweber at gmx.de
Wed Sep 17 13:06:11 PDT 2008
Hi,
On 17.09.2008, at 21:52, Ted Kremenek wrote:
>> For this example, I'd like to know why/when we care if all these
>> VarDecls refer to the same variable? Since each VarDecl is "extern",
>> it's the linkers job to bind the actual variable definition (which
>> isn't in this particular translation unit).
>
> Another example would be a client that wanted to rename 'x'. How
> would it know all of the declarations for the same variable? There
> are lots of cases where clients, looking the AST for a translation
> unit, want to know which declarations refer to the same thing.
How would that client work? As far as I understand, each translation
unit has its own AST, so this client needs some kind of linker that
merges information from several ASTs. For example:
a.c:
int a = 4;
/* use a somewhere below in file*/
b.c:
extern int a;
/* use a somewhere below file */
c.c:
extern int a;
/* use a somewhere below in file*/
If the tool should rename `a` to `importantCache` (or whatever), it
has to know which of a.c, b.c, and c.c belong to the same project and
only rename the `a`s in there. More information in a single
translation unit doesn't help here, some kind of linker is required.
Nico
More information about the cfe-dev
mailing list