<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 29, 2015 at 8:28 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>On Thu, Jan 29, 2015 at 11:27 AM, Kostya Serebryany <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>> wrote:<br>
><br>
><br>
> On Thu, Jan 29, 2015 at 8:18 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>><br>
> wrote:<br>
>><br>
>> On Thu, Jan 29, 2015 at 11:11 AM, Kostya Serebryany <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>><br>
>> wrote:<br>
>> ><br>
>> ><br>
>> > On Thu, Jan 29, 2015 at 7:28 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Actually, this is completely broken on Windows and should be reverted<br>
>> >> until it is fixed up. Comments below.<br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> >><br>
>> >><br>
>> >> On Thu, Jan 29, 2015 at 10:11 AM, Aaron Ballman<br>
>> >> <<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>><br>
>> >> wrote:<br>
>> >> > This commit puts the fuzzer targets on the top-level for MSVC<br>
>> >> > solutions when they should be in a separate folder instead. Picture<br>
>> >> > attached is worth 1000 words. ;-)<br>
>> >> ><br>
>> >> > ~Aaron<br>
>> >> ><br>
>> >> > On Tue, Jan 27, 2015 at 5:08 PM, Kostya Serebryany <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>><br>
>> >> > wrote:<br>
>> >> >> Author: kcc<br>
>> >> >> Date: Tue Jan 27 16:08:41 2015<br>
>> >> >> New Revision: 227252<br>
>> >> >><br>
>> >> >> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227252&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=227252&view=rev</a><br>
>> >> >> Log:<br>
>> >> >> Add a Fuzzer library<br>
>> >> >><br>
>> >> >> Summary:<br>
>> >> >> A simple genetic in-process coverage-guided fuzz testing library.<br>
>> >> >><br>
>> >> >> I've used this fuzzer to test clang-format<br>
>> >> >> (it found 12+ bugs, thanks djasper@ for the fixes!)<br>
>> >> >> and it may also help us test other parts of LLVM.<br>
>> >> >> So why not keep it in the LLVM repository?<br>
>> >> >><br>
>> >> >> I plan to add the cmake build rules later (in a separate patch, if<br>
>> >> >> that's ok)<br>
>> >> >> and also add a clang-format-fuzzer target.<br>
>> >> >><br>
>> >> >> See README.txt for details.<br>
>> >> >><br>
>> >> >> Test Plan: Tests will follow separately.<br>
>> >> >><br>
>> >> >> Reviewers: djasper, chandlerc, rnk<br>
>> >> >><br>
>> >> >> Reviewed By: rnk<br>
>> >> >><br>
>> >> >> Subscribers: majnemer, ygribov, dblaikie, llvm-commits<br>
>> >> >><br>
>> >> >> Differential Revision: <a href="http://reviews.llvm.org/D7184" target="_blank">http://reviews.llvm.org/D7184</a><br>
>> >> >><br>
>> >> >> Added:<br>
>> >> >>     llvm/trunk/lib/Fuzzer/<br>
>> >> >>     llvm/trunk/lib/Fuzzer/CMakeLists.txt<br>
>> >> >>     llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/FuzzerFlags.def<br>
>> >> >>     llvm/trunk/lib/Fuzzer/FuzzerIO.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/FuzzerInternal.h<br>
>> >> >>     llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/FuzzerMain.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/README.txt<br>
>> >> >>     llvm/trunk/lib/Fuzzer/test/<br>
>> >> >>     llvm/trunk/lib/Fuzzer/test/ExactTest.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/test/InfiniteTest.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/test/NullDerefTest.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/test/SimpleTest.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/test/TestFuzzerCrossOver.cpp<br>
>> >> >>     llvm/trunk/lib/Fuzzer/test/TimeoutTest.cpp<br>
>> >> >> Modified:<br>
>> >> >>     llvm/trunk/lib/CMakeLists.txt<br>
>> >> >><br>
>> >> >> Modified: llvm/trunk/lib/CMakeLists.txt<br>
>> >> >> URL:<br>
>> >> >><br>
>> >> >> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CMakeLists.txt?rev=227252&r1=227251&r2=227252&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CMakeLists.txt?rev=227252&r1=227251&r2=227252&view=diff</a><br>
>> >> >><br>
>> >> >><br>
>> >> >> ==============================================================================<br>
>> >> >> --- llvm/trunk/lib/CMakeLists.txt (original)<br>
>> >> >> +++ llvm/trunk/lib/CMakeLists.txt Tue Jan 27 16:08:41 2015<br>
>> >> >> @@ -17,3 +17,4 @@ add_subdirectory(Target)<br>
>> >> >>  add_subdirectory(AsmParser)<br>
>> >> >>  add_subdirectory(LineEditor)<br>
>> >> >>  add_subdirectory(ProfileData)<br>
>> >> >> +add_subdirectory(Fuzzer)<br>
>> >> >><br>
>> >> >> Added: llvm/trunk/lib/Fuzzer/CMakeLists.txt<br>
>> >> >> URL:<br>
>> >> >><br>
>> >> >> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/CMakeLists.txt?rev=227252&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/CMakeLists.txt?rev=227252&view=auto</a><br>
>> >> >><br>
>> >> >><br>
>> >> >> ==============================================================================<br>
>> >> >> --- llvm/trunk/lib/Fuzzer/CMakeLists.txt (added)<br>
>> >> >> +++ llvm/trunk/lib/Fuzzer/CMakeLists.txt Tue Jan 27 16:08:41 2015<br>
>> >> >> @@ -0,0 +1,9 @@<br>
>> >> >> +add_library(LLVMFuzzer STATIC<br>
>> >> >> +  EXCLUDE_FROM_ALL  # Do not build if you are not building fuzzers.<br>
>> >> >> +  FuzzerCrossOver.cpp<br>
>> >> >> +  FuzzerIO.cpp<br>
>> >> >> +  FuzzerLoop.cpp<br>
>> >> >> +  FuzzerMain.cpp<br>
>> >> >> +  FuzzerMutate.cpp<br>
>> >> >> +  FuzzerUtil.cpp<br>
>> >> >> +  )<br>
>> >> >><br>
>> >> >> Added: llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp<br>
>> >> >> URL:<br>
>> >> >><br>
>> >> >> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp?rev=227252&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp?rev=227252&view=auto</a><br>
>> >> >><br>
>> >> >><br>
>> >> >> ==============================================================================<br>
>> >> >> --- llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp (added)<br>
>> >> >> +++ llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp Tue Jan 27 16:08:41<br>
>> >> >> 2015<br>
>> >> >> @@ -0,0 +1,46 @@<br>
>> >> >> +//===- FuzzerCrossOver.cpp - Cross over two test inputs<br>
>> >> >> -------------------===//<br>
>> >> >> +//<br>
>> >> >> +//                     The LLVM Compiler Infrastructure<br>
>> >> >> +//<br>
>> >> >> +// This file is distributed under the University of Illinois Open<br>
>> >> >> Source<br>
>> >> >> +// License. See LICENSE.TXT for details.<br>
>> >> >> +//<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +// Cross over test inputs.<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +<br>
>> >> >> +#include "FuzzerInternal.h"<br>
>> >> >> +<br>
>> >> >> +namespace fuzzer {<br>
>> >> >> +<br>
>> >> >> +// Cross A and B, store the result (ap to MaxLen bytes) in U.<br>
>> >> >> +void CrossOver(const Unit &A, const Unit &B, Unit *U, size_t<br>
>> >> >> MaxLen) {<br>
>> >> >> +  size_t Size = rand() % MaxLen + 1;<br>
>> >> >> +  U->clear();<br>
>> >> >> +  const Unit *V = &A;<br>
>> >> >> +  size_t PosA = 0;<br>
>> >> >> +  size_t PosB = 0;<br>
>> >> >> +  size_t *Pos = &PosA;<br>
>> >> >> +  while (U->size() < Size && (PosA < A.size() || PosB < B.size()))<br>
>> >> >> {<br>
>> >> >> +    // Merge a part of V into U.<br>
>> >> >> +    size_t SizeLeftU = Size - U->size();<br>
>> >> >> +    if (*Pos < V->size()) {<br>
>> >> >> +      size_t SizeLeftV = V->size() - *Pos;<br>
>> >> >> +      size_t MaxExtraSize = std::min(SizeLeftU, SizeLeftV);<br>
>> >> >> +      size_t ExtraSize = rand() % MaxExtraSize + 1;<br>
>> >> >> +      U->insert(U->end(), V->begin() + *Pos, V->begin() + *Pos +<br>
>> >> >> ExtraSize);<br>
>> >> >> +      (*Pos) += ExtraSize;<br>
>> >> >> +    }<br>
>> >> >> +<br>
>> >> >> +    // Use the other Unit on the next iteration.<br>
>> >> >> +    if (Pos == &PosA) {<br>
>> >> >> +      Pos = &PosB;<br>
>> >> >> +      V = &B;<br>
>> >> >> +    } else {<br>
>> >> >> +      Pos = &PosA;<br>
>> >> >> +      V = &A;<br>
>> >> >> +    }<br>
>> >> >> +  }<br>
>> >> >> +}<br>
>> >> >> +<br>
>> >> >> +}  // namespace fuzzer<br>
>> >> >><br>
>> >> >> Added: llvm/trunk/lib/Fuzzer/FuzzerFlags.def<br>
>> >> >> URL:<br>
>> >> >><br>
>> >> >> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerFlags.def?rev=227252&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerFlags.def?rev=227252&view=auto</a><br>
>> >> >><br>
>> >> >><br>
>> >> >> ==============================================================================<br>
>> >> >> --- llvm/trunk/lib/Fuzzer/FuzzerFlags.def (added)<br>
>> >> >> +++ llvm/trunk/lib/Fuzzer/FuzzerFlags.def Tue Jan 27 16:08:41 2015<br>
>> >> >> @@ -0,0 +1,24 @@<br>
>> >> >> +//===- FuzzerFlags.def - Run-time flags -------------------------*-<br>
>> >> >> C++ -* ===//<br>
>> >> >> +//<br>
>> >> >> +//                     The LLVM Compiler Infrastructure<br>
>> >> >> +//<br>
>> >> >> +// This file is distributed under the University of Illinois Open<br>
>> >> >> Source<br>
>> >> >> +// License. See LICENSE.TXT for details.<br>
>> >> >> +//<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +// Flags. FUZZER_FLAG macro should be defined at the point of<br>
>> >> >> inclusion.<br>
>> >> >> +// We are not using any flag parsing library for better portability<br>
>> >> >> and<br>
>> >> >> +// independence.<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +FUZZER_FLAG(int, verbosity, 1, "Verbosity level.")<br>
>> >> >> +FUZZER_FLAG(int, seed, 0, "Random seed. If 0, seed is generated.")<br>
>> >> >> +FUZZER_FLAG(int, iterations, -1,<br>
>> >> >> +            "Number of iterations of the fuzzer (-1 for infinite<br>
>> >> >> runs).")<br>
>> >> >> +FUZZER_FLAG(int, max_len, 64, "Maximal length of the test input.")<br>
>> >> >> +FUZZER_FLAG(int, cross_over, 1, "If 1, cross over inputs.")<br>
>> >> >> +FUZZER_FLAG(int, mutate_depth, 10,<br>
>> >> >> +            "Apply this number of consecutive mutations to each<br>
>> >> >> input.")<br>
>> >> >> +FUZZER_FLAG(int, exit_on_first, 0,<br>
>> >> >> +            "If 1, exit after the first new interesting input is<br>
>> >> >> found.")<br>
>> >> >> +FUZZER_FLAG(int, timeout, -1, "Timeout in seconds (if positive).")<br>
>> >> >> +FUZZER_FLAG(int, help, 0, "Print help.")<br>
>> >> >><br>
>> >> >> Added: llvm/trunk/lib/Fuzzer/FuzzerIO.cpp<br>
>> >> >> URL:<br>
>> >> >><br>
>> >> >> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerIO.cpp?rev=227252&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerIO.cpp?rev=227252&view=auto</a><br>
>> >> >><br>
>> >> >><br>
>> >> >> ==============================================================================<br>
>> >> >> --- llvm/trunk/lib/Fuzzer/FuzzerIO.cpp (added)<br>
>> >> >> +++ llvm/trunk/lib/Fuzzer/FuzzerIO.cpp Tue Jan 27 16:08:41 2015<br>
>> >> >> @@ -0,0 +1,44 @@<br>
>> >> >> +//===- FuzzerIO.cpp - IO utils.<br>
>> >> >> -------------------------------------------===//<br>
>> >> >> +//<br>
>> >> >> +//                     The LLVM Compiler Infrastructure<br>
>> >> >> +//<br>
>> >> >> +// This file is distributed under the University of Illinois Open<br>
>> >> >> Source<br>
>> >> >> +// License. See LICENSE.TXT for details.<br>
>> >> >> +//<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +// IO functions.<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +#include "FuzzerInternal.h"<br>
>> >> >> +#include <fstream><br>
>> >> >> +#include <dirent.h><br>
>> >><br>
>> >> dirent.h does not exist on Windows with MSVC.<br>
>> >><br>
>> >> >> +namespace fuzzer {<br>
>> >> >> +<br>
>> >> >> +std::vector<std::string> ListFilesInDir(const std::string &Dir) {<br>
>> >> >> +  std::vector<std::string> V;<br>
>> >> >> +  DIR *D = opendir(Dir.c_str());<br>
>> >> >> +  if (!D) return V;<br>
>> >> >> +  while (auto E = readdir(D)) {<br>
>> >> >> +    if (E->d_type == DT_REG || E->d_type == DT_LNK)<br>
>> >> >> +      V.push_back(E->d_name);<br>
>> >> >> +  }<br>
>> >> >> +  closedir(D);<br>
>> >> >> +  return V;<br>
>> >><br>
>> >> We have filesystem APIs to do this, don't we?<br>
>> >><br>
>> ><br>
>> > As the README.txt explains, this library can not use any of the great<br>
>> > LLVM<br>
>> > support.<br>
>> > It has to remain independent. I amy even have to remove the use of STL<br>
>> > from<br>
>> > it later.<br>
>> ><br>
>> >><br>
>> >> >> +}<br>
>> >> >> +<br>
>> >> >> +Unit FileToVector(const std::string &Path) {<br>
>> >> >> +  std::ifstream T(Path);<br>
>> >> >> +  return Unit((std::istreambuf_iterator<char>(T)),<br>
>> >> >> +              std::istreambuf_iterator<char>());<br>
>> >> >> +}<br>
>> >> >> +<br>
>> >> >> +void WriteToFile(const Unit &U, const std::string &Path) {<br>
>> >> >> +  std::ofstream OF(Path);<br>
>> >> >> +  OF.write((const char*)U.data(), U.size());<br>
>> >> >> +}<br>
>> >> >> +<br>
>> >> >> +void ReadDirToVectorOfUnits(const char *Path, std::vector<Unit> *V)<br>
>> >> >> {<br>
>> >> >> +  for (auto &X : ListFilesInDir(Path))<br>
>> >> >> +    V->push_back(FileToVector(std::string(Path) + "/" + X));<br>
>> >> >> +}<br>
>> >> >> +<br>
>> >> >> +}  // namespace fuzzer<br>
>> >> >><br>
>> >> >> Added: llvm/trunk/lib/Fuzzer/FuzzerInternal.h<br>
>> >> >> URL:<br>
>> >> >><br>
>> >> >> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerInternal.h?rev=227252&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerInternal.h?rev=227252&view=auto</a><br>
>> >> >><br>
>> >> >><br>
>> >> >> ==============================================================================<br>
>> >> >> --- llvm/trunk/lib/Fuzzer/FuzzerInternal.h (added)<br>
>> >> >> +++ llvm/trunk/lib/Fuzzer/FuzzerInternal.h Tue Jan 27 16:08:41 2015<br>
>> >> >> @@ -0,0 +1,77 @@<br>
>> >> >> +//===- FuzzerInternal.h - Internal header for the Fuzzer --------*-<br>
>> >> >> C++ -* ===//<br>
>> >> >> +//<br>
>> >> >> +//                     The LLVM Compiler Infrastructure<br>
>> >> >> +//<br>
>> >> >> +// This file is distributed under the University of Illinois Open<br>
>> >> >> Source<br>
>> >> >> +// License. See LICENSE.TXT for details.<br>
>> >> >> +//<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +// Define the main class fuzzer::Fuzzer and most functions.<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +#include <cassert><br>
>> >> >> +#include <chrono><br>
>> >> >> +#include <cstddef><br>
>> >> >> +#include <cstdlib><br>
>> >> >> +#include <string><br>
>> >> >> +#include <vector><br>
>> >> >> +<br>
>> >> >> +namespace fuzzer {<br>
>> >> >> +typedef std::vector<uint8_t> Unit;<br>
>> >> >> +using namespace std::chrono;<br>
>> >> >> +<br>
>> >> >> +Unit ReadFile(const char *Path);<br>
>> >> >> +std::vector<std::string> ListFilesInDir(const std::string &Dir);<br>
>> >> >> +void ReadDirToVectorOfUnits(const char *Path, std::vector<Unit><br>
>> >> >> *V);<br>
>> >> >> +void WriteToFile(const Unit &U, const std::string &Path);<br>
>> >> >> +<br>
>> >> >> +void Mutate(Unit *U, size_t MaxLen);<br>
>> >> >> +<br>
>> >> >> +void CrossOver(const Unit &A, const Unit &B, Unit *U, size_t<br>
>> >> >> MaxLen);<br>
>> >> >> +<br>
>> >> >> +void Print(const Unit &U, const char *PrintAfter = "");<br>
>> >> >> +void PrintASCII(const Unit &U, const char *PrintAfter = "");<br>
>> >> >> +std::string Hash(const Unit &U);<br>
>> >> >> +void SetTimer(int Seconds);<br>
>> >> >> +<br>
>> >> >> +class Fuzzer {<br>
>> >> >> + public:<br>
>> >> >> +  struct FuzzingOptions {<br>
>> >> >> +    int Verbosity = 1;<br>
>> >> >> +    int MaxLen = 0;<br>
>> >> >> +    bool DoCrossOver = true;<br>
>> >> >> +    bool MutateDepth = 10;<br>
>> >> >> +    bool ExitOnFirst = false;<br>
>> >> >> +    std::string OutputCorpus;<br>
>> >> >> +  };<br>
>> >> >> +  Fuzzer(FuzzingOptions Options) : Options(Options) {<br>
>> >> >> +    SetDeathCallback();<br>
>> >> >> +  }<br>
>> >> >> +  void AddToCorpus(const Unit &U) { Corpus.push_back(U); }<br>
>> >> >> +  size_t Loop(size_t NumIterations);<br>
>> >> >> +  void ShuffleAndMinimize();<br>
>> >> >> +  size_t CorpusSize() const { return Corpus.size(); }<br>
>> >> >> +  void ReadDir(const std::string &Path) {<br>
>> >> >> +    ReadDirToVectorOfUnits(Path.c_str(), &Corpus);<br>
>> >> >> +  }<br>
>> >> >> +<br>
>> >> >> +  static void AlarmCallback();<br>
>> >> >> +<br>
>> >> >> + private:<br>
>> >> >> +  size_t MutateAndTestOne(Unit *U);<br>
>> >> >> +  size_t RunOne(const Unit &U);<br>
>> >> >> +  void WriteToOutputCorpus(const Unit &U);<br>
>> >> >> +  static void WriteToCrash(const Unit &U, const char *Prefix);<br>
>> >> >> +<br>
>> >> >> +  void SetDeathCallback();<br>
>> >> >> +  static void DeathCallback();<br>
>> >> >> +  static Unit CurrentUnit;<br>
>> >> >> +<br>
>> >> >> +  size_t TotalNumberOfRuns = 0;<br>
>> >> >> +<br>
>> >> >> +  std::vector<Unit> Corpus;<br>
>> >> >> +  FuzzingOptions Options;<br>
>> >> >> +  system_clock::time_point ProcessStartTime = system_clock::now();<br>
>> >> >> +  static system_clock::time_point UnitStartTime;<br>
>> >> >> +};<br>
>> >> >> +<br>
>> >> >> +};  // namespace fuzzer<br>
>> >> >><br>
>> >> >> Added: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp<br>
>> >> >> URL:<br>
>> >> >><br>
>> >> >> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=227252&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=227252&view=auto</a><br>
>> >> >><br>
>> >> >><br>
>> >> >> ==============================================================================<br>
>> >> >> --- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (added)<br>
>> >> >> +++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Tue Jan 27 16:08:41 2015<br>
>> >> >> @@ -0,0 +1,161 @@<br>
>> >> >> +//===- FuzzerLoop.cpp - Fuzzer's main loop<br>
>> >> >> --------------------------------===//<br>
>> >> >> +//<br>
>> >> >> +//                     The LLVM Compiler Infrastructure<br>
>> >> >> +//<br>
>> >> >> +// This file is distributed under the University of Illinois Open<br>
>> >> >> Source<br>
>> >> >> +// License. See LICENSE.TXT for details.<br>
>> >> >> +//<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +// Fuzzer's main loop.<br>
>> >> >><br>
>> >> >><br>
>> >> >> +//===----------------------------------------------------------------------===//<br>
>> >> >> +<br>
>> >> >> +#include "FuzzerInternal.h"<br>
>> >> >> +#include <sanitizer/asan_interface.h><br>
>> >><br>
>> >> Please do not assume everyone has asan checked out. Also, this is<br>
>> >> using a system include path on Windows instead of a project include<br>
>> >> path.<br>
>> ><br>
>> ><br>
>> ><br>
>> > I do not. This is what EXCLUDE_FROM_ALL was for.<br>
>> > Apparently it did not help.<br>
>> > Suggestions?<br>
>><br>
>> I'm not certain how EXCLUDE_FROM_ALL would help for this #include?<br>
><br>
><br>
> Not sure what you mean here.<br>
> My understanding of EXCLUDE_FROM_ALL is that a target will not be built<br>
> unless it is explicitly requested from the build system,<br>
> at which point the requester makes sure there is proper sanitizer support.<br>
> This library will not function w/o sanitizers, so there is no way to have it<br>
> available in all builds.<br>
<br>
</div></div>Ah, I understand your logic now. You want CMake to only include the<br>
entire fuzzer library when sanitizers are present, and otherwise not<br>
build it. So then it would be safe for this #include. That makes far<br>
more sense to me. :-)<br></blockquote><div><br></div><div>Correct. This is why I used EXCLUDE_FROM_ALL.</div><div>Now that you've made me think of it more, maybe the proper guard will be </div><div>   if (LLVM_USE_SANITIZE_COVERAGE) from</div><div><a href="http://llvm.org/viewvc/llvm-project?view=revision&revision=227216">http://llvm.org/viewvc/llvm-project?view=revision&revision=227216</a><br></div><div><br></div><div>wdyt? </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span><font color="#888888"><br>
~Aaron<br>
</font></span></blockquote></div><br></div></div>