[PATCH] D76355: [Syntax] Build mapping from AST to syntax tree nodes
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 23 03:15:47 PDT 2020
gribozavr2 added inline comments.
================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:173
+private:
+ // Keys are either Stmt* or Decl*.
+ llvm::DenseMap<ASTPtr, syntax::Tree *> Nodes;
----------------
The comment is not needed anymore.
================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:490
+ if (C->role() == NodeRole::Detached)
+ C->Role = static_cast<unsigned>(NodeRole::Unknown);
+ Node->prependChildLowLevel(C);
----------------
Could you add a private setter that performs this cast? (The cast is repeated at least 3 times in this patch.)
================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:570
+ auto *N = new (allocator()) syntax::SimpleDeclarator;
+ Builder.foldNode(Builder.getRange(R.getBegin(), R.getEnd()), N, D);
+ Builder.markChild(N, syntax::NodeRole::SimpleDeclaration_declarator);
----------------
It might make sense to add a helper `Builder.getRange(SourceRange)` and simplify these calls to `Builder.getRange(something.getBegin(), something.getEnd())` throughout the patch.
================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:975
+ const syntax::Token *TemplateKW,
+ syntax::SimpleDeclaration *InnerDeclaration) {
assert(!ExternKW || ExternKW->kind() == tok::kw_extern);
----------------
Add a `Decl *From` parameter and pass it through to `Builder.foldNode()` below?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76355/new/
https://reviews.llvm.org/D76355
More information about the cfe-commits
mailing list