Nodes.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. using namespace clang;
  11. llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS, NodeKind K) {
  12. switch (K) {
  13. case NodeKind::Leaf:
  14. return OS << "Leaf";
  15. case NodeKind::TranslationUnit:
  16. return OS << "TranslationUnit";
  17. case NodeKind::TopLevelDeclaration:
  18. return OS << "TopLevelDeclaration";
  19. case NodeKind::CompoundStatement:
  20. return OS << "CompoundStatement";
  21. }
  22. llvm_unreachable("unknown node kind");
  23. }
  24. syntax::Leaf *syntax::CompoundStatement::lbrace() {
  25. return llvm::cast_or_null<syntax::Leaf>(
  26. findChild(NodeRole::CompoundStatement_lbrace));
  27. }
  28. syntax::Leaf *syntax::CompoundStatement::rbrace() {
  29. return llvm::cast_or_null<syntax::Leaf>(
  30. findChild(NodeRole::CompoundStatement_rbrace));
  31. }