[cfe-dev] FieldDecl isReferenced() within a certain class?

Pedro Delgado Perez pedro.delgadoperez at mail.uca.es
Sat Apr 5 12:41:24 PDT 2014


 
Hi again,

I couldn't find a solution for this problem, but I was wondering if I could traverse a subset of classes looking for a "memberExpr" which is referencing a certain "fieldDecl".

Maybe I could use:
http://clang.llvm.org/doxygen/classclang_1_1RecursiveASTVisitor.html#ac74e5ed6ab3568f7ba8819507e768050 [ http://clang.llvm.org/doxygen/classclang_1_1RecursiveASTVisitor.html#ac74e5ed6ab3568f7ba8819507e768050 ]
but, how can I indicate that the traveral is only in a class or some classes?

BTW, what should I use instead of "Context.getTranslationUnitDecl()" as argument of "TraverseStmt(Stmt *S)"?

This task is really necessary for me.

Thanks,

Pedro.

El día 26 mar 2014 19:29, Pedro Delgado Perez <pedro.delgadoperez at mail.uca.es> escribió:
> Hi everyone,
> 
> Maybe my question has a simple answer, but after a time searching for the solution, I haven't found how could I know if a fieldDecl has been referenced in a certain class.
> 
> An example:
> 
> class A{
>   public:
>        int a;
>        int method(){ return a;}
>  ...
> };
> 
> class B: public A{
> ...
> };
> 
> In the above example, if I use the method "isReferenced()" regarding the member variable "a", I think I will get "true" because it was returned in "method". However, if I want to know if that member was referenced within the class "B" (or a subset of classes), how could I do that? (not only in inline methods, but also in redeclarations)
> 
> Thanks in advance,
> 
> Pedro.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140405/c9c954a4/attachment.html>


More information about the cfe-dev mailing list