NestedNameSpecifier-equivalent for CallExpr?

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

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

Hi Jordan,

DeclRefExpr indeed solves half of the problem (for non-method calls). I found for C++ methods I need to handle instead MemberExpr and use getMemberLoc() to get the location of F() as in X->F() or X::F().

Thanks!

Lukhnos

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

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:

[...]