diff options
author | Eduardo Caldas <ecaldas@google.com> | 2020-05-29 20:03:58 +0200 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2020-05-29 20:03:59 +0200 |
commit | 3a574a6cb35953e538e577a88f62af8dd01432c7 (patch) | |
tree | d1999c161eec60c7eb2116a58fd4ee24edd5bef0 /clang/unittests/Tooling/Syntax/TreeTest.cpp | |
parent | 81443ac1bc710c89565ea1bce0eb566bf2cacd0d (diff) | |
download | llvm-3a574a6cb35953e538e577a88f62af8dd01432c7.zip llvm-3a574a6cb35953e538e577a88f62af8dd01432c7.tar.gz llvm-3a574a6cb35953e538e577a88f62af8dd01432c7.tar.bz2 |
Add support for Overloaded Binary Operators in SyntaxTree
Reviewers: gribozavr2
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80812
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/Syntax/TreeTest.cpp | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp index 7051074..0478625 100644 --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -993,6 +993,134 @@ void test(int a, int b) { )txt"); } +TEST_F(SyntaxTreeTest, UserDefinedBinaryOperator) { + expectTreeDumpEqual( + R"cpp( +struct X { + X& operator=(const X&); + friend X operator+(X, const X&); + friend bool operator<(const X&, const X&); +}; +void test(X x, X y) { + x = y; + x + y; + x < y; +} + )cpp", + R"txt( +*: TranslationUnit +|-SimpleDeclaration +| |-struct +| |-X +| |-{ +| |-SimpleDeclaration +| | |-X +| | |-SimpleDeclarator +| | | |-& +| | | |-operator +| | | |-= +| | | `-ParametersAndQualifiers +| | | |-( +| | | |-SimpleDeclaration +| | | | |-const +| | | | |-X +| | | | `-SimpleDeclarator +| | | | `-& +| | | `-) +| | `-; +| |-UnknownDeclaration +| | `-SimpleDeclaration +| | |-friend +| | |-X +| | |-SimpleDeclarator +| | | |-operator +| | | |-+ +| | | `-ParametersAndQualifiers +| | | |-( +| | | |-SimpleDeclaration +| | | | `-X +| | | |-, +| | | |-SimpleDeclaration +| | | | |-const +| | | | |-X +| | | | `-SimpleDeclarator +| | | | `-& +| | | `-) +| | `-; +| |-UnknownDeclaration +| | `-SimpleDeclaration +| | |-friend +| | |-bool +| | |-SimpleDeclarator +| | | |-operator +| | | |-< +| | | `-ParametersAndQualifiers +| | | |-( +| | | |-SimpleDeclaration +| | | | |-const +| | | | |-X +| | | | `-SimpleDeclarator +| | | | `-& +| | | |-, +| | | |-SimpleDeclaration +| | | | |-const +| | | | |-X +| | | | `-SimpleDeclarator +| | | | `-& +| | | `-) +| | `-; +| |-} +| `-; +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | |-SimpleDeclaration + | | |-X + | | `-SimpleDeclarator + | | `-x + | |-, + | |-SimpleDeclaration + | | |-X + | | `-SimpleDeclarator + | | `-y + | `-) + `-CompoundStatement + |-{ + |-ExpressionStatement + | |-BinaryOperatorExpression + | | |-UnknownExpression + | | | `-x + | | |-UnknownExpression + | | | `-= + | | `-UnknownExpression + | | `-y + | `-; + |-ExpressionStatement + | |-BinaryOperatorExpression + | | |-UnknownExpression + | | | `-UnknownExpression + | | | `-x + | | |-UnknownExpression + | | | `-+ + | | `-UnknownExpression + | | `-y + | `-; + |-ExpressionStatement + | |-BinaryOperatorExpression + | | |-UnknownExpression + | | | `-x + | | |-UnknownExpression + | | | `-< + | | `-UnknownExpression + | | `-y + | `-; + `-} +)txt"); +} + TEST_F(SyntaxTreeTest, MultipleDeclaratorsGrouping) { expectTreeDumpEqual( R"cpp( |