[libFuzzer] Improve FuzzedDataProvider helper.
authorMax Moroz <mmoroz@chromium.org>
Tue, 18 Jun 2019 20:29:11 +0000 (20:29 +0000)
committerMax Moroz <mmoroz@chromium.org>
Tue, 18 Jun 2019 20:29:11 +0000 (20:29 +0000)
commita0eb49c26e53d05f983e1339e6a03d4eeb222d3a
treef3adde0daa5a4f93ec8f8eab9d6afa5416839861
parent9f3a805ee96b70ebe384ea6337c49464b5f28af2
[libFuzzer] Improve FuzzedDataProvider helper.

Summary:
The following changes are made based on the feedback from Tim King:
- Removed default template parameters, to have less assumptions.
- Implemented `ConsumeBytesWithTerminator` method.
- Made `PickValueInArray` method work with `initializer_list` argument.
- Got rid of `data_type` type alias, that was redundant.
- Refactored `ConsumeBytes` logic into a private method for better code reuse.
- Replaced implementation defined unsigned to signed conversion.
- Fixed `ConsumeRandomLengthString` to always call `shrink_to_fit`.
- Clarified and fixed some commments.
- Applied clang-format to both the library and the unittest source.

Tested on Linux, Mac, Windows.

Reviewers: morehouse, metzman

Reviewed By: morehouse

Subscribers: delcypher, #sanitizers, llvm-commits, kcc

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D63348

llvm-svn: 363735
compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp
compiler-rt/lib/fuzzer/utils/FuzzedDataProvider.h