This is an archive of the discontinued LLVM Phabricator instance.

add a new API seek for the Cursor class in the DataExtractor.cpp
ClosedPublic

Authored by DiggerLin on Sep 10 2021, 6:28 AM.

Details

Summary

add a new API seek to set the Cursor to a new position.

Diff Detail

Event Timeline

DiggerLin created this revision.Sep 10 2021, 6:28 AM
DiggerLin requested review of this revision.Sep 10 2021, 6:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 10 2021, 6:28 AM
jhenderson added inline comments.Sep 10 2021, 6:56 AM
llvm/include/llvm/Support/DataExtractor.h
73

Perhaps add another sentence saying "This does not impact the error state."

llvm/unittests/Support/DataExtractorTest.cpp
181

I think you can simplify this testing: Cursor doesn't depend on DataExtractor, so you can just instantiate a Cursor and then call seek on it a couple of times to show what happens, like the following:

Cursor C(5);
C.seek(3);
EXPECT_EQ(3u, C.tell());
C.seek(8);
EXPECT_EQ(8u, C.tell());

This is different to tell, where reading data impacts the tell location.

DiggerLin marked 2 inline comments as done.Sep 10 2021, 8:12 AM
DiggerLin added inline comments.
llvm/include/llvm/Support/DataExtractor.h
73

thanks

llvm/unittests/Support/DataExtractorTest.cpp
181

thanks

DiggerLin updated this revision to Diff 371930.Sep 10 2021, 8:14 AM
DiggerLin marked 2 inline comments as done.

address comments

This revision is now accepted and ready to land.Sep 13 2021, 1:00 AM
MaskRay accepted this revision.Sep 13 2021, 9:57 AM

Looks great!