This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Access to unused global variable declarations from a plugin

On Thu, Jan 5, 2012 at 5:16 PM, David Malcolm <> wrote:
> I'm working on a GCC plugin which performs static analysis of Python
> extension code [1]
> In various places I need access to a VAR_DECL for various globals from C
> code, many of which potentially aren't used directly within the
> compilation unit. ?For example, I may need to reference this global:
> ? extern PyObject * PyExc_MemoryError;
> when reasoning about the possible exception objects that could have been
> set within a function, even if the code in question doesn't explicitly
> reference that global.
> Previously, I've been looking with the TRANSLATION_UNIT_DECL's block,
> and then looking within BLOCK_VARS().
> This works with 4.6.1, but doesn't work in 4.7 [2]; on debugging, it
> seems to have been broken by the fix for PR debug/51410:
> ?
> which seems to be slimming down the debuginfo by removing these decls.
> I suspect I was going about this the wrong way - so is there a good way
> to access VAR_DECLs for global variable declarations? (as opposed to
> *definitions*, which I'm able to access via "varpool_nodes").
> Previously I'd also tried looking them up via an identifier, but by the
> time my code runs the scope's binding from the identifier to the
> VAR_DECL has been lost.
> FWIW I'm tracking the breakage on my side as

Mere declarations are gone and not kept as you leave the frontends
domain.  You can probably access them in frontend specific ways
before cgraph_finalize_compilation_unit is called.


> Thanks
> Dave
> [1]
> [2] specifically, on Fedora's builds of GCC, with
> gcc-4.6.1-9.fc15.x86_64 and gcc-4.7.0-0.2.fc17.x86_64 respectively

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]