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 : public ExpectedLocationVisitor {
16public:
17 bool TraverseInitListExpr(InitListExpr *ILE) override {
18 return ExpectedLocationVisitor::TraverseInitListExpr(ILE);
19 }
20
21 bool VisitInitListExpr(InitListExpr *ILE) override {
22 Match(ILE->isSemanticForm() ? "semantic" : "syntactic", ILE->getBeginLoc());
23 return true;
24 }
25};
26
27TEST(RecursiveASTVisitor, InitListExprIsPreOrderNoQueueVisitedTwice) {
28 InitListExprPreOrderNoQueueVisitor Visitor;
29 Visitor.ExpectMatch("syntactic", 2, 21);
30 Visitor.ExpectMatch("semantic", 2, 21);
31 EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n"
32 "static struct S s = {.x = 0};\n",
33 InitListExprPreOrderNoQueueVisitor::Lang_C));
34}
35
36} // end anonymous namespace
37

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

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