[libFuzzer] when adding a reduced input print REDUCED instead of NEW

git-svn-id: svn://svn.chromium.org/llvm-project/llvm/trunk/lib/Fuzzer@308336 0b72dbe1-c17f-4bc7-b9db-2b4152be0356
diff --git a/FuzzerCorpus.h b/FuzzerCorpus.h
index 5d2a47d..bae0aea 100644
--- a/FuzzerCorpus.h
+++ b/FuzzerCorpus.h
@@ -34,6 +34,7 @@
   size_t NumExecutedMutations = 0;
   size_t NumSuccessfullMutations = 0;
   bool MayDeleteFile = false;
+  bool Reduced = false;
   std::vector<uint32_t> UniqFeatureSet;
 };
 
@@ -126,12 +127,13 @@
   }
 
   void Replace(InputInfo *II, const Unit &U) {
-    assert(II->U.size());
+    assert(II->U.size() > U.size());
     Hashes.erase(Sha1ToString(II->Sha1));
     DeleteFile(*II);
     ComputeSHA1(U.data(), U.size(), II->Sha1);
     Hashes.insert(Sha1ToString(II->Sha1));
     II->U = U;
+    II->Reduced = true;
   }
 
   bool HasUnit(const Unit &U) { return Hashes.count(Hash(U)); }
diff --git a/FuzzerInternal.h b/FuzzerInternal.h
index 8993f2c..3fc3fe0 100644
--- a/FuzzerInternal.h
+++ b/FuzzerInternal.h
@@ -99,7 +99,7 @@
   void WriteToOutputCorpus(const Unit &U);
   void WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix);
   void PrintStats(const char *Where, const char *End = "\n", size_t Units = 0);
-  void PrintStatusForNewUnit(const Unit &U);
+  void PrintStatusForNewUnit(const Unit &U, const char *Text);
   void ShuffleCorpus(UnitVector *V);
   void CheckExitOnSrcPosOrItem();
 
diff --git a/FuzzerLoop.cpp b/FuzzerLoop.cpp
index 046816c..8ac7a84 100644
--- a/FuzzerLoop.cpp
+++ b/FuzzerLoop.cpp
@@ -507,10 +507,10 @@
     Printf("Base64: %s\n", Base64(U).c_str());
 }
 
-void Fuzzer::PrintStatusForNewUnit(const Unit &U) {
+void Fuzzer::PrintStatusForNewUnit(const Unit &U, const char *Text) {
   if (!Options.PrintNEW)
     return;
-  PrintStats("NEW   ", "");
+  PrintStats(Text, "");
   if (Options.Verbosity) {
     Printf(" L: %zd ", U.size());
     MD.PrintMutationSequence();
@@ -521,7 +521,8 @@
 void Fuzzer::ReportNewCoverage(InputInfo *II, const Unit &U) {
   II->NumSuccessfullMutations++;
   MD.RecordSuccessfulMutationSequence();
-  PrintStatusForNewUnit(U);
+  PrintStatusForNewUnit(U, II->Reduced ? "REDUCE" :
+                                         "NEW   ");
   WriteToOutputCorpus(U);
   NumberOfNewUnitsAdded++;
   TPC.PrintNewPCs();