diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-09 17:36:48 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-09 17:36:48 +0000 |
commit | 333fb04506233255f10d8095c9e2de5e5f0fdc6f (patch) | |
tree | 29b15348801de3482b07a438b1fb1f2ba094d3d2 /lib/Support/FileUtilities.cpp | |
parent | 908b6ddad6dac40c4c0453d690f0db9422b48b10 (diff) |
Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with error_code &ec. And fix clients.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/FileUtilities.cpp')
-rw-r--r-- | lib/Support/FileUtilities.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 72200850c5..77de94dfc9 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -16,6 +16,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Path.h" +#include "llvm/Support/system_error.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" #include <cstdlib> @@ -199,11 +200,20 @@ int llvm::DiffFilesWithTolerance(const sys::PathWithStatus &FileA, // Now its safe to mmap the files into memory becasue both files // have a non-zero size. - OwningPtr<MemoryBuffer> F1(MemoryBuffer::getFile(FileA.c_str(), Error)); - OwningPtr<MemoryBuffer> F2(MemoryBuffer::getFile(FileB.c_str(), Error)); - if (F1 == 0 || F2 == 0) + error_code ec; + OwningPtr<MemoryBuffer> F1(MemoryBuffer::getFile(FileA.c_str(), ec)); + if (F1 == 0) { + if (Error) + *Error = ec.message(); + return 2; + } + OwningPtr<MemoryBuffer> F2(MemoryBuffer::getFile(FileB.c_str(), ec)); + if (F2 == 0) { + if (Error) + *Error = ec.message(); return 2; - + } + // Okay, now that we opened the files, scan them for the first difference. const char *File1Start = F1->getBufferStart(); const char *File2Start = F2->getBufferStart(); |