Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Finding ICPPClassType for this from the AST

Just as an update.

I'm able to get to the ICPPClassType by navigating parents of the expression to the function definition and then using
the name of the declarator.

Is this already implemented in a utility somewhere?

-Andrew

On 14-01-08 11:38 AM, Andrew Eidsness wrote:
> Is there a way to find the ICPPClassType of this from the AST in all of the following cases?
> 
> |class T
> {
>     void callee();
>     void caller()
>     {
>         this->callee(); // case 1
>         callee();       // case 2
>         T::callee();    // case 3
>     }
> };|
> 
> I have the ICPPASTFunctionCallExpression and I’m trying to get the ICPPClassType of this to implement a Content
> Assistant and a Codan checker.
> 
> For case 1, the name of the function call is an ICPPASTFieldReference, so I can use the result of getFieldOwner to get T.
> 
> For cases 2 and 3, /if/ the node is a valid function call then I can use ICPPASTExpression.getEvaluation() to get an
> EvalMemberAccess and then use the owner type to get T.
> 
> However, I want to use this code as part of a Content Assistant and if the complete function call has not yet been
> entered, then getEvaluation returns a Problem instead of the EvalMemberAccess. For the same reason, I can’t get the
> IBinding from the index.
> 
> -Andrew
> 
> 
> 
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
> 



Back to the top