Clang Project

clang_source_code/unittests/Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp
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
11using namespace clang;
12
13namespace {
14
15class CXXBoolLiteralExprVisitor 
16  : public ExpectedLocationVisitor<CXXBoolLiteralExprVisitor> {
17public:
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
27TEST(RecursiveASTVisitor, VisitsClassTemplateNonTypeParmDefaultArgument) {
28  CXXBoolLiteralExprVisitor Visitor;
29  Visitor.ExpectMatch("true"219);
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
37