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