LLVM: lib/Remarks/RemarkStringTable.cpp Source File (original) (raw)
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9
10
11
12
18#include
19
20using namespace llvm;
22
24 for (unsigned i = 0, e = Other.size(); i < e; ++i)
26 add(*MaybeStr);
27 else
28 llvm_unreachable("Unexpected error while building remarks string table.");
29}
30
32 size_t NextID = StrTab.size();
33 auto KV = StrTab.insert({Str, NextID});
34
35 if (KV.second)
36 SerializedSize += KV.first->first().size() + 1;
37
38 return {KV.first->second, KV.first->first()};
39}
40
42 auto Impl = [&](StringRef &S) { S = add(S).second; };
43 Impl(R.PassName);
44 Impl(R.RemarkName);
45 Impl(R.FunctionName);
46 if (R.Loc)
47 Impl(R.Loc->SourceFilePath);
48 for (Argument &Arg : R.Args) {
49 Impl(Arg.Key);
50 Impl(Arg.Val);
51 if (Arg.Loc)
52 Impl(Arg.Loc->SourceFilePath);
53 }
54}
55
57
59 OS << Str;
60
62 }
63}
64
66 std::vector Strings{StrTab.size()};
67 for (const auto &KV : StrTab)
68 Strings[KV.second] = KV.first();
69 return Strings;
70}
Tagged union holding either a T or a Error.
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write(unsigned char C)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.