[PATCH] D86544: [SyntaxTree] Add support for call expressions

2020-08-26 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2de2ca348dfa: [SyntaxTree] Add support for `CallExpression` 
(authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86544/new/

https://reviews.llvm.org/D86544

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -316,12 +316,12 @@
   `-CompoundStatement
 |-'{' OpenParen
 |-ExpressionStatement CompoundStatement_statement
-| |-UnknownExpression ExpressionStatement_expression
-| | |-IdExpression
+| |-CallExpression ExpressionStatement_expression
+| | |-IdExpression CallExpression_callee
 | | | `-UnqualifiedId IdExpression_id
 | | |   `-'test'
-| | |-'('
-| | `-')'
+| | |-'(' OpenParen
+| | `-')' CloseParen
 | `-';'
 |-IfStatement CompoundStatement_statement
 | |-'if' IntroducerKeyword
@@ -330,21 +330,21 @@
 | | `-'1' LiteralToken
 | |-')'
 | |-ExpressionStatement IfStatement_thenStatement
-| | |-UnknownExpression ExpressionStatement_expression
-| | | |-IdExpression
+| | |-CallExpression ExpressionStatement_expression
+| | | |-IdExpression CallExpression_callee
 | | | | `-UnqualifiedId IdExpression_id
 | | | |   `-'test'
-| | | |-'('
-| | | `-')'
+| | | |-'(' OpenParen
+| | | `-')' CloseParen
 | | `-';'
 | |-'else' IfStatement_elseKeyword
 | `-ExpressionStatement IfStatement_elseStatement
-|   |-UnknownExpression ExpressionStatement_expression
-|   | |-IdExpression
+|   |-CallExpression ExpressionStatement_expression
+|   | |-IdExpression CallExpression_callee
 |   | | `-UnqualifiedId IdExpression_id
 |   | |   `-'test'
-|   | |-'('
-|   | `-')'
+|   | |-'(' OpenParen
+|   | `-')' CloseParen
 |   `-';'
 `-'}' CloseParen
 )txt"));
@@ -378,20 +378,21 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'operator'
 |   `-'+'
-|-'('
-|-IdExpression
-| `-UnqualifiedId IdExpression_id
-|   `-'x'
-|-','
-|-IdExpression
-| `-UnqualifiedId IdExpression_id
-|   `-'x'
-`-')'
+|-'(' OpenParen
+|-CallArguments CallExpression_arguments
+| |-IdExpression List_element
+| | `-UnqualifiedId IdExpression_id
+| |   `-'x'
+| |-',' List_delimiter
+| `-IdExpression List_element
+|   `-UnqualifiedId IdExpression_id
+| `-'x'
+`-')' CloseParen
 )txt"}));
 }
 
@@ -409,8 +410,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -419,8 +420,8 @@
 |   `-UnqualifiedId IdExpression_id
 | |-'operator'
 | `-'int'
-|-'('
-`-')'
+|-'(' OpenParen
+`-')' CloseParen
 )txt"}));
 }
 
@@ -436,16 +437,17 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'operator'
 |   |-'""'
 |   `-'_w'
-|-'('
-|-CharacterLiteralExpression
-| `-''1'' LiteralToken
-`-')'
+|-'(' OpenParen
+|-CallArguments CallExpression_arguments
+| `-CharacterLiteralExpression List_element
+|   `-''1'' LiteralToken
+`-')' CloseParen
 )txt"}));
 }
 
@@ -461,8 +463,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -471,8 +473,8 @@
 |   `-UnqualifiedId IdExpression_id
 | |-'~'
 | `-'X'
-|-'('
-`-')'
+|-'(' OpenParen
+`-')' CloseParen
 )txt"}));
 }
 
@@ -492,8 +494,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -506,7 +508,7 @@
 |-'x'
 |-')'
 |-'('
-`-')'
+`-')' CloseParen
 )txt"}));
 }
 
@@ -523,15 +525,15 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpr

[PATCH] D86544: [SyntaxTree] Add support for call expressions

2020-08-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:1070
+Builder.markChildToken(
+std::next(Builder.findToken(S->getCallee()->getEndLoc())),
+syntax::NodeRole::OpenParen);

gribozavr2 wrote:
> 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.
Thanks! It is indeed what I should've done :) 



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:1159
 case syntax::NodeKind::UnknownExpression:
-  return RecursiveASTVisitor::WalkUpFromCXXOperatorCallExpr(S);
+  return WalkUpFromExpr(S);
 default:

gribozavr2 wrote:
> I don't understand this change to the unknown case, could you explain?
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.




Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2734
+|   |   `-'args'
+|   `-'...'
+`-')' CloseParen

gribozavr2 wrote:
> eduucaldas wrote:
> > Here there is a divergence between the grammar and the ClangAST. 
> > According to the [[ https://eel.is/c++draft/expr.post#nt:expression-list | 
> > grammar ]]  `...` would an optional element of `CallArguments`, but here 
> > `...` is part of an expression.
> > 
> > Perhaps I have used the wrong kind of `...`
> > `...` would an optional element of CallArguments
> 
> I don't think so. Note that every element of initializer-list can have a 
> `...` in it.
True! I hadn't seen it correctly!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86544/new/

https://reviews.llvm.org/D86544

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86544: [SyntaxTree] Add support for call expressions

2020-08-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 287842.
eduucaldas marked 8 inline comments as done.
eduucaldas added a comment.

Answer code review, squash commits


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86544/new/

https://reviews.llvm.org/D86544

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -316,12 +316,12 @@
   `-CompoundStatement
 |-'{' OpenParen
 |-ExpressionStatement CompoundStatement_statement
-| |-UnknownExpression ExpressionStatement_expression
-| | |-IdExpression
+| |-CallExpression ExpressionStatement_expression
+| | |-IdExpression CallExpression_callee
 | | | `-UnqualifiedId IdExpression_id
 | | |   `-'test'
-| | |-'('
-| | `-')'
+| | |-'(' OpenParen
+| | `-')' CloseParen
 | `-';'
 |-IfStatement CompoundStatement_statement
 | |-'if' IntroducerKeyword
@@ -330,21 +330,21 @@
 | | `-'1' LiteralToken
 | |-')'
 | |-ExpressionStatement IfStatement_thenStatement
-| | |-UnknownExpression ExpressionStatement_expression
-| | | |-IdExpression
+| | |-CallExpression ExpressionStatement_expression
+| | | |-IdExpression CallExpression_callee
 | | | | `-UnqualifiedId IdExpression_id
 | | | |   `-'test'
-| | | |-'('
-| | | `-')'
+| | | |-'(' OpenParen
+| | | `-')' CloseParen
 | | `-';'
 | |-'else' IfStatement_elseKeyword
 | `-ExpressionStatement IfStatement_elseStatement
-|   |-UnknownExpression ExpressionStatement_expression
-|   | |-IdExpression
+|   |-CallExpression ExpressionStatement_expression
+|   | |-IdExpression CallExpression_callee
 |   | | `-UnqualifiedId IdExpression_id
 |   | |   `-'test'
-|   | |-'('
-|   | `-')'
+|   | |-'(' OpenParen
+|   | `-')' CloseParen
 |   `-';'
 `-'}' CloseParen
 )txt"));
@@ -378,20 +378,21 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'operator'
 |   `-'+'
-|-'('
-|-IdExpression
-| `-UnqualifiedId IdExpression_id
-|   `-'x'
-|-','
-|-IdExpression
-| `-UnqualifiedId IdExpression_id
-|   `-'x'
-`-')'
+|-'(' OpenParen
+|-CallArguments CallExpression_arguments
+| |-IdExpression List_element
+| | `-UnqualifiedId IdExpression_id
+| |   `-'x'
+| |-',' List_delimiter
+| `-IdExpression List_element
+|   `-UnqualifiedId IdExpression_id
+| `-'x'
+`-')' CloseParen
 )txt"}));
 }
 
@@ -409,8 +410,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -419,8 +420,8 @@
 |   `-UnqualifiedId IdExpression_id
 | |-'operator'
 | `-'int'
-|-'('
-`-')'
+|-'(' OpenParen
+`-')' CloseParen
 )txt"}));
 }
 
@@ -436,16 +437,17 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'operator'
 |   |-'""'
 |   `-'_w'
-|-'('
-|-CharacterLiteralExpression
-| `-''1'' LiteralToken
-`-')'
+|-'(' OpenParen
+|-CallArguments CallExpression_arguments
+| `-CharacterLiteralExpression List_element
+|   `-''1'' LiteralToken
+`-')' CloseParen
 )txt"}));
 }
 
@@ -461,8 +463,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -471,8 +473,8 @@
 |   `-UnqualifiedId IdExpression_id
 | |-'~'
 | `-'X'
-|-'('
-`-')'
+|-'(' OpenParen
+`-')' CloseParen
 )txt"}));
 }
 
@@ -492,8 +494,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -506,7 +508,7 @@
 |-'x'
 |-')'
 |-'('
-`-')'
+`-')' CloseParen
 )txt"}));
 }
 
@@ -523,15 +525,15 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'f'
 |   |-'<'
 |   |-'int'
 |   `-'>'
-|-'('
-`-')'
+|-'(' 

[PATCH] D86544: [SyntaxTree] Add support for call expressions

2020-08-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:333
+///   call-arguments:
+/// delimited_list(expression, ',', )
+/// Note: This construct is a simplification of the grammar rule for





Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:1070
+Builder.markChildToken(
+std::next(Builder.findToken(S->getCallee()->getEndLoc())),
+syntax::NodeRole::OpenParen);

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.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:1159
 case syntax::NodeKind::UnknownExpression:
-  return RecursiveASTVisitor::WalkUpFromCXXOperatorCallExpr(S);
+  return WalkUpFromExpr(S);
 default:

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



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2320
+
+TEST_P(SyntaxTreeTest, CallExpression_Callee_Operator) {
+  if (!GetParam().isCXX()) {





Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2343
+
+TEST_P(SyntaxTreeTest, CallExpression_Callee_OperatorChaining) {
+  if (!GetParam().isCXX()) {





Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2431-2436
+void f();
+void test() {
+  void (*pf)();
+  pf = &f;
+  [[(*pf)()]];
+}





Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2437
+}
+)cpp",
+  {R"txt(

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



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2734
+|   |   `-'args'
+|   `-'...'
+`-')' CloseParen

eduucaldas wrote:
> Here there is a divergence between the grammar and the ClangAST. 
> According to the [[ https://eel.is/c++draft/expr.post#nt:expression-list | 
> grammar ]]  `...` would an optional element of `CallArguments`, but here 
> `...` is part of an expression.
> 
> Perhaps I have used the wrong kind of `...`
> `...` would an optional element of CallArguments

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


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86544/new/

https://reviews.llvm.org/D86544

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86544: [SyntaxTree] Add support for call expressions

2020-08-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a reviewer: gribozavr2.
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:506
 | `-'~'
-|-'decltype'
+|-'decltype' OpenParen
 |-'('

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



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2734
+|   |   `-'args'
+|   `-'...'
+`-')' CloseParen

Here there is a divergence between the grammar and the ClangAST. 
According to the [[ https://eel.is/c++draft/expr.post#nt:expression-list | 
grammar ]]  `...` would an optional element of `CallArguments`, but here `...` 
is part of an expression.

Perhaps I have used the wrong kind of `...`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86544/new/

https://reviews.llvm.org/D86544

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86544: [SyntaxTree] Add support for call expressions

2020-08-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 287694.
eduucaldas added a comment.

- Nits


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86544/new/

https://reviews.llvm.org/D86544

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -316,12 +316,12 @@
   `-CompoundStatement
 |-'{' OpenParen
 |-ExpressionStatement CompoundStatement_statement
-| |-UnknownExpression ExpressionStatement_expression
-| | |-IdExpression
+| |-CallExpression ExpressionStatement_expression
+| | |-IdExpression CallExpression_callee
 | | | `-UnqualifiedId IdExpression_id
 | | |   `-'test'
-| | |-'('
-| | `-')'
+| | |-'(' OpenParen
+| | `-')' CloseParen
 | `-';'
 |-IfStatement CompoundStatement_statement
 | |-'if' IntroducerKeyword
@@ -330,21 +330,21 @@
 | | `-'1' LiteralToken
 | |-')'
 | |-ExpressionStatement IfStatement_thenStatement
-| | |-UnknownExpression ExpressionStatement_expression
-| | | |-IdExpression
+| | |-CallExpression ExpressionStatement_expression
+| | | |-IdExpression CallExpression_callee
 | | | | `-UnqualifiedId IdExpression_id
 | | | |   `-'test'
-| | | |-'('
-| | | `-')'
+| | | |-'(' OpenParen
+| | | `-')' CloseParen
 | | `-';'
 | |-'else' IfStatement_elseKeyword
 | `-ExpressionStatement IfStatement_elseStatement
-|   |-UnknownExpression ExpressionStatement_expression
-|   | |-IdExpression
+|   |-CallExpression ExpressionStatement_expression
+|   | |-IdExpression CallExpression_callee
 |   | | `-UnqualifiedId IdExpression_id
 |   | |   `-'test'
-|   | |-'('
-|   | `-')'
+|   | |-'(' OpenParen
+|   | `-')' CloseParen
 |   `-';'
 `-'}' CloseParen
 )txt"));
@@ -378,20 +378,21 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'operator'
 |   `-'+'
-|-'('
-|-IdExpression
-| `-UnqualifiedId IdExpression_id
-|   `-'x'
-|-','
-|-IdExpression
-| `-UnqualifiedId IdExpression_id
-|   `-'x'
-`-')'
+|-'(' OpenParen
+|-CallArguments CallExpression_arguments
+| |-IdExpression List_element
+| | `-UnqualifiedId IdExpression_id
+| |   `-'x'
+| |-',' List_delimiter
+| `-IdExpression List_element
+|   `-UnqualifiedId IdExpression_id
+| `-'x'
+`-')' CloseParen
 )txt"}));
 }
 
@@ -409,8 +410,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -419,8 +420,8 @@
 |   `-UnqualifiedId IdExpression_id
 | |-'operator'
 | `-'int'
-|-'('
-`-')'
+|-'(' OpenParen
+`-')' CloseParen
 )txt"}));
 }
 
@@ -436,16 +437,17 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'operator'
 |   |-'""'
 |   `-'_w'
-|-'('
-|-CharacterLiteralExpression
-| `-''1'' LiteralToken
-`-')'
+|-'(' OpenParen
+|-CallArguments CallExpression_arguments
+| `-CharacterLiteralExpression List_element
+|   `-''1'' LiteralToken
+`-')' CloseParen
 )txt"}));
 }
 
@@ -461,8 +463,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -471,8 +473,8 @@
 |   `-UnqualifiedId IdExpression_id
 | |-'~'
 | `-'X'
-|-'('
-`-')'
+|-'(' OpenParen
+`-')' CloseParen
 )txt"}));
 }
 
@@ -492,8 +494,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -501,12 +503,12 @@
 | `-IdExpression MemberExpression_member
 |   `-UnqualifiedId IdExpression_id
 | `-'~'
-|-'decltype'
+|-'decltype' OpenParen
 |-'('
 |-'x'
 |-')'
 |-'('
-`-')'
+`-')' CloseParen
 )txt"}));
 }
 
@@ -523,15 +525,15 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 

[PATCH] D86544: [SyntaxTree] Add support for call expressions

2020-08-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86544

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -316,12 +316,12 @@
   `-CompoundStatement
 |-'{' OpenParen
 |-ExpressionStatement CompoundStatement_statement
-| |-UnknownExpression ExpressionStatement_expression
-| | |-IdExpression
+| |-CallExpression ExpressionStatement_expression
+| | |-IdExpression CallExpression_callee
 | | | `-UnqualifiedId IdExpression_id
 | | |   `-'test'
-| | |-'('
-| | `-')'
+| | |-'(' OpenParen
+| | `-')' CloseParen
 | `-';'
 |-IfStatement CompoundStatement_statement
 | |-'if' IntroducerKeyword
@@ -330,21 +330,21 @@
 | | `-'1' LiteralToken
 | |-')'
 | |-ExpressionStatement IfStatement_thenStatement
-| | |-UnknownExpression ExpressionStatement_expression
-| | | |-IdExpression
+| | |-CallExpression ExpressionStatement_expression
+| | | |-IdExpression CallExpression_callee
 | | | | `-UnqualifiedId IdExpression_id
 | | | |   `-'test'
-| | | |-'('
-| | | `-')'
+| | | |-'(' OpenParen
+| | | `-')' CloseParen
 | | `-';'
 | |-'else' IfStatement_elseKeyword
 | `-ExpressionStatement IfStatement_elseStatement
-|   |-UnknownExpression ExpressionStatement_expression
-|   | |-IdExpression
+|   |-CallExpression ExpressionStatement_expression
+|   | |-IdExpression CallExpression_callee
 |   | | `-UnqualifiedId IdExpression_id
 |   | |   `-'test'
-|   | |-'('
-|   | `-')'
+|   | |-'(' OpenParen
+|   | `-')' CloseParen
 |   `-';'
 `-'}' CloseParen
 )txt"));
@@ -378,20 +378,21 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'operator'
 |   `-'+'
-|-'('
-|-IdExpression
-| `-UnqualifiedId IdExpression_id
-|   `-'x'
-|-','
-|-IdExpression
-| `-UnqualifiedId IdExpression_id
-|   `-'x'
-`-')'
+|-'(' OpenParen
+|-CallArguments CallExpression_arguments
+| |-IdExpression List_element
+| | `-UnqualifiedId IdExpression_id
+| |   `-'x'
+| |-',' List_delimiter
+| `-IdExpression List_element
+|   `-UnqualifiedId IdExpression_id
+| `-'x'
+`-')' CloseParen
 )txt"}));
 }
 
@@ -409,8 +410,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -419,8 +420,8 @@
 |   `-UnqualifiedId IdExpression_id
 | |-'operator'
 | `-'int'
-|-'('
-`-')'
+|-'(' OpenParen
+`-')' CloseParen
 )txt"}));
 }
 
@@ -436,16 +437,17 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-IdExpression
+CallExpression ExpressionStatement_expression
+|-IdExpression CallExpression_callee
 | `-UnqualifiedId IdExpression_id
 |   |-'operator'
 |   |-'""'
 |   `-'_w'
-|-'('
-|-CharacterLiteralExpression
-| `-''1'' LiteralToken
-`-')'
+|-'(' OpenParen
+|-CallArguments CallExpression_arguments
+| `-CharacterLiteralExpression List_element
+|   `-''1'' LiteralToken
+`-')' CloseParen
 )txt"}));
 }
 
@@ -461,8 +463,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -471,8 +473,8 @@
 |   `-UnqualifiedId IdExpression_id
 | |-'~'
 | `-'X'
-|-'('
-`-')'
+|-'(' OpenParen
+`-')' CloseParen
 )txt"}));
 }
 
@@ -492,8 +494,8 @@
 }
 )cpp",
   {R"txt(
-UnknownExpression ExpressionStatement_expression
-|-MemberExpression
+CallExpression ExpressionStatement_expression
+|-MemberExpression CallExpression_callee
 | |-IdExpression MemberExpression_object
 | | `-UnqualifiedId IdExpression_id
 | |   `-'x'
@@ -501,12 +503,12 @@
 | `-IdExpression MemberExpression_member
 |   `-UnqualifiedId IdExpression_id
 | `-'~'
-|-'decltype'
+|-'decltype' OpenParen
 |-'('
 |-'x'
 |-')'
 |-'('
-`-')'
+`-')' CloseParen
 )txt"}));
 }
 
@@ -523,15 +525,15 @@
 }
 )cpp",
   {R