|
|
|||
File indexing completed on 2026-05-10 08:37:11
0001 //===- BuildTree.h - build syntax trees -----------------------*- C++ -*-=====// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // Functions to construct a syntax tree from an AST. 0009 //===----------------------------------------------------------------------===// 0010 #ifndef LLVM_CLANG_TOOLING_SYNTAX_BUILDTREE_H 0011 #define LLVM_CLANG_TOOLING_SYNTAX_BUILDTREE_H 0012 0013 #include "clang/AST/Decl.h" 0014 #include "clang/Basic/TokenKinds.h" 0015 #include "clang/Tooling/Syntax/Nodes.h" 0016 #include "clang/Tooling/Syntax/TokenBufferTokenManager.h" 0017 #include "clang/Tooling/Syntax/Tree.h" 0018 0019 namespace clang { 0020 namespace syntax { 0021 0022 /// Build a syntax tree for the main file. 0023 /// This usually covers the whole TranslationUnitDecl, but can be restricted by 0024 /// the ASTContext's traversal scope. 0025 syntax::TranslationUnit * 0026 buildSyntaxTree(Arena &A, TokenBufferTokenManager &TBTM, ASTContext &Context); 0027 0028 // Create syntax trees from subtrees not backed by the source code. 0029 0030 // Synthesis of Leafs 0031 /// Create `Leaf` from token with `Spelling` and assert it has the desired 0032 /// `TokenKind`. 0033 syntax::Leaf *createLeaf(syntax::Arena &A, TokenBufferTokenManager &TBTM, 0034 tok::TokenKind K, StringRef Spelling); 0035 0036 /// Infer the token spelling from its `TokenKind`, then create `Leaf` from 0037 /// this token 0038 syntax::Leaf *createLeaf(syntax::Arena &A, TokenBufferTokenManager &TBTM, 0039 tok::TokenKind K); 0040 0041 // Synthesis of Trees 0042 /// Creates the concrete syntax node according to the specified `NodeKind` `K`. 0043 /// Returns it as a pointer to the base class `Tree`. 0044 syntax::Tree * 0045 createTree(syntax::Arena &A, 0046 ArrayRef<std::pair<syntax::Node *, syntax::NodeRole>> Children, 0047 syntax::NodeKind K); 0048 0049 // Synthesis of Syntax Nodes 0050 syntax::EmptyStatement *createEmptyStatement(syntax::Arena &A, 0051 TokenBufferTokenManager &TBTM); 0052 0053 /// Creates a completely independent copy of `N` with its macros expanded. 0054 /// 0055 /// The copy is: 0056 /// * Detached, i.e. `Parent == NextSibling == nullptr` and 0057 /// `Role == Detached`. 0058 /// * Synthesized, i.e. `Original == false`. 0059 syntax::Node *deepCopyExpandingMacros(syntax::Arena &A, 0060 TokenBufferTokenManager &TBTM, 0061 const syntax::Node *N); 0062 } // namespace syntax 0063 } // namespace clang 0064 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|