diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 09:08:18 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 09:08:18 +0000 | 
| commit | 5ca98fd98791947eba83a1ed3f2c8191ef7afa6c (patch) | |
| tree | f5944309621cee4fe0976be6f9ac619b7ebfc4c2 /lib/Support/FileUtilities.cpp | |
| parent | 68bcb7db193e4bc81430063148253d30a791023e (diff) | |
Notes
Diffstat (limited to 'lib/Support/FileUtilities.cpp')
| -rw-r--r-- | lib/Support/FileUtilities.cpp | 18 | 
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 7f5d54048775..8a234917827e 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -13,15 +13,14 @@  //===----------------------------------------------------------------------===//  #include "llvm/Support/FileUtilities.h" -#include "llvm/ADT/OwningPtr.h"  #include "llvm/ADT/SmallString.h"  #include "llvm/Support/MemoryBuffer.h"  #include "llvm/Support/Path.h"  #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/system_error.h"  #include <cctype>  #include <cstdlib>  #include <cstring> +#include <system_error>  using namespace llvm;  static bool isSignedChar(char C) { @@ -177,18 +176,21 @@ int llvm::DiffFilesWithTolerance(StringRef NameA,                                   std::string *Error) {    // Now its safe to mmap the files into memory because both files    // have a non-zero size. -  OwningPtr<MemoryBuffer> F1; -  if (error_code ec = MemoryBuffer::getFile(NameA, F1)) { +  ErrorOr<std::unique_ptr<MemoryBuffer>> F1OrErr = MemoryBuffer::getFile(NameA); +  if (std::error_code EC = F1OrErr.getError()) {      if (Error) -      *Error = ec.message(); +      *Error = EC.message();      return 2;    } -  OwningPtr<MemoryBuffer> F2; -  if (error_code ec = MemoryBuffer::getFile(NameB, F2)) { +  std::unique_ptr<MemoryBuffer> F1 = std::move(F1OrErr.get()); + +  ErrorOr<std::unique_ptr<MemoryBuffer>> F2OrErr = MemoryBuffer::getFile(NameB); +  if (std::error_code EC = F2OrErr.getError()) {      if (Error) -      *Error = ec.message(); +      *Error = EC.message();      return 2;    } +  std::unique_ptr<MemoryBuffer> F2 = std::move(F2OrErr.get());    // Okay, now that we opened the files, scan them for the first difference.    const char *File1Start = F1->getBufferStart();  | 
