Author: Jan Svoboda Date: 2021-12-17T14:00:20+01:00 New Revision: 3f3b5c3ec0da8f4982a8645fdb403de582295f0b
URL: https://github.com/llvm/llvm-project/commit/3f3b5c3ec0da8f4982a8645fdb403de582295f0b DIFF: https://github.com/llvm/llvm-project/commit/3f3b5c3ec0da8f4982a8645fdb403de582295f0b.diff LOG: [clang][deps] NFC: Unify ErrorOr patterns This patch canonicalized some code into repetitive ErrorOr pattern. This will make refactoring easier if we ever come up with a way to simplify this. Added: Modified: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp Removed: ################################################################################ diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp index 8ea59cb0d9a4..acceec690c11 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp @@ -19,21 +19,22 @@ using namespace dependencies; llvm::ErrorOr<llvm::vfs::Status> CachedFileSystemEntry::initFile(StringRef Filename, llvm::vfs::FileSystem &FS) { // Load the file and its content from the file system. - llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> MaybeFile = - FS.openFileForRead(Filename); + auto MaybeFile = FS.openFileForRead(Filename); if (!MaybeFile) return MaybeFile.getError(); + auto File = std::move(*MaybeFile); - llvm::ErrorOr<llvm::vfs::Status> Stat = (*MaybeFile)->status(); - if (!Stat) - return Stat.getError(); + auto MaybeStat = File->status(); + if (!MaybeStat) + return MaybeStat.getError(); + auto Stat = std::move(*MaybeStat); - llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MaybeBuffer = - (*MaybeFile)->getBuffer(Stat->getName()); + auto MaybeBuffer = File->getBuffer(Stat.getName()); if (!MaybeBuffer) return MaybeBuffer.getError(); + auto Buffer = std::move(*MaybeBuffer); - OriginalContents = std::move(*MaybeBuffer); + OriginalContents = std::move(Buffer); return Stat; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits