summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyndy Ishida <cyndy_ishida@apple.com>2019-09-05 17:33:44 +0000
committerCyndy Ishida <cyndy_ishida@apple.com>2019-09-05 17:33:44 +0000
commit541ab7130e2c34097fd9e15f70ce193a37c2ad19 (patch)
treebabf8a841f24a3b038e37905c4b7972500d79ab3
parente3e6624ca2d0e2cc31793aa36dd07c35683a2f14 (diff)
downloadbcm5719-llvm-541ab7130e2c34097fd9e15f70ce193a37c2ad19.tar.gz
bcm5719-llvm-541ab7130e2c34097fd9e15f70ce193a37c2ad19.zip
[TextAPI] update interface file for filtered iter
Summary: This is a simple change that allows easy iterator semantics for symbols held in interface file. Not being used, so harmless change right now, but will be once TBD-v4 is submitted. Reviewers: ributzka, steven_wu Reviewed By: ributzka Subscribers: javed.absar, kristof.beyls, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67204 llvm-svn: 371097
-rw-r--r--llvm/include/llvm/TextAPI/MachO/InterfaceFile.h93
1 files changed, 22 insertions, 71 deletions
diff --git a/llvm/include/llvm/TextAPI/MachO/InterfaceFile.h b/llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
index e722449d52f..323b0509585 100644
--- a/llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
+++ b/llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
@@ -320,84 +320,35 @@ public:
reference operator*() const { return I->second; }
pointer operator->() const { return I->second; }
};
- using const_symbol_range = iterator_range<const_symbol_iterator>;
-
- // Custom iterator to return only exported symbols.
- struct const_export_iterator
- : public iterator_adaptor_base<
- const_export_iterator, const_symbol_iterator,
- std::forward_iterator_tag, const Symbol *> {
- const_symbol_iterator _end;
-
- void skipToNextSymbol() {
- while (I != _end && I->isUndefined())
- ++I;
- }
-
- const_export_iterator() = default;
- template <typename U>
- const_export_iterator(U &&it, U &&end)
- : iterator_adaptor_base(std::forward<U &&>(it)),
- _end(std::forward<U &&>(end)) {
- skipToNextSymbol();
- }
-
- const_export_iterator &operator++() {
- ++I;
- skipToNextSymbol();
- return *this;
- }
-
- const_export_iterator operator++(int) {
- const_export_iterator tmp(*this);
- ++(*this);
- return tmp;
- }
- };
- using const_export_range = llvm::iterator_range<const_export_iterator>;
- // Custom iterator to return only undefined symbols.
- struct const_undefined_iterator
- : public iterator_adaptor_base<
- const_undefined_iterator, const_symbol_iterator,
- std::forward_iterator_tag, const Symbol *> {
- const_symbol_iterator _end;
+ using const_symbol_range = iterator_range<const_symbol_iterator>;
- void skipToNextSymbol() {
- while (I != _end && !I->isUndefined())
- ++I;
- }
-
- const_undefined_iterator() = default;
- template <typename U>
- const_undefined_iterator(U &&it, U &&end)
- : iterator_adaptor_base(std::forward<U &&>(it)),
- _end(std::forward<U &&>(end)) {
- skipToNextSymbol();
- }
-
- const_undefined_iterator &operator++() {
- ++I;
- skipToNextSymbol();
- return *this;
- }
-
- const_undefined_iterator operator++(int) {
- const_undefined_iterator tmp(*this);
- ++(*this);
- return tmp;
- }
- };
- using const_undefined_range = llvm::iterator_range<const_undefined_iterator>;
+ using const_filtered_symbol_iterator =
+ filter_iterator<const_symbol_iterator,
+ std::function<bool(const Symbol *)>>;
+ using const_filtered_symbol_range =
+ iterator_range<const_filtered_symbol_iterator>;
const_symbol_range symbols() const {
return {Symbols.begin(), Symbols.end()};
}
- const_export_range exports() const {
- return {{Symbols.begin(), Symbols.end()}, {Symbols.end(), Symbols.end()}};
+
+ const_filtered_symbol_range exports() const {
+ std::function<bool(const Symbol *)> fn = [](const Symbol *Symbol) {
+ return !Symbol->isUndefined();
+ };
+ return make_filter_range(
+ make_range<const_symbol_iterator>({Symbols.begin()}, {Symbols.end()}),
+ fn);
}
- const_undefined_range undefineds() const {
- return {{Symbols.begin(), Symbols.end()}, {Symbols.end(), Symbols.end()}};
+
+ const_filtered_symbol_range undefineds() const {
+ std::function<bool(const Symbol *)> fn = [](const Symbol *Symbol) {
+ return Symbol->isUndefined();
+ };
+ return make_filter_range(
+ make_range<const_symbol_iterator>({Symbols.begin()}, {Symbols.end()}),
+ fn);
}
private:
OpenPOWER on IntegriCloud