1//===- unittest/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.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#include <string>
11
12using namespace clang;
13
14namespace {
15
16// Check to ensure that bitfield initializers are visited.
17class BitfieldInitializerVisitor
18 : public ExpectedLocationVisitor<BitfieldInitializerVisitor> {
19public:
20 bool VisitIntegerLiteral(IntegerLiteral *IL) {
21 Match(Name: std::to_string(IL->getValue().getSExtValue()), Location: IL->getLocation());
22 return true;
23 }
24};
25
26TEST(RecursiveASTVisitor, BitfieldInitializerIsVisited) {
27 BitfieldInitializerVisitor Visitor;
28 Visitor.ExpectMatch(Match: "123", Line: 2, Column: 15);
29 EXPECT_TRUE(Visitor.runOver("struct S {\n"
30 " int x : 8 = 123;\n"
31 "};\n"));
32}
33
34} // end anonymous namespace
35

source code of clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp