[llvm] r348059 - Use RequireNullTerminator=false in identify_magic.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 30 16:22:39 PST 2018


Author: zturner
Date: Fri Nov 30 16:22:39 2018
New Revision: 348059

URL: http://llvm.org/viewvc/llvm-project?rev=348059&view=rev
Log:
Use RequireNullTerminator=false in identify_magic.

identify_magic does not need the file to be null terminated.  Passing
true here causes the file reading code to decide not to use mmap in
some rare cases (which happen to be true 100% of the time in PDB files)
which can lead to very large files failing to load.  Since it was
probably just an accident that we were passing true here (since it is
the default function parameter), this should be strictly an improvement.

Modified:
    llvm/trunk/lib/BinaryFormat/Magic.cpp

Modified: llvm/trunk/lib/BinaryFormat/Magic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/BinaryFormat/Magic.cpp?rev=348059&r1=348058&r2=348059&view=diff
==============================================================================
--- llvm/trunk/lib/BinaryFormat/Magic.cpp (original)
+++ llvm/trunk/lib/BinaryFormat/Magic.cpp Fri Nov 30 16:22:39 2018
@@ -206,7 +206,7 @@ file_magic llvm::identify_magic(StringRe
 }
 
 std::error_code llvm::identify_magic(const Twine &Path, file_magic &Result) {
-  auto FileOrError = MemoryBuffer::getFile(Path);
+  auto FileOrError = MemoryBuffer::getFile(Path, -1LL, false);
   if (!FileOrError)
     return FileOrError.getError();
 




More information about the llvm-commits mailing list