[PATCH] D27577: [libFuzzer] Diff 18 - Avoid name collision with Windows API.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 09:23:28 PST 2016


mpividori created this revision.
mpividori added reviewers: amccarth, zturner.
mpividori added a subscriber: llvm-commits.
mpividori set the repository for this revision to rL LLVM.

Windows uses some macros to replace `DeleteFile()` by `DeleteFileA()` or `DeleteFileW()`. This was causing an error at link time.
I could have used "#undef DeleteFile", but I decided to change the function name to avoid future problem if we want to use Windows's function `DeleteFile()`.


Repository:
  rL LLVM

https://reviews.llvm.org/D27577

Files:
  lib/Fuzzer/FuzzerCorpus.h
  lib/Fuzzer/FuzzerIO.h
  lib/Fuzzer/FuzzerIOPosix.cpp
  lib/Fuzzer/FuzzerIOWindows.cpp


Index: lib/Fuzzer/FuzzerIOWindows.cpp
===================================================================
--- lib/Fuzzer/FuzzerIOWindows.cpp
+++ lib/Fuzzer/FuzzerIOWindows.cpp
@@ -136,7 +136,7 @@
   return _dup(Fd);
 }
 
-void DeleteFile(const std::string &Path) {
+void RemoveFile(const std::string &Path) {
   _unlink(Path.c_str());
 }
 
Index: lib/Fuzzer/FuzzerIOPosix.cpp
===================================================================
--- lib/Fuzzer/FuzzerIOPosix.cpp
+++ lib/Fuzzer/FuzzerIOPosix.cpp
@@ -71,7 +71,7 @@
   return dup(Fd);
 }
 
-void DeleteFile(const std::string &Path) {
+void RemoveFile(const std::string &Path) {
   unlink(Path.c_str());
 }
 
Index: lib/Fuzzer/FuzzerIO.h
===================================================================
--- lib/Fuzzer/FuzzerIO.h
+++ lib/Fuzzer/FuzzerIO.h
@@ -57,7 +57,7 @@
 
 int DuplicateFile(int Fd);
 
-void DeleteFile(const std::string &Path);
+void RemoveFile(const std::string &Path);
 
 }  // namespace fuzzer
 
Index: lib/Fuzzer/FuzzerCorpus.h
===================================================================
--- lib/Fuzzer/FuzzerCorpus.h
+++ lib/Fuzzer/FuzzerCorpus.h
@@ -119,7 +119,7 @@
   void DeleteInput(size_t Idx) {
     InputInfo &II = *Inputs[Idx];
     if (!OutputCorpus.empty() && II.MayDeleteFile)
-      DeleteFile(DirPlusFile(OutputCorpus, Sha1ToString(II.Sha1)));
+      RemoveFile(DirPlusFile(OutputCorpus, Sha1ToString(II.Sha1)));
     Unit().swap(II.U);
     if (FeatureDebug)
       Printf("EVICTED %zd\n", Idx);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27577.80771.patch
Type: text/x-patch
Size: 1507 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161208/2816bd38/attachment.bin>


More information about the llvm-commits mailing list