1 //===- Nodes.cpp ----------------------------------------------*- C++ -*-=====// 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 #include "clang/Tooling/Syntax/Nodes.h" 9 #include "clang/Basic/TokenKinds.h" 10 11 using namespace clang; 12 13 llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS, NodeKind K) { 14 switch (K) { 15 case NodeKind::Leaf: 16 return OS << "Leaf"; 17 case NodeKind::TranslationUnit: 18 return OS << "TranslationUnit"; 19 case NodeKind::TopLevelDeclaration: 20 return OS << "TopLevelDeclaration"; 21 case NodeKind::CompoundStatement: 22 return OS << "CompoundStatement"; 23 } 24 llvm_unreachable("unknown node kind"); 25 } 26 27 syntax::Leaf *syntax::CompoundStatement::lbrace() { 28 return llvm::cast_or_null<syntax::Leaf>( 29 findChild(NodeRole::CompoundStatement_lbrace)); 30 } 31 32 syntax::Leaf *syntax::CompoundStatement::rbrace() { 33 return llvm::cast_or_null<syntax::Leaf>( 34 findChild(NodeRole::CompoundStatement_rbrace)); 35 } 36