[cfe-dev] NestedNameSpecifier-equivalent for CallExpr?

Jordan Rose jordan_rose at apple.com
Wed Jun 6 09:28:10 PDT 2012


Hi, Lukhnos. You can get the function/method/whatever being called using CallExpr::getCallee, and from there you should be able to pick it apart if it's a DeclRefExpr. (Note that a callee could easily /not/ be a DeclRefExpr, say if it's a lambda expression.)

Is that what you're looking for?
Jordan


On Jun 5, 2012, at 23:59 , Lukhnos Liu <lukhnos at lukhnos.org> wrote:

> Hi,
> 
> When we are dealing with types, it is easy to extract the different parts of a nested name specifier by getting one from DeclaratorDecl::getQualifierLoc(). Is anything similar available to CallExpr?
> 
> For example, when we are writing a method renaming tool, and we come upon this:
> 
>  int B::foo(int x) {
>    if (x < 1) {
>      return A::foo(x);  // A is super of B
>    }
>    else {
>      return foo(x - 1);
>    }
>  }
> 
> CallExpr::getLocStart() gives us the beginning locations of "A::foo" and "foo". But for the former, I'm interested in the exact location of the identifier "foo" (the other info I can get from getDirectCallee()). I can't figure out a way to do it other than parsing the range between the start loc and the left parenthesis. Or did I miss anything?
> 
> Thanks!
> 
> Lukhnos
> 
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list