[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / DebugInfo / GSYM / LookupResult.cpp
blob8a624226b1d3d3083fbd146fe09136600d6fcb49
1 //===- LookupResult.cpp -------------------------------------------------*-===//
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 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/GSYM/LookupResult.h"
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/Support/Format.h"
12 #include "llvm/Support/Path.h"
13 #include "llvm/Support/raw_ostream.h"
14 #include <ciso646>
16 using namespace llvm;
17 using namespace gsym;
19 std::string LookupResult::getSourceFile(uint32_t Index) const {
20 std::string Fullpath;
21 if (Index < Locations.size()) {
22 if (!Locations[Index].Dir.empty()) {
23 if (Locations[Index].Base.empty()) {
24 Fullpath = std::string(Locations[Index].Dir);
25 } else {
26 llvm::SmallString<64> Storage;
27 llvm::sys::path::append(Storage, Locations[Index].Dir,
28 Locations[Index].Base);
29 Fullpath.assign(Storage.begin(), Storage.end());
31 } else if (!Locations[Index].Base.empty())
32 Fullpath = std::string(Locations[Index].Base);
34 return Fullpath;
37 raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const SourceLocation &SL) {
38 OS << SL.Name;
39 if (SL.Offset > 0)
40 OS << " + " << SL.Offset;
41 if (SL.Dir.size() || SL.Base.size()) {
42 OS << " @ ";
43 if (!SL.Dir.empty()) {
44 OS << SL.Dir;
45 if (SL.Dir.contains('\\') and not SL.Dir.contains('/'))
46 OS << '\\';
47 else
48 OS << '/';
50 if (SL.Base.empty())
51 OS << "<invalid-file>";
52 else
53 OS << SL.Base;
54 OS << ':' << SL.Line;
56 return OS;
59 raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const LookupResult &LR) {
60 OS << HEX64(LR.LookupAddr) << ": ";
61 auto NumLocations = LR.Locations.size();
62 for (size_t I = 0; I < NumLocations; ++I) {
63 if (I > 0) {
64 OS << '\n';
65 OS.indent(20);
67 const bool IsInlined = I + 1 != NumLocations;
68 OS << LR.Locations[I];
69 if (IsInlined)
70 OS << " [inlined]";
72 OS << '\n';
73 return OS;