21 #ifndef LLVM_CLANG_TOOLING_SYNTAX_TREE_CASCADE_H 22 #define LLVM_CLANG_TOOLING_SYNTAX_TREE_CASCADE_H 29 #include "llvm/ADT/ArrayRef.h" 30 #include "llvm/ADT/DenseMap.h" 31 #include "llvm/Support/Allocator.h" 48 llvm::BumpPtrAllocator &
allocator() {
return Allocator; }
53 std::pair<FileID, llvm::ArrayRef<syntax::Token>>
54 lexBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer);
61 llvm::DenseMap<FileID, std::vector<syntax::Token>> ExtraTokens;
63 llvm::BumpPtrAllocator Allocator;
86 bool isDetached()
const;
111 std::string dumpTokens(
const Arena &A)
const;
115 void assertInvariants()
const;
117 void assertInvariantsRecursive()
const;
123 friend class TreeBuilder;
133 unsigned Original : 1;
134 unsigned CanModify : 1;
160 return const_cast<Tree *
>(
this)->firstLeaf();
176 friend class TreeBuilder;
183 void replaceChildRangeLowLevel(
Node *BeforeBegin,
Node *
End,
Node *New);
186 Node *FirstChild =
nullptr;
const syntax::Token * token() const
std::pair< FileID, llvm::ArrayRef< syntax::Token > > lexBuffer(std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add Buffer to the underlying source manager, tokenize it and store the resulting tokens.
Defines the SourceManager interface.
A token coming directly from a file or from a macro invocation.
Node(NodeKind Kind)
Newly created nodes are detached from a tree, parent and sibling links are set when the node is added...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
const SourceManager & sourceManager() const
llvm::BumpPtrAllocator & allocator()
const LangOptions & langOptions() const
const TokenBuffer & tokenBuffer() const
A memory arena for syntax trees.
bool canModify() const
If this function return false, the tree cannot be modified because there is no reasonable way to prod...
Defines the clang::LangOptions interface.
const Node * nextSibling() const
A node that has children and represents a syntactic language construct.
NodeKind
A kind of a syntax node, used for implementing casts.
const Tree * parent() const
const Leaf * lastLeaf() const
Exposes private syntax tree APIs required to implement node synthesis.
ast_type_traits::DynTypedNode Node
NodeRole
A relation between a parent and child node, e.g.
Dataflow Directional Tag Classes.
Arena(SourceManager &SourceMgr, const LangOptions &LangOpts, TokenBuffer Tokens)
A leaf node points to a single token inside the expanded token stream.
bool isOriginal() const
Whether the node was created from the AST backed by the source code rather than added later through m...
static bool classof(const OMPClause *T)
Defines the clang::TokenKind enum and support functions.
Defines the clang::SourceLocation class and associated facilities.
const Leaf * firstLeaf() const
A list of tokens obtained by preprocessing a text buffer and operations to map between the expanded a...
const Node * firstChild() const
This class handles loading and caching of source files into memory.