[cfe-users] Extra argument when calling object of class type

Brennan Vincent via cfe-users cfe-users at lists.llvm.org
Wed Nov 28 10:07:00 PST 2018


 
Hi all,
 

 
I have noticed that there is an extra argument in `CXXOperatorCallExpr`
 
corresponding to the object itself. For example:
 

 
```
 
class S;
 
S s;
 
s(1, "asdf",2);
 
```
 

 
In this case, the corresponding `CXXOperatorCallExpr` will have
 
four arguments: `s`, `1`, `"asdf"`, and `2`.
 

 
However, when getting the declaration of the callee 
 
(e.g. in `expr->getDirectCallee()`), it doesn't have a corresponding 
 
extra parameter (in this example, it would have three parameters). 
 

 
This makes writing linters that deal with call expressions a bit annoying,
 
since you have to special-case the "call to object of class type" case and 
 
skip the first argument when iterating over call arguments and
 
function decl parameters in parallel.
 

 
Is this intended? If so, is there some API that will just return the three
 
actual call arguments (`1`, `"asdf"`, and `2`) ?
 

 
See: https://github.com/llvm-mirror/clang/blob/b129ce9436c5e1227d6314d30d3bf65fa548a3f8/lib/Sema/SemaOverload.cpp#L13260-L13264
 

 
Thanks for any advice.
 
Brennan
 

 


 



More information about the cfe-users mailing list