Skip to content

Commit 1193f7d

Browse files
authored
[NFC] Use const members of StringToOffsetTable (#105824)
1 parent b6603e1 commit 1193f7d

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ static void emitDiagArrays(std::map<std::string, GroupInfo> &DiagsInGroup,
16341634
/// \000\020#pragma-messages\t#warnings\020CFString-literal"
16351635
/// };
16361636
/// \endcode
1637-
static void emitDiagGroupNames(StringToOffsetTable &GroupNames,
1637+
static void emitDiagGroupNames(const StringToOffsetTable &GroupNames,
16381638
raw_ostream &OS) {
16391639
OS << "static const char DiagGroupNames[] = {\n";
16401640
GroupNames.EmitString(OS);
@@ -1656,7 +1656,7 @@ static void emitDiagGroupNames(StringToOffsetTable &GroupNames,
16561656
static void emitAllDiagArrays(std::map<std::string, GroupInfo> &DiagsInGroup,
16571657
RecordVec &DiagsInPedantic,
16581658
RecordVec &GroupsInPedantic,
1659-
StringToOffsetTable &GroupNames,
1659+
const StringToOffsetTable &GroupNames,
16601660
raw_ostream &OS) {
16611661
OS << "\n#ifdef GET_DIAG_ARRAYS\n";
16621662
emitDiagArrays(DiagsInGroup, DiagsInPedantic, OS);
@@ -1683,7 +1683,8 @@ static void emitAllDiagArrays(std::map<std::string, GroupInfo> &DiagsInGroup,
16831683
static void emitDiagTable(std::map<std::string, GroupInfo> &DiagsInGroup,
16841684
RecordVec &DiagsInPedantic,
16851685
RecordVec &GroupsInPedantic,
1686-
StringToOffsetTable &GroupNames, raw_ostream &OS) {
1686+
const StringToOffsetTable &GroupNames,
1687+
raw_ostream &OS) {
16871688
unsigned MaxLen = 0;
16881689

16891690
for (auto const &I: DiagsInGroup)
@@ -1705,7 +1706,7 @@ static void emitDiagTable(std::map<std::string, GroupInfo> &DiagsInGroup,
17051706
OS << I.first << " */, ";
17061707
// Store a pascal-style length byte at the beginning of the string.
17071708
std::string Name = char(I.first.size()) + I.first;
1708-
OS << GroupNames.GetOrAddStringOffset(Name, false) << ", ";
1709+
OS << *GroupNames.GetStringOffset(Name) << ", ";
17091710

17101711
// Special handling for 'pedantic'.
17111712
const bool IsPedantic = I.first == "pedantic";

llvm/utils/TableGen/AsmMatcherEmitter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info,
28712871
static void
28722872
emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,
28732873
const AsmMatcherInfo &Info, StringRef ClassName,
2874-
StringToOffsetTable &StringTable,
2874+
const StringToOffsetTable &StringTable,
28752875
unsigned MaxMnemonicIndex, unsigned MaxFeaturesIndex,
28762876
bool HasMnemonicFirst, const Record &AsmParser) {
28772877
unsigned MaxMask = 0;
@@ -2924,8 +2924,8 @@ emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,
29242924

29252925
// Store a pascal-style length byte in the mnemonic.
29262926
std::string LenMnemonic = char(II.Mnemonic.size()) + II.Mnemonic.lower();
2927-
OS << StringTable.GetOrAddStringOffset(LenMnemonic, false) << " /* "
2928-
<< II.Mnemonic << " */, ";
2927+
OS << *StringTable.GetStringOffset(LenMnemonic) << " /* " << II.Mnemonic
2928+
<< " */, ";
29292929

29302930
OS << OMI.OperandMask;
29312931
OS << " /* ";
@@ -3554,8 +3554,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
35543554
// Store a pascal-style length byte in the mnemonic.
35553555
std::string LenMnemonic =
35563556
char(MI->Mnemonic.size()) + MI->Mnemonic.lower();
3557-
OS << " { " << StringTable.GetOrAddStringOffset(LenMnemonic, false)
3558-
<< " /* " << MI->Mnemonic << " */, " << Target.getInstNamespace()
3557+
OS << " { " << *StringTable.GetStringOffset(LenMnemonic) << " /* "
3558+
<< MI->Mnemonic << " */, " << Target.getInstNamespace()
35593559
<< "::" << MI->getResultInst()->TheDef->getName() << ", "
35603560
<< MI->ConversionFnKind << ", ";
35613561

0 commit comments

Comments
 (0)