[PATCH] D50021: [Support] Add casting iterator adapters

Hamza Sood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 1 06:51:39 PDT 2018


hamzasood updated this revision to Diff 158526.
hamzasood retitled this revision from "[ADT] Add a static function pointer type" to "[Support] Add casting iterator adapters".
hamzasood added a comment.
Herald added a subscriber: mgorny.

The previous revision was an unnecessarily general solution to a specific problem.

I think there's a need for a special kind of `filter_iterator` that filters and casts based on the dynamic type of the elements, as determined by `llvm::dyn_cast`. In Clang there're at least 4 custom-written, entirely separate iterators that do just this: `specific_decl_itererator`, `filtered_decl_iterator`, `specific_clause_iterator`,` specific_attr_iterator`. And I'm at the point where I need to add yet another one.

This patch contains a generic iterator that yields `Derived *` from `Base *` by `dyn_cast`ing each element and filtering out those element whose dynamic type doesn't match.


https://reviews.llvm.org/D50021

Files:
  include/llvm/Support/CastingIterators.h
  unittests/Support/CMakeLists.txt
  unittests/Support/CastingIterators.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50021.158526.patch
Type: text/x-patch
Size: 7390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180801/bf60543a/attachment.bin>


More information about the llvm-commits mailing list