This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] FDP: add ConsumeRandomLengthString() version without arguments.
ClosedPublic

Authored by Dor1s on Mar 19 2020, 12:44 PM.

Diff Detail

Event Timeline

Dor1s created this revision.Mar 19 2020, 12:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2020, 12:44 PM
Herald added subscribers: Restricted Project, dberris. · View Herald Transcript

PTAL, this is a small change requested/suggested by Mitch. I have another one ready (which is a large refactoring) that would come after.

Dor1s retitled this revision from [compiler-rt] Add ConsumeRandomLengthString() version without arguments. to [compiler-rt] FDP: add ConsumeRandomLengthString() version without arguments..Mar 19 2020, 12:46 PM
hctim added inline comments.Mar 19 2020, 1:18 PM
compiler-rt/include/fuzzer/FuzzedDataProvider.h
115

Why not just:

std::string ConsumeRandomLengthString(size_t max_length = remaining_bytes_) {?

Dor1s marked an inline comment as done.Mar 19 2020, 1:51 PM
Dor1s added inline comments.
compiler-rt/include/fuzzer/FuzzedDataProvider.h
115

I don't think a non-const value can be used for the default argument

Dor1s updated this revision to Diff 251471.Mar 19 2020, 2:03 PM

fix tidy error

hctim accepted this revision.Mar 19 2020, 2:32 PM

LGTM w/ one comment

compiler-rt/include/fuzzer/FuzzedDataProvider.h
115

Maybe I'm being silly, but this shouldn't be an issue, no? https://godbolt.org/z/46E8ht

This revision is now accepted and ready to land.Mar 19 2020, 2:32 PM
Dor1s updated this revision to Diff 251485.Mar 19 2020, 3:00 PM

make the linter happy #2

Dor1s marked an inline comment as done.Mar 19 2020, 3:04 PM
Dor1s added inline comments.
compiler-rt/include/fuzzer/FuzzedDataProvider.h
115

hm, looks like it's not necessarily should be const, but anyhow it can't be a "non-static data member"

In file included from <...>/llvm-project/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp:9:
<...>/llvm-build/lib/clang/11.0.0/include/fuzzer/FuzzedDataProvider.h:115:61: error: invalid use of non-static data member 'remaining_bytes_'
  std::string ConsumeRandomLengthString(size_t max_length = remaining_bytes_) {
                                                            ^~~~~~~~~~~~~~~~
1 error generated.

same in gcc: https://godbolt.org/z/DdVHv4

hctim accepted this revision.Mar 19 2020, 4:00 PM
hctim marked an inline comment as done.
hctim added inline comments.
compiler-rt/include/fuzzer/FuzzedDataProvider.h
115

TIL - LGTM.

metzman accepted this revision.Mar 19 2020, 5:11 PM

LGTM

This revision was automatically updated to reflect the committed changes.