This is an archive of the discontinued LLVM Phabricator instance.

[SyntaxTree] Add support for call expressions
ClosedPublic

Authored by eduucaldas on Aug 25 2020, 8:45 AM.

Details

Summary

Add support for all C++ call expressions, including those coming from operator().
A call expression's arguments are inside their own node - CallArguments - based on the List base API.

Diff Detail

Event Timeline

eduucaldas created this revision.Aug 25 2020, 8:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 8:45 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
eduucaldas requested review of this revision.Aug 25 2020, 8:45 AM
eduucaldas added inline comments.
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
506

This is wrong but it's just because decltype is all wrong

2734

Here there is a divergence between the grammar and the ClangAST.
According to the grammar ... would an optional element of CallArguments, but here ... is part of an expression.

Perhaps I have used the wrong kind of ...

gribozavr2 accepted this revision.Aug 25 2020, 1:54 PM
gribozavr2 added inline comments.
clang/include/clang/Tooling/Syntax/Nodes.h
333
clang/lib/Tooling/Syntax/BuildTree.cpp
1070

Could you add an assertion that it is indeed an open paren?

Or, rather, due to the decltype test, it has to be a check, and a FIXME that says that the check should become an assertion.

1166

I don't understand this change to the unknown case, could you explain?

clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
2320
2343
2431–2436
2437

Please also add a test for pf() -- that's allowed, but I believe the AST is slightly different from f().

2734

... would an optional element of CallArguments

I don't think so. Note that every element of initializer-list can have a ... in it.

This revision is now accepted and ready to land.Aug 25 2020, 1:54 PM
eduucaldas marked 8 inline comments as done.

Answer code review, squash commits

clang/lib/Tooling/Syntax/BuildTree.cpp
1070

Thanks! It is indeed what I should've done :)

1166

CXXOperatorCallExpr <- CallExpr <- Expr

In this change we added an overload for WalkUpFromCallExpr, so we started intercepting the WalkUp at CallExpr instead of Expr, this works around that.

clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
2734

True! I hadn't seen it correctly!

This revision was landed with ongoing or failed builds.Aug 26 2020, 12:04 AM
This revision was automatically updated to reflect the committed changes.