This is an archive of the discontinued LLVM Phabricator instance.

[AST] AnyCall: Implement arguments().
Needs ReviewPublic

Authored by NoQ on May 3 2021, 3:10 PM.

Details

Summary

AnyCall is an interface provided by libAnalysis to polymorphically handle various call-like entities (function calls, Obj-C message expressions, block calls, constructor/destructor invocations, new/delete invocations, etc.) which aren't necessarily related in the AST class hierarchy.

This patch updates it to allow obtaining arguments of any call-like expression.

It also adds a couple of accessor functions in the AST in order to make this possible. The CXXDeleteExpr's getArgumentAddress() looks a bit weird out of context but we do seem to have a precedent (VarDecl::getInitAddress()).

Diff Detail

Event Timeline

NoQ created this revision.May 3 2021, 3:10 PM
NoQ requested review of this revision.May 3 2021, 3:10 PM
xazax.hun added inline comments.
clang/include/clang/Analysis/AnyCall.h
170

As far as I remember CXXMemberCallExpr and CXXOperatorCallExpr having slightly different behavior with the former not including the implicit object argument in the argument list contrary to the latter. If that is the case, maybe this API should provide some uniformity, e.g. skipping the implicit object argument for CXXOperatorCallExpr (and potentially providing a separate function for getting the this/self). What do you think?

NoQ added inline comments.May 3 2021, 7:35 PM
clang/include/clang/Analysis/AnyCall.h
170

Excellent point yeah. And if we're going to do something so non-trivial it probably makes sense for me to start covering AnyCall with unittests.