LLVM  10.0.0
LookupResult.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/Support/Format.h"
12 #include "llvm/Support/Path.h"
14 #include <ciso646>
15 
16 using namespace llvm;
17 using namespace gsym;
18 
20  std::string Fullpath;
21  if (Index < Locations.size()) {
22  if (!Locations[Index].Dir.empty()) {
23  if (Locations[Index].Base.empty()) {
24  Fullpath = 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());
30  }
31  } else if (!Locations[Index].Base.empty())
32  Fullpath = Locations[Index].Base;
33  }
34  return Fullpath;
35 }
36 
38  OS << SL.Name << " @ ";
39  if (!SL.Dir.empty()) {
40  OS << SL.Dir;
41  if (SL.Dir.contains('\\') and not SL.Dir.contains('/'))
42  OS << '\\';
43  else
44  OS << '/';
45  }
46  if (SL.Base.empty())
47  OS << "<invalid-file>";
48  else
49  OS << SL.Base;
50  OS << ':' << SL.Line;
51  return OS;
52 }
53 
55  OS << HEX64(LR.LookupAddr) << ": ";
56  auto NumLocations = LR.Locations.size();
57  for (size_t I = 0; I < NumLocations; ++I) {
58  if (I > 0) {
59  OS << '\n';
60  OS.indent(20);
61  }
62  const bool IsInlined = I + 1 != NumLocations;
63  OS << LR.Locations[I];
64  if (IsInlined)
65  OS << " [inlined]";
66  }
67  OS << '\n';
68  return OS;
69 }
#define HEX64(v)
Definition: Range.h:20
StringRef Base
Line entry source file basename.
Definition: LookupResult.h:25
This class represents lattice values for constants.
Definition: AllocatorList.h:23
StringRef Dir
Line entry source file directory path.
Definition: LookupResult.h:24
raw_ostream & indent(unsigned NumSpaces)
indent - Insert &#39;NumSpaces&#39; spaces.
uint32_t Line
Source file line number.
Definition: LookupResult.h:26
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:455
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:147
uint64_t LookupAddr
The address that this lookup pertains to.
Definition: LookupResult.h:40
SourceLocations Locations
The source locations that match this address.
Definition: LookupResult.h:52
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:453
StringRef Name
Function or symbol name.
Definition: LookupResult.h:23
#define I(x, y, z)
Definition: MD5.cpp:58
std::string getSourceFile(uint32_t Index) const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
raw_ostream & operator<<(raw_ostream &OS, const FunctionInfo &R)