[Support] Make DataExtractor string functions error-aware
authorPavel Labath <pavel@labath.sk>
Mon, 23 Mar 2020 15:15:49 +0000 (16:15 +0100)
committerPavel Labath <pavel@labath.sk>
Mon, 6 Apr 2020 12:14:11 +0000 (14:14 +0200)
commita16fffa3f6add51fe1c6ee975ace56aa06a3bea7
treef6437870891a7066feb1231d4b933ff4649df35e
parentff858d77810a5565a1f668c8e900a5e8659817be
[Support] Make DataExtractor string functions error-aware

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.

Reviewers: dblaikie, MaskRay

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77307
llvm/include/llvm/Support/DataExtractor.h
llvm/lib/Support/DataExtractor.cpp
llvm/unittests/Support/DataExtractorTest.cpp