[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

Eduardo Caldas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 14 08:38:09 PDT 2020


eduucaldas added inline comments.


================
Comment at: clang/include/clang/Tooling/Syntax/Tree.h:241-242
   /// "a; b; c"  <=> [("a" , ";"), ("b" , ";" ), ("c" , null)]
+  template <typename ElementType>
+  class ElementAndDelimiterIterator
+      : public llvm::iterator_facade_base<
----------------
Since we're gonna provide strongly-typed iterators, I make the Iterator a class template.

I keep the base functions as they were, `getElementAndDelimiterAfter...`, but I cast their result using `castToElementType`.

Another option would be to make the base functions also templated and not perform any casting.

We'll use `castToElementType` to provide the strongly-typed iterators as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88106/new/

https://reviews.llvm.org/D88106



More information about the cfe-commits mailing list