summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/FileUtilities.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-09 17:36:48 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-09 17:36:48 +0000
commit7b6fef82d43a4e121a284ebabf5de94c3485b29a (patch)
tree09a49a4bb8f4c8c8b5a13d4d328b82f442a26969 /llvm/lib/Support/FileUtilities.cpp
parentf25faaaffbd9c6d3ffeccb333d0338e5bcb796b1 (diff)
downloadbcm5719-llvm-7b6fef82d43a4e121a284ebabf5de94c3485b29a.tar.gz
bcm5719-llvm-7b6fef82d43a4e121a284ebabf5de94c3485b29a.zip
Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with error_code &ec. And fix clients.
llvm-svn: 121379
Diffstat (limited to 'llvm/lib/Support/FileUtilities.cpp')
-rw-r--r--llvm/lib/Support/FileUtilities.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp
index 72200850c57..77de94dfc92 100644
--- a/llvm/lib/Support/FileUtilities.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud