This is an archive of the discontinued LLVM Phabricator instance.

Add methods to data extractor for extracting bytes and fixed length C strings.
ClosedPublic

Authored by clayborg on Feb 21 2020, 3:21 PM.

Details

Summary

These modificaitons will be used in D74883.

Fixed length C strings can have trailing NULLs or sometimes spaces (BSD archive files), so the fixed length C string defaults to stripping trailing NULLs, but can have the arguments specify to remove one or more kinds of spaces if needed. This is used to extract fixed length C strings from ELF NOTEs in D74883.

Diff Detail

Event Timeline

clayborg created this revision.Feb 21 2020, 3:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2020, 3:21 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
aprantl added inline comments.Feb 24 2020, 8:47 AM
llvm/include/llvm/Support/DataExtractor.h
173

The comment is at odds with the return type. I think returning just a (potentially) empty StringRef as mentioned in the comment should be fine though.

198

same here

clayborg updated this revision to Diff 246263.Feb 24 2020, 11:06 AM

Switched to returning StringRef instead of Optional<StringRef> as suggested by Adrian. Comments are now correct.

aprantl accepted this revision.Feb 24 2020, 12:22 PM
aprantl added inline comments.
llvm/include/llvm/Support/DataExtractor.h
183

Sorry for not asking this in the first iteration...

If we don't expect a nullptr to be passed in here, I think it would be better to use a reference?

This revision is now accepted and ready to land.Feb 24 2020, 12:22 PM
This revision was automatically updated to reflect the committed changes.
clayborg marked an inline comment as done.Feb 24 2020, 2:31 PM
clayborg added inline comments.
llvm/include/llvm/Support/DataExtractor.h
183

I was keeping this consistent with all of the other calls since they all do the same thing.