LLVM: lib/DebugInfo/LogicalView/Core/LVSupport.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

15

16using namespace llvm;

18

19#define DEBUG_TYPE "Support"

20

21namespace {

22

24}

26

27

28

29

30

32 std::string Name(Path);

33 std::transform(Name.begin(), Name.end(), Name.begin(), tolower);

34 std::replace(Name.begin(), Name.end(), '\\', '/');

35

36

37 size_t Pos = 0;

38 while ((Pos = Name.find("//", Pos)) != std:🧵:npos)

39 Name.erase(Pos, 1);

40

42}

43

44

45

46

47

49 std::string Name(Path);

50 std::transform(Name.begin(), Name.end(), Name.begin(), tolower);

51

52 const char *CharSet = "/\\<>.:%*?|\" ";

53 char *Input = Name.data();

54 while (Input && *Input) {

55 Input = strpbrk(Input, CharSet);

56 if (Input)

57 *Input++ = '_';

58 };

60}

61

64

66 if (Name.empty())

67 return {};

68

69 size_t AngleCount = 0;

70 size_t ColonSeen = 0;

71 size_t Current = 0;

72

74

75#ifndef NDEBUG

76 auto PrintLexicalEntry = [&]() {

79 "'{0}:{1}', '{2}'\n", Entry.first, Entry.second,

80 Name.substr(Entry.first, Entry.second - Entry.first + 1));

81 };

82#endif

83

85 for (size_t Index = 0; Index < Length; ++Index) {

89 });

90 switch (Name[Index]) {

91 case '<':

92 ++AngleCount;

93 break;

94 case '>':

95 --AngleCount;

96 break;

97 case ':':

98 ++ColonSeen;

99 break;

100 }

101 if (ColonSeen == 2) {

102 if (!AngleCount) {

104 Current = Index + 1;

105 LLVM_DEBUG({ PrintLexicalEntry(); });

106 }

107 ColonSeen = 0;

108 continue;

109 }

110 }

111

112

114 LLVM_DEBUG({ PrintLexicalEntry(); });

115 return Indexes;

116}

117

119 if (Name.empty())

120 return {};

121

123 if (Indexes.size() == 1)

125

129 Name.substr(BeginEntry.first, EndEntry.second - BeginEntry.first + 1);

130

134

135 return std::make_tuple(Outer, Inner);

136}

137

139 if (Name.empty())

140 return {};

141

145 Components.push_back(

146 Name.substr(Entry.first, Entry.second - Entry.first + 1));

147

148 return Components;

149}

150

153 if (Components.empty())

154 return {};

155 std::string Name(BaseName);

157 if (BaseName.size())

158 Stream << "::";

159 Stream << Components[0];

160 for (LVStringRefs::size_type Index = 1; Index < Components.size(); ++Index)

161 Stream << "::" << Components[Index];

163}

static LexicalIndexes getAllLexicalIndexes(StringRef Name)

std::pair< size_t, size_t > LexicalEntry

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

constexpr size_t size() const

size - Get the string size.

A raw_ostream that writes to an std::string.

std::vector< StringRef > LVStringRefs

LVStringPool & getStringPool()

std::tuple< StringRef, StringRef > LVLexicalComponent

LVStringRefs getAllLexicalComponents(StringRef Name)

std::string transformPath(StringRef Path)

LVLexicalComponent getInnerComponent(StringRef Name)

std::string flattenedFilePath(StringRef Path)

std::string getScopedName(const LVStringRefs &Components, StringRef BaseName={})

This is an optimization pass for GlobalISel generic memory operations.

auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)

raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.