[PATCH] D109603: add a new API seek for the Cursor class in the DataExtractor.cpp
Digger Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 10 08:14:01 PDT 2021
DiggerLin updated this revision to Diff 371930.
DiggerLin marked 2 inline comments as done.
DiggerLin added a comment.
address comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109603/new/
https://reviews.llvm.org/D109603
Files:
llvm/include/llvm/Support/DataExtractor.h
llvm/unittests/Support/DataExtractorTest.cpp
Index: llvm/unittests/Support/DataExtractorTest.cpp
===================================================================
--- llvm/unittests/Support/DataExtractorTest.cpp
+++ llvm/unittests/Support/DataExtractorTest.cpp
@@ -177,6 +177,18 @@
consumeError(C.takeError());
}
+TEST(DataExtractorTest, Cursor_seek) {
+ DataExtractor::Cursor C(5);
+
+ C.seek(3);
+ EXPECT_EQ(3u, C.tell());
+
+ C.seek(8);
+ EXPECT_EQ(8u, C.tell());
+
+ EXPECT_THAT_ERROR(C.takeError(), Succeeded());
+}
+
TEST(DataExtractorTest, Cursor_takeError) {
DataExtractor DE(StringRef("AB"), false, 8);
DataExtractor::Cursor C(0);
Index: llvm/include/llvm/Support/DataExtractor.h
===================================================================
--- llvm/include/llvm/Support/DataExtractor.h
+++ llvm/include/llvm/Support/DataExtractor.h
@@ -70,6 +70,9 @@
/// the position of the Cursor before the first error was encountered.
uint64_t tell() const { return Offset; }
+ /// Set the cursor to the new offset. This does not impact the error state.
+ void seek(uint64_t NewOffSet) { Offset = NewOffSet; }
+
/// Return error contained inside this Cursor, if any. Clears the internal
/// Cursor state.
Error takeError() { return std::move(Err); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109603.371930.patch
Type: text/x-patch
Size: 1262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210910/786c67a3/attachment.bin>
More information about the llvm-commits
mailing list