[cfe-dev] cfe-dev Digest, Vol 93, Issue 97

Aleksei Sidorin a.sidorin at samsung.com
Wed Mar 25 12:15:09 PDT 2015


Hello Bhargava,

Pointers to Decl are unique in the translation unit since Decls are part 
of ASTContext (and are created with its allocator) and each Decl belongs 
to only one ASTContext. However, I don't think it is a good idea to use 
them as GDM keys. The reason for using tags is a need to distinguish 
data that belong to different checkers. A static variable (which is 
checker-private) identifies a checker uniquely, but a 'Decl *' doesn't 
since multiple checkers may use it as a key.
> Hi, I am writing a Generic Data Map (GDM) client, a checker basically. 
> Comment in ProgramState.h reads:
>> The typical way that clients generate unique tags are by taking the address of a static variable.
> Question: Can one use pointer to Decl as a GDM tag? In other words, are
> Decl pointers in a translation unit unique?
>
> Code perusal reveals that Decls belong to an object instance (possibly
> AnalysisConsumer). So, in theory they are non-unique and should not be
> used as a GDM tag. Is that correct?
>
> Thanks and Regards,
> Bhargava

-- 
Best regards,
Aleksei Sidorin
Software Engineer,
IMSWL-IMCG, SRR, Samsung Electronics




More information about the cfe-dev mailing list