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 | |
11 | using namespace clang; |
12 | |
13 | namespace { |
14 | |
15 | class InitListExprPreOrderNoQueueVisitor : public ExpectedLocationVisitor { |
16 | public: |
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 | |
27 | TEST(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 |