[all-commits] [llvm/llvm-project] d4934e: [Syntax] Add iterators over children of syntax trees.

Sam McCall via All-commits all-commits at lists.llvm.org
Wed Oct 28 04:38:21 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d4934eb5f876cdc97a9a8665bd654351fbbcb66b
      https://github.com/llvm/llvm-project/commit/d4934eb5f876cdc97a9a8665bd654351fbbcb66b
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2020-10-28 (Wed, 28 Oct 2020)

  Changed paths:
    M clang/include/clang/Tooling/Syntax/Tree.h
    M clang/lib/Tooling/Syntax/Tree.cpp
    M clang/unittests/Tooling/Syntax/TreeTest.cpp
    M clang/unittests/Tooling/Syntax/TreeTestBase.h

  Log Message:
  -----------
  [Syntax] Add iterators over children of syntax trees.

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.

Differential Revision: https://reviews.llvm.org/D90023




More information about the All-commits mailing list