X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FFileUtilities.cpp;h=5316f049a38a5a41754c354f9385d91af332017d;hb=HEAD;hp=0d26bafd771493f5c4aac5e6a55ddc69d436f9ee;hpb=4e2b922131ae617cb8738d1871e9d918c44bdb69;p=oota-llvm.git diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 0d26bafd771..5316f049a38 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -176,28 +176,31 @@ 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 (std::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 (std::error_code ec = MemoryBuffer::getFile(NameB, F2)) { + MemoryBuffer &F1 = *F1OrErr.get(); + + ErrorOr> F2OrErr = MemoryBuffer::getFile(NameB); + if (std::error_code EC = F2OrErr.getError()) { if (Error) - *Error = ec.message(); + *Error = EC.message(); return 2; } + MemoryBuffer &F2 = *F2OrErr.get(); // Okay, now that we opened the files, scan them for the first difference. - const char *File1Start = F1->getBufferStart(); - const char *File2Start = F2->getBufferStart(); - const char *File1End = F1->getBufferEnd(); - const char *File2End = F2->getBufferEnd(); + const char *File1Start = F1.getBufferStart(); + const char *File2Start = F2.getBufferStart(); + const char *File1End = F1.getBufferEnd(); + const char *File2End = F2.getBufferEnd(); const char *F1P = File1Start; const char *F2P = File2Start; - uint64_t A_size = F1->getBufferSize(); - uint64_t B_size = F2->getBufferSize(); + uint64_t A_size = F1.getBufferSize(); + uint64_t B_size = F2.getBufferSize(); // Are the buffers identical? Common case: Handle this efficiently. if (A_size == B_size &&