From f767cba05fb4152e98728d34ec138f7cf0447cea Mon Sep 17 00:00:00 2001 From: Joe Ranieri Date: Mon, 18 Mar 2024 12:29:19 -0400 Subject: [PATCH] Address review feedback --- doc/cpp/README.md | 1 + include/gtirb/ByteInterval.hpp | 57 ++++++++++++++++++++++------------ include/gtirb/DecodeMode.hpp | 2 +- include/gtirb/IR.hpp | 48 ++++++++++++++++++---------- include/gtirb/Module.hpp | 52 ++++++++++++++++++++----------- include/gtirb/Section.hpp | 54 +++++++++++++++++++++----------- src/test/ByteInterval.test.cpp | 9 +----- src/test/Section.test.cpp | 9 +----- src/test/TestHelpers.hpp | 30 ++++++++++++++++++ 9 files changed, 173 insertions(+), 89 deletions(-) create mode 100644 src/test/TestHelpers.hpp diff --git a/doc/cpp/README.md b/doc/cpp/README.md index 5afdaf5f..cdb26367 100644 --- a/doc/cpp/README.md +++ b/doc/cpp/README.md @@ -70,6 +70,7 @@ the repository at `gtirb/doc/examples/api-walkthrough.cpp`) for a basic introduction to using the GTIRB API in C++. ## Iteration Order +\anchor iteration_order ### Blocks diff --git a/include/gtirb/ByteInterval.hpp b/include/gtirb/ByteInterval.hpp index 2c3b7c72..991ef03b 100644 --- a/include/gtirb/ByteInterval.hpp +++ b/include/gtirb/ByteInterval.hpp @@ -353,35 +353,40 @@ class GTIRB_EXPORT_API ByteInterval : public Node { /// \brief Iterator over \ref Block objects. /// - /// Blocks are yielded in offset order, ascending. If two blocks have the - /// same offset, their order is not specified. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". + using block_iterator = boost::transform_iterator, BlockSet::index::type::iterator>; /// \brief Range of \ref Block objects. /// - /// Blocks are yielded in offset order, ascending. If two blocks have the - /// same offset, their order is not specified. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_range = boost::iterator_range; /// \brief Sub-range of blocks overlapping an address or range of addreses. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_subrange = boost::iterator_range, BlockIntMap::codomain_type::iterator>>; /// \brief Const iterator over \ref Block objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_iterator = boost::transform_iterator< BlockToNode, BlockSet::index::type::const_iterator>; /// \brief Const range of \ref Block objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_range = boost::iterator_range; /// \brief Const sub-range of blocks overlapping an address or range of /// addreses. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_subrange = boost::iterator_range, BlockIntMap::codomain_type::const_iterator>>; @@ -577,19 +582,22 @@ class GTIRB_EXPORT_API ByteInterval : public Node { /// \brief Iterator over \ref CodeBlock objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_iterator = boost::transform_iterator< BlockToNode, boost::filter_iterator, BlockSet::index::type::iterator>>; /// \brief Range of \ref CodeBlock objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_range = boost::iterator_range; /// \brief Sub-range of code blocks overlapping an address or range of /// addreses. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_subrange = boost::iterator_range, boost::filter_iterator< @@ -597,20 +605,23 @@ class GTIRB_EXPORT_API ByteInterval : public Node { boost::indirect_iterator>>>; /// \brief Const iterator over \ref CodeBlock objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_iterator = boost::transform_iterator< BlockToNode, boost::filter_iterator, BlockSet::index::type::const_iterator>>; /// \brief Const range of \ref CodeBlock objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_range = boost::iterator_range; /// \brief Const sub-range of code blocks overlapping an address or range of /// addreses. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_subrange = boost::iterator_range, @@ -828,19 +839,22 @@ class GTIRB_EXPORT_API ByteInterval : public Node { /// \brief Iterator over \ref DataBlock objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_iterator = boost::transform_iterator< BlockToNode, boost::filter_iterator, BlockSet::index::type::iterator>>; /// \brief Range of \ref DataBlock objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_range = boost::iterator_range; /// \brief Sub-range of data blocks overlapping an address or range of /// addreses. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_subrange = boost::iterator_range, boost::filter_iterator< @@ -848,20 +862,23 @@ class GTIRB_EXPORT_API ByteInterval : public Node { boost::indirect_iterator>>>; /// \brief Const iterator over \ref DataBlock objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_iterator = boost::transform_iterator< BlockToNode, boost::filter_iterator, BlockSet::index::type::const_iterator>>; /// \brief Const range of \ref DataBlock objects. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_range = boost::iterator_range; /// \brief Const sub-range of data blocks overlapping an address or range of /// addreses. /// - /// Blocks are yielded in offset order, ascending. + /// Blocks are yielded in offset order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_subrange = boost::iterator_range, diff --git a/include/gtirb/DecodeMode.hpp b/include/gtirb/DecodeMode.hpp index 1cbaa470..be5b5611 100644 --- a/include/gtirb/DecodeMode.hpp +++ b/include/gtirb/DecodeMode.hpp @@ -1,4 +1,4 @@ -//===- CodeBlock.hpp ---------------------------------------------*- C++-*-===// +//===- DecodeMode.hpp --------------------------------------------*- C++-*-===// // // Copyright (C) 2024 GrammaTech, Inc. // diff --git a/include/gtirb/IR.hpp b/include/gtirb/IR.hpp index d2b9cc07..97b086c9 100644 --- a/include/gtirb/IR.hpp +++ b/include/gtirb/IR.hpp @@ -777,30 +777,36 @@ class GTIRB_EXPORT_API IR : public AuxDataContainer { /// \brief Iterator over blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_iterator = MergeSortedIterator; /// \brief Range of blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_range = boost::iterator_range; /// \brief Sub-range of blocks overlapping an address or range of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_subrange = boost::iterator_range< MergeSortedIterator>; /// \brief Iterator over blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_iterator = MergeSortedIterator; /// \brief Range of blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_range = boost::iterator_range; /// \brief Sub-range of blocks overlapping an address or range of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_subrange = boost::iterator_range>; @@ -946,27 +952,32 @@ class GTIRB_EXPORT_API IR : public AuxDataContainer { /// \brief Iterator over \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_iterator = MergeSortedIterator; /// \brief Range of \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_range = boost::iterator_range; /// \brief Sub-range of \ref CodeBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_subrange = boost::iterator_range< MergeSortedIterator>; /// \brief Iterator over \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_iterator = MergeSortedIterator; /// \brief Range of \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_range = boost::iterator_range; /// \brief Sub-range of \ref CodeBlock objects overlapping an address or range @@ -1118,22 +1129,26 @@ class GTIRB_EXPORT_API IR : public AuxDataContainer { /// \brief Iterator over \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_iterator = MergeSortedIterator; /// \brief Range of \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_range = boost::iterator_range; /// \brief Sub-range of \ref DataBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_subrange = boost::iterator_range< MergeSortedIterator>; /// \brief Iterator over \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_iterator = MergeSortedIterator; /// \brief Range of \ref DataBlock objects. @@ -1144,7 +1159,8 @@ class GTIRB_EXPORT_API IR : public AuxDataContainer { /// \brief Sub-range of \ref DataBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_subrange = boost::iterator_range>; diff --git a/include/gtirb/Module.hpp b/include/gtirb/Module.hpp index 1b658147..aa976ba5 100644 --- a/include/gtirb/Module.hpp +++ b/include/gtirb/Module.hpp @@ -1065,26 +1065,31 @@ class GTIRB_EXPORT_API Module : public AuxDataContainer { /// \brief Iterator over blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_iterator = MergeSortedIterator; /// \brief Range of blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_range = boost::iterator_range; /// \brief Sub-range of blocks overlapping an address or range of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_subrange = boost::iterator_range< MergeSortedIterator>; /// \brief Iterator over blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_iterator = MergeSortedIterator; /// \brief Range of blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_range = boost::iterator_range; /// \brief Sub-range of blocks overlapping an address or range of addreses. /// @@ -1235,34 +1240,39 @@ class GTIRB_EXPORT_API Module : public AuxDataContainer { /// \brief Iterator over \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. If two blocks have the - /// same address, their order is not specified. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_iterator = MergeSortedIterator; /// \brief Range of \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_range = boost::iterator_range; /// \brief Sub-range of \ref CodeBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_subrange = boost::iterator_range< MergeSortedIterator>; /// \brief Iterator over \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_iterator = MergeSortedIterator; /// \brief Range of \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_range = boost::iterator_range; /// \brief Sub-range of \ref CodeBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_subrange = boost::iterator_range>; @@ -1421,33 +1431,39 @@ class GTIRB_EXPORT_API Module : public AuxDataContainer { /// \brief Iterator over \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_iterator = MergeSortedIterator; /// \brief Range of \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_range = boost::iterator_range; /// \brief Sub-range of \ref DataBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_subrange = boost::iterator_range< MergeSortedIterator>; /// \brief Iterator over \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_iterator = MergeSortedIterator; /// \brief Range of \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_range = boost::iterator_range; /// \brief Sub-range of \ref DataBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_subrange = boost::iterator_range>; diff --git a/include/gtirb/Section.hpp b/include/gtirb/Section.hpp index 77b17796..e764f883 100644 --- a/include/gtirb/Section.hpp +++ b/include/gtirb/Section.hpp @@ -366,31 +366,37 @@ class GTIRB_EXPORT_API Section : public Node { /// \brief Iterator over blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_iterator = MergeSortedIterator; /// \brief Range of blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_range = boost::iterator_range; /// \brief Sub-range of blocks overlapping an address or range of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using block_subrange = boost::iterator_range>; /// \brief Const iterator over blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_iterator = MergeSortedIterator; /// \brief Const range of blocks. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_range = boost::iterator_range; /// \brief Const sub-range of blocks overlapping an address or range of /// addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_block_subrange = boost::iterator_range>; @@ -533,33 +539,39 @@ class GTIRB_EXPORT_API Section : public Node { /// \brief Iterator over \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_iterator = MergeSortedIterator; /// \brief Range of \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_range = boost::iterator_range; /// \brief Sub-range of \ref CodeBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using code_block_subrange = boost::iterator_range>; /// \brief Iterator over \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_iterator = MergeSortedIterator; /// \brief Range of \ref CodeBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_range = boost::iterator_range; /// \brief Sub-range of \ref CodeBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_code_block_subrange = boost::iterator_range>; @@ -715,33 +727,39 @@ class GTIRB_EXPORT_API Section : public Node { /// \brief Iterator over \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_iterator = MergeSortedIterator; /// \brief Range of \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_range = boost::iterator_range; /// \brief Sub-range of \ref DataBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using data_block_subrange = boost::iterator_range>; /// \brief Iterator over \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_iterator = MergeSortedIterator; /// \brief Range of \ref DataBlock objects. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_range = boost::iterator_range; /// \brief Sub-range of \ref DataBlock objects overlapping an address or range /// of addreses. /// - /// Blocks are yielded in address order, ascending. + /// Blocks are yielded in address order, ascending. For more details, see + /// \ref iteration_order "the documentation on iteration order". using const_data_block_subrange = boost::iterator_range>; diff --git a/src/test/ByteInterval.test.cpp b/src/test/ByteInterval.test.cpp index 3a0a8f72..ffd7ff19 100644 --- a/src/test/ByteInterval.test.cpp +++ b/src/test/ByteInterval.test.cpp @@ -13,6 +13,7 @@ // //===----------------------------------------------------------------------===// #include "SerializationTestHarness.hpp" +#include "TestHelpers.hpp" #include #include #include @@ -25,14 +26,6 @@ using namespace gtirb; static Context Ctx; -// Transforms a range of references into a range of pointers. -template auto pointers(const RangeTy& Range) { - auto GetPointer = [](auto& arg) { return &arg; }; - return boost::make_iterator_range( - boost::make_transform_iterator(Range.begin(), GetPointer), - boost::make_transform_iterator(Range.end(), GetPointer)); -} - TEST(Unit_ByteInterval, compilationIteratorTypes) { static_assert(std::is_same_v); static_assert(std::is_same_v #include #include @@ -24,14 +25,6 @@ using namespace gtirb; static Context Ctx; -// Transforms a range of references into a range of pointers. -template auto pointers(const RangeTy& Range) { - auto GetPointer = [](auto& arg) { return &arg; }; - return boost::make_iterator_range( - boost::make_transform_iterator(Range.begin(), GetPointer), - boost::make_transform_iterator(Range.end(), GetPointer)); -} - TEST(Unit_Section, compilationIteratorTypes) { static_assert(std::is_same_v); static_assert( diff --git a/src/test/TestHelpers.hpp b/src/test/TestHelpers.hpp new file mode 100644 index 00000000..06841435 --- /dev/null +++ b/src/test/TestHelpers.hpp @@ -0,0 +1,30 @@ +//===- TestHelpers.hpp ------------------------------------------*- C++ -*-===// +// +// Copyright (C) 2024 GrammaTech, Inc. +// +// This code is licensed under the MIT license. See the LICENSE file in the +// project root for license terms. +// +// This project is sponsored by the Office of Naval Research, One Liberty +// Center, 875 N. Randolph Street, Arlington, VA 22203 under contract # +// N68335-17-C-0700. The content of the information does not necessarily +// reflect the position or policy of the Government and no official +// endorsement should be inferred. +// +//===----------------------------------------------------------------------===// + +#ifndef GTIRB_TEST_HELPERS_H +#define GTIRB_TEST_HELPERS_H + +#include +#include + +// Transforms a range of references into a range of pointers. +template auto pointers(const RangeTy& Range) { + auto GetPointer = [](auto& arg) { return &arg; }; + return boost::make_iterator_range( + boost::make_transform_iterator(Range.begin(), GetPointer), + boost::make_transform_iterator(Range.end(), GetPointer)); +} + +#endif // GTIRB_TEST_HELPERS_H