1 | //===- unittest/Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.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 CXXBoolLiteralExprVisitor : public ExpectedLocationVisitor { |
16 | public: |
17 | bool VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *BE) override { |
18 | if (BE->getValue()) |
19 | Match("true", BE->getLocation()); |
20 | else |
21 | Match("false", BE->getLocation()); |
22 | return true; |
23 | } |
24 | }; |
25 | |
26 | TEST(RecursiveASTVisitor, VisitsClassTemplateNonTypeParmDefaultArgument) { |
27 | CXXBoolLiteralExprVisitor Visitor; |
28 | Visitor.ExpectMatch("true", 2, 19); |
29 | EXPECT_TRUE(Visitor.runOver( |
30 | "template<bool B> class X;\n" |
31 | "template<bool B = true> class Y;\n" |
32 | "template<bool B> class Y {};\n")); |
33 | } |
34 | |
35 | } // end anonymous namespace |
36 |