This is an archive of the discontinued LLVM Phabricator instance.

[Support] Make DataExtractor string functions error-aware
ClosedPublic

Authored by labath on Apr 2 2020, 7:22 AM.

Details

Summary

This patch adds an optional Error argument to DataExtractor functions
for string extraction, and makes them behave like other DataExtractor
functions (set the error if extraction fails, don't do anything if the
error is already set).

I have merged the StringRef and c string versions of the functions to
reduce code duplication.

Diff Detail

Event Timeline

labath created this revision.Apr 2 2020, 7:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 2 2020, 7:22 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
probinson accepted this revision.Apr 2 2020, 8:26 AM
probinson added a subscriber: probinson.

One nit and LGTM.

llvm/lib/Support/DataExtractor.cpp
159

This is the only use of Result; eliminate the var and return StringRef() here.

This revision is now accepted and ready to land.Apr 2 2020, 8:26 AM
MaskRay accepted this revision.Apr 2 2020, 8:39 AM

Aside from the StringRef Result nit, in the description, c string versions -> C string versions.

dblaikie accepted this revision.Apr 2 2020, 4:05 PM

Looks good - thanks!

This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.