Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Object/SymbolicFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ template <class content_type> class content_iterator {

public:
using iterator_category = std::forward_iterator_tag;
using value_type = content_type;
using value_type = const content_type;
using difference_type = std::ptrdiff_t;
using pointer = value_type *;
using reference = value_type &;
Expand Down
23 changes: 23 additions & 0 deletions llvm/unittests/Object/SymbolicFileTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
//===----------------------------------------------------------------------===//

#include "llvm/Object/SymbolicFile.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this blank line. Headers should be included as one contiguous block, otherwise clang-format won't sort them properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

#include "gtest/gtest.h"
#include <sstream>

Expand Down Expand Up @@ -38,3 +40,24 @@ TEST(Object, DataRefImplOstream) {

EXPECT_EQ(Expected, s);
}

struct ProxyContent {
unsigned Index = 0;
ProxyContent(unsigned Index) : Index(Index) {};
void moveNext() { Index++; }

bool operator==(const ProxyContent &Another) const {
return Index == Another.Index;
}
};

TEST(Object, ContentIterator) {
using Iter = llvm::object::content_iterator<ProxyContent>;
auto Sequence = llvm::make_range(Iter(0u), Iter(10u));
auto EvenSequence = llvm::make_filter_range(
Sequence, [](auto &&PC) { return PC.Index % 2 == 0; });

for (auto &&[I, Value] : llvm::enumerate(EvenSequence)) {
EXPECT_EQ(I * 2u, Value.Index);
}
}
Loading