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