diff options
Diffstat (limited to 'tools/llvm-xray/xray-fdr-dump.cpp')
-rw-r--r-- | tools/llvm-xray/xray-fdr-dump.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tools/llvm-xray/xray-fdr-dump.cpp b/tools/llvm-xray/xray-fdr-dump.cpp index 389825605b62..81a93cac57c4 100644 --- a/tools/llvm-xray/xray-fdr-dump.cpp +++ b/tools/llvm-xray/xray-fdr-dump.cpp @@ -1,9 +1,8 @@ //===- xray-fdr-dump.cpp: XRay FDR Trace Dump Tool ------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -36,10 +35,9 @@ static cl::opt<bool> DumpVerify("verify", static CommandRegistration Unused(&Dump, []() -> Error { // Open the file provided. - int Fd; - if (auto EC = sys::fs::openFileForRead(DumpInput, Fd)) - return createStringError(EC, "Cannot open file '%s' for read.", - DumpInput.c_str()); + auto FDOrErr = sys::fs::openNativeFileForRead(DumpInput); + if (!FDOrErr) + return FDOrErr.takeError(); uint64_t FileSize; if (auto EC = sys::fs::file_size(DumpInput, FileSize)) @@ -48,7 +46,9 @@ static CommandRegistration Unused(&Dump, []() -> Error { std::error_code EC; sys::fs::mapped_file_region MappedFile( - Fd, sys::fs::mapped_file_region::mapmode::readonly, FileSize, 0, EC); + *FDOrErr, sys::fs::mapped_file_region::mapmode::readonly, FileSize, 0, + EC); + sys::fs::closeFile(*FDOrErr); DataExtractor DE(StringRef(MappedFile.data(), MappedFile.size()), true, 8); uint32_t OffsetPtr = 0; |