xref: /freebsd/contrib/llvm-project/llvm/lib/Debuginfod/BuildIDFetcher.cpp (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1 //===- llvm/DebugInfod/BuildIDFetcher.cpp - Build ID fetcher --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file defines a DIFetcher implementation for obtaining debug info
11 /// from debuginfod.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm/Debuginfod/BuildIDFetcher.h"
16 
17 #include "llvm/Debuginfod/Debuginfod.h"
18 
19 using namespace llvm;
20 
21 std::optional<std::string>
22 DebuginfodFetcher::fetch(ArrayRef<uint8_t> BuildID) const {
23   if (std::optional<std::string> Path = BuildIDFetcher::fetch(BuildID))
24     return std::move(*Path);
25 
26   Expected<std::string> PathOrErr = getCachedOrDownloadDebuginfo(BuildID);
27   if (PathOrErr)
28     return *PathOrErr;
29   consumeError(PathOrErr.takeError());
30   return std::nullopt;
31 }
32