aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Fuzzer/FuzzerLoop.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-03-31 04:17:45 +0000
committerKostya Serebryany <kcc@google.com>2017-03-31 04:17:45 +0000
commita617e16ff128c8aeac28212b5f06df212f6bbf3e (patch)
tree938c9d4f1b33cc7f962b8f946410919ffb6680dc /llvm/lib/Fuzzer/FuzzerLoop.cpp
parent7de1f1a826a9f1848e09f7c312fb47f00f8d589e (diff)
downloadllvm-a617e16ff128c8aeac28212b5f06df212f6bbf3e.zip
llvm-a617e16ff128c8aeac28212b5f06df212f6bbf3e.tar.gz
llvm-a617e16ff128c8aeac28212b5f06df212f6bbf3e.tar.bz2
[libFuzzer] simplify the code a bit
llvm-svn: 299180
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerLoop.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp
index 5c9dbc0..7040928 100644
--- a/llvm/lib/Fuzzer/FuzzerLoop.cpp
+++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp
@@ -407,11 +407,11 @@ size_t Fuzzer::RunOne(const uint8_t *Data, size_t Size) {
ExecuteCallback(Data, Size);
- size_t Res = 0;
- if (size_t NumFeatures = TPC.CollectFeatures([&](size_t Feature) -> bool {
- return Corpus.AddFeature(Feature, Size, Options.Shrink);
- }))
- Res = NumFeatures;
+ size_t NumUpdatesBefore = Corpus.NumFeatureUpdates();
+ TPC.CollectFeatures([&](size_t Feature) {
+ Corpus.AddFeature(Feature, Size, Options.Shrink);
+ });
+ size_t NumUpdatesAfter = Corpus.NumFeatureUpdates();
auto TimeOfUnit =
duration_cast<seconds>(UnitStopTime - UnitStartTime).count();
@@ -424,7 +424,7 @@ size_t Fuzzer::RunOne(const uint8_t *Data, size_t Size) {
Printf("Slowest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
WriteUnitToFileWithPrefix({Data, Data + Size}, "slow-unit-");
}
- return Res;
+ return NumUpdatesAfter - NumUpdatesBefore;
}
size_t Fuzzer::GetCurrentUnitInFuzzingThead(const uint8_t **Data) const {