1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #include "TestVisitor.h" |
10 | |
11 | using namespace clang; |
12 | |
13 | namespace { |
14 | |
15 | |
16 | |
17 | class InitListExprPreOrderVisitor |
18 | : public ExpectedLocationVisitor<InitListExprPreOrderVisitor> { |
19 | public: |
20 | bool VisitInitListExpr(InitListExpr *ILE) { |
21 | Match(ILE->isSemanticForm() ? "semantic" : "syntactic", ILE->getBeginLoc()); |
22 | return true; |
23 | } |
24 | }; |
25 | |
26 | TEST(RecursiveASTVisitor, InitListExprIsPreOrderVisitedTwice) { |
27 | InitListExprPreOrderVisitor Visitor; |
28 | Visitor.ExpectMatch("syntactic", 2, 21); |
29 | Visitor.ExpectMatch("semantic", 2, 21); |
30 | EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n" |
31 | "static struct S s = {.x = 0};\n", |
32 | InitListExprPreOrderVisitor::Lang_C)); |
33 | } |
34 | |
35 | } |
36 | |