[PATCH] D76355: [Syntax] Build mapping from AST to syntax tree nodes

Marcel Hlopko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 23 05:26:07 PDT 2020


hlopko added inline comments.


================
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);
----------------
gribozavr2 wrote:
> 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.
Done and refactored all the calls that made sense to use the SourceRange method. I didn't modify call like Builder.getRange(L.getLBracketLoc(), L.getRBracketLoc()).


================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:975
+      const syntax::Token *TemplateKW,
+      syntax::SimpleDeclaration *InnerDeclaration) {
     assert(!ExternKW || ExternKW->kind() == tok::kw_extern);
----------------
gribozavr2 wrote:
> Add a `Decl *From` parameter and pass it through to `Builder.foldNode()` below?
Done, but to get rid of all nullptr parents in BuildTree.cpp we'd have to implement support for Types in the AST mapping. Let's not do that in this patch.


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