LLVM: lib/ProfileData/SymbolRemappingReader.cpp Source File (original) (raw)
30
31 auto ReportError = [&](Twine Msg) {
33 B.getBufferIdentifier(), LineIt.line_number(), Msg);
34 };
35
36 for (; !LineIt.is_at_eof(); ++LineIt) {
38 Line = Line.ltrim(' ');
39
40 if (Line.starts_with("#") || Line.empty())
41 continue;
42
44 Line.split(Parts, ' ', -1, false);
45
46 if (Parts.size() != 3)
47 return ReportError("Expected 'kind mangled_name mangled_name', "
48 "found '" + Line + "'");
49
52 .Case("name", FK::Name)
53 .Case("type", FK::Type)
54 .Case("encoding", FK::Encoding)
56 if (!FragmentKind)
57 return ReportError("Invalid kind, expected 'name', 'type', or 'encoding',"
58 " found '" + Parts[0] + "'");
59
61 switch (Canonicalizer.addEquivalence(*FragmentKind, Parts[1], Parts[2])) {
62 case EE::Success:
63 break;
64
65 case EE::ManglingAlreadyUsed:
66 return ReportError("Manglings '" + Parts[1] + "' and '" + Parts[2] + "' "
67 "have both been used in prior remappings. Move this "
68 "remapping earlier in the file.");
69
70 case EE::InvalidFirstMangling:
71 return ReportError("Could not demangle '" + Parts[1] + "' "
72 "as a <" + Parts[0] + ">; invalid mangling?");
73
74 case EE::InvalidSecondMangling:
75 return ReportError("Could not demangle '" + Parts[2] + "' "
76 "as a <" + Parts[0] + ">; invalid mangling?");
77 }
78 }
79
81}