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