[PATCH] D90023: [Syntax] Add iterators over children of syntax trees.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 23 04:09:27 PDT 2020


sammccall created this revision.
sammccall added reviewers: gribozavr, eduucaldas.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
sammccall requested review of this revision.

This gives us slightly nicer syntax (foreach) for idioms currently expressed
as a loop, and the option to use range algorithms where it makes sense
(e.g. llvm::all_of et al encapsulate the needed flow control in a useful way).

It's also a building block for iteration over filtered views (e.g. iterate over
all Stmt children, with the right type):
for (const Statement &S : filter<Statement>(N.children()))

  ...

I realize the recent direction has been mostly towards strongly-typed
node-specific facilities, but I think it's important we have convenient
generic facilities too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90023

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90023.300218.patch
Type: text/x-patch
Size: 11611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201023/929217d1/attachment-0001.bin>


More information about the cfe-commits mailing list