aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/Syntax/TreeTest.cpp
diff options
context:
space:
mode:
authorEduardo Caldas <ecaldas@google.com>2020-08-04 08:30:24 +0000
committerEduardo Caldas <ecaldas@google.com>2020-08-05 07:36:39 +0000
commitc5cdc3e801ad1b0aceaf220d78a3ff3fab1e0fdb (patch)
tree2335d3d3ac162b6a44eb9ad328b9a9b16e71f14e /clang/unittests/Tooling/Syntax/TreeTest.cpp
parente739648cfae21d2b564751ef0511fec9559305fa (diff)
downloadllvm-c5cdc3e801ad1b0aceaf220d78a3ff3fab1e0fdb.zip
llvm-c5cdc3e801ad1b0aceaf220d78a3ff3fab1e0fdb.tar.gz
llvm-c5cdc3e801ad1b0aceaf220d78a3ff3fab1e0fdb.tar.bz2
[SyntaxTree] Add test coverage for `->*` operator
This was the last binary operator that we supported but didn't have any test coverage. The recent fix in a crash in member pointers allowed us to add this test. Differential Revision: https://reviews.llvm.org/D85185
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r--clang/unittests/Tooling/Syntax/TreeTest.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 3ccfabb..e696be3 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -2329,16 +2329,17 @@ struct X {
friend bool operator<(const X&, const X&);
friend X operator<<(X&, const X&);
X operator,(X&);
- // TODO: Fix crash on member function pointer and add a test for `->*`
- // TODO: Unbox operators in syntax tree.
+ X operator->*(int);
+ // TODO: Unbox operators in syntax tree.
// Represent operators by `+` instead of `IdExpression-UnqualifiedId-+`
};
-void test(X x, X y) {
+void test(X x, X y, X* xp, int X::* pmi) {
x = y;
x + y;
x < y;
x << y;
x, y;
+ xp->*pmi;
}
)cpp",
R"txt(
@@ -2437,6 +2438,17 @@ void test(X x, X y) {
| | | | `-&
| | | `-)
| | `-;
+| |-SimpleDeclaration
+| | |-X
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-->*
+| | | `-ParametersAndQualifiers
+| | | |-(
+| | | |-SimpleDeclaration
+| | | | `-int
+| | | `-)
+| | `-;
| |-}
| `-;
`-SimpleDeclaration
@@ -2454,6 +2466,21 @@ void test(X x, X y) {
| | |-X
| | `-SimpleDeclarator
| | `-y
+ | |-,
+ | |-SimpleDeclaration
+ | | |-X
+ | | `-SimpleDeclarator
+ | | |-*
+ | | `-xp
+ | |-,
+ | |-SimpleDeclaration
+ | | |-int
+ | | `-SimpleDeclarator
+ | | |-MemberPointer
+ | | | |-X
+ | | | |-::
+ | | | `-*
+ | | `-pmi
| `-)
`-CompoundStatement
|-{
@@ -2518,6 +2545,16 @@ void test(X x, X y) {
| | `-UnqualifiedId
| | `-y
| `-;
+ |-ExpressionStatement
+ | |-BinaryOperatorExpression
+ | | |-IdExpression
+ | | | `-UnqualifiedId
+ | | | `-xp
+ | | |-->*
+ | | `-IdExpression
+ | | `-UnqualifiedId
+ | | `-pmi
+ | `-;
`-}
)txt"));
}