================
@@ -162,26 +163,41 @@ class AnyCall {
size_t param_size() const { return parameters().size(); }
bool param_empty() const { return parameters().empty(); }
- /// \returns actual arguments for expression-backed calls, or an empty range
+ /// \returns actual arguments for expression-backed calls, or an empty list
/// for declaration-backed calls and call kinds with implicit or synthesized
- /// argument lists, such as allocators and destructors.
- ArrayRef<const Expr *> arguments() const {
+ /// argument lists, such as allocators and destructors. For instance member
+ /// calls, the implicit object argument is included as argument 0.
+ llvm::SmallVector<const Expr *, 4> arguments() const {
if (!E)
return {};
switch (K) {
- case Function:
+ case Function: {
+ llvm::SmallVector<const Expr *, 4> Args;
+ const auto *CE = cast<CallExpr>(E);
+ if (const auto *MCE = dyn_cast<CXXMemberCallExpr>(CE))
+ Args.push_back(MCE->getImplicitObjectArgument());
+ Args.append(CE->arg_begin(), CE->arg_end());
+
+ if (const auto *OCE = dyn_cast<CXXOperatorCallExpr>(CE))
+ // For `static operator()`, the first argument is the object argument,
+ // remove it from the argument list to avoid off-by-one errors.
+ if (const auto *FD = dyn_cast_or_null<FunctionDecl>(D);
+ FD && FD->isStatic() && OCE->getOperator() == OO_Call)
+ Args.erase(Args.begin());
+ return Args;
+ }
case Block: {
const auto *CE = cast<CallExpr>(E);
- return {CE->getArgs(), CE->getNumArgs()};
+ return llvm::SmallVector<const Expr *, 4>(CE->arg_begin(),
CE->arg_end());
----------------
iitianpushkar wrote:
Yes, will update the patch accordingly.
https://github.com/llvm/llvm-project/pull/217838
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits