clang  10.0.0svn
Nodes.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
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 
28  return llvm::cast_or_null<syntax::Leaf>(
30 }
31 
33  return llvm::cast_or_null<syntax::Leaf>(
35 }
syntax::Leaf * lbrace()
Definition: Nodes.cpp:27
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, NodeKind K)
For debugging purposes.
Definition: Nodes.cpp:13
NodeKind
A kind of a syntax node, used for implementing casts.
Definition: Nodes.h:25
Dataflow Directional Tag Classes.
A leaf node points to a single token inside the expanded token stream.
Definition: Tree.h:104
syntax::Leaf * rbrace()
Definition: Nodes.cpp:32
Defines the clang::TokenKind enum and support functions.
syntax::Node * findChild(NodeRole R)
Find the first node with a corresponding role.
Definition: Tree.cpp:143