1//===- InitListExprPreOrderNoQueue.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//===----------------------------------------------------------------------===//
8
9#include "TestVisitor.h"
10
11using namespace clang;
12
13namespace {
14
15class InitListExprPreOrderNoQueueVisitor
16 : public ExpectedLocationVisitor<InitListExprPreOrderNoQueueVisitor> {
17public:
18 bool TraverseInitListExpr(InitListExpr *ILE) {
19 return ExpectedLocationVisitor::TraverseInitListExpr(ILE);
20 }
21
22 bool VisitInitListExpr(InitListExpr *ILE) {
23 Match(Name: ILE->isSemanticForm() ? "semantic" : "syntactic", Location: ILE->getBeginLoc());
24 return true;
25 }
26};
27
28TEST(RecursiveASTVisitor, InitListExprIsPreOrderNoQueueVisitedTwice) {
29 InitListExprPreOrderNoQueueVisitor Visitor;
30 Visitor.ExpectMatch(Match: "syntactic", Line: 2, Column: 21);
31 Visitor.ExpectMatch(Match: "semantic", Line: 2, Column: 21);
32 EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n"
33 "static struct S s = {.x = 0};\n",
34 InitListExprPreOrderNoQueueVisitor::Lang_C));
35}
36
37} // end anonymous namespace
38

source code of clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrderNoQueue.cpp