X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FFileUtilities.cpp;h=8a234917827edc2657514d92a5d099be041ab36a;hb=ad591b341bf22bb4d3a7526d59d4ae6c414420ee;hp=729e44789cdf5b4d1e0fa87766cecf024fe4d02e;hpb=5c792faa0e5560bc148c973f3df658eb3bb2061e;p=oota-llvm.git diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 729e44789cd..8a234917827 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -22,7 +22,6 @@ #include #include using namespace llvm; -using std::error_code; static bool isSignedChar(char C) { return (C == '+' || 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. - std::unique_ptr F1; - if (error_code ec = MemoryBuffer::getFile(NameA, F1)) { + ErrorOr> F1OrErr = MemoryBuffer::getFile(NameA); + if (std::error_code EC = F1OrErr.getError()) { if (Error) - *Error = ec.message(); + *Error = EC.message(); return 2; } - std::unique_ptr F2; - if (error_code ec = MemoryBuffer::getFile(NameB, F2)) { + std::unique_ptr F1 = std::move(F1OrErr.get()); + + ErrorOr> F2OrErr = MemoryBuffer::getFile(NameB); + if (std::error_code EC = F2OrErr.getError()) { if (Error) - *Error = ec.message(); + *Error = EC.message(); return 2; } + std::unique_ptr F2 = std::move(F2OrErr.get()); // Okay, now that we opened the files, scan them for the first difference. const char *File1Start = F1->getBufferStart();