Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / unittests / Tooling / RecursiveASTVisitorTests / CXXOperatorCallExprTraverser.cpp
blob91de8d17c9d5f2254a231f8688f8decc86db18a0
1 //===- unittest/Tooling/RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp -===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "TestVisitor.h"
11 using namespace clang;
13 namespace {
15 class CXXOperatorCallExprTraverser
16 : public ExpectedLocationVisitor<CXXOperatorCallExprTraverser> {
17 public:
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(
31 "struct A {\n"
32 " int operator()();\n"
33 "} a;\n"
34 "int k = a();\n"));
37 } // end anonymous namespace