1 //===- unittest/Tooling/RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp -===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "TestVisitor.h"
11 using namespace clang
;
15 class CXXOperatorCallExprTraverser
16 : public ExpectedLocationVisitor
<CXXOperatorCallExprTraverser
> {
18 // Use Traverse, not Visit, to check that data recursion optimization isn't
19 // bypassing the call of this function.
20 bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr
*CE
) {
21 Match(getOperatorSpelling(CE
->getOperator()), CE
->getExprLoc());
22 return ExpectedLocationVisitor
<CXXOperatorCallExprTraverser
>::
23 TraverseCXXOperatorCallExpr(CE
);
27 TEST(RecursiveASTVisitor
, TraversesOverloadedOperator
) {
28 CXXOperatorCallExprTraverser Visitor
;
29 Visitor
.ExpectMatch("()", 4, 9);
30 EXPECT_TRUE(Visitor
.runOver(
32 " int operator()();\n"
37 } // end anonymous namespace