[cfe-dev] Getting the unique ID for a clang::Decl

Mikhail Ramalho via cfe-dev cfe-dev at lists.llvm.org
Fri Aug 12 15:29:54 PDT 2016


+1 to that.

Sometime ago, I tried to get an unique ID generated by clang but couldn't
find any .get_whatever() to solve the problem.

I ended up using the pointer's address as an ID, as it seems to be unique.

For example:

const clang::TagDecl &tag;
std::size_t address = reinterpret_cast<std::size_t>(tag.getFirstDecl());

It's basically the same code for all decls. I use getFirstDecl to avoid
having different IDs for the same decl.

If there is a better way to do that, I would like to know too.

Thank you,


2016-08-12 17:29 GMT+01:00 Raboudi Amel via cfe-dev <cfe-dev at lists.llvm.org>
:

> Hi All,
>
> I am using clang C++ API's to parse a source code and then generates its
> AST.
> I need for that to find a way to uniquely identify my AST declarations.
>
> refering to this Doxygen Documentation:  http://clang.llvm.org/
> doxygen/classclang_1_1Decl.html#a57cf20fc798dae7f5fba3e21d455df6b
>
> the getGlobalID() function must do the task, but, it returns nothing.
>
> Can anyone helps me to find this unique ID in clang's C++ APIs?
>
> Thank you !
> Amel
>
>
>>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>


-- 

Mikhail Ramalho.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160812/5a3f9091/attachment.html>


More information about the cfe-dev mailing list