Skip to content

Commit

Permalink
[NFC] Use const members of StringToOffsetTable (#105824)
Browse files Browse the repository at this point in the history
  • Loading branch information
jurahul authored Aug 25, 2024
1 parent b6603e1 commit 1193f7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ static void emitDiagArrays(std::map<std::string, GroupInfo> &DiagsInGroup,
/// \000\020#pragma-messages\t#warnings\020CFString-literal"
/// };
/// \endcode
static void emitDiagGroupNames(StringToOffsetTable &GroupNames,
static void emitDiagGroupNames(const StringToOffsetTable &GroupNames,
raw_ostream &OS) {
OS << "static const char DiagGroupNames[] = {\n";
GroupNames.EmitString(OS);
Expand All @@ -1656,7 +1656,7 @@ static void emitDiagGroupNames(StringToOffsetTable &GroupNames,
static void emitAllDiagArrays(std::map<std::string, GroupInfo> &DiagsInGroup,
RecordVec &DiagsInPedantic,
RecordVec &GroupsInPedantic,
StringToOffsetTable &GroupNames,
const StringToOffsetTable &GroupNames,
raw_ostream &OS) {
OS << "\n#ifdef GET_DIAG_ARRAYS\n";
emitDiagArrays(DiagsInGroup, DiagsInPedantic, OS);
Expand All @@ -1683,7 +1683,8 @@ static void emitAllDiagArrays(std::map<std::string, GroupInfo> &DiagsInGroup,
static void emitDiagTable(std::map<std::string, GroupInfo> &DiagsInGroup,
RecordVec &DiagsInPedantic,
RecordVec &GroupsInPedantic,
StringToOffsetTable &GroupNames, raw_ostream &OS) {
const StringToOffsetTable &GroupNames,
raw_ostream &OS) {
unsigned MaxLen = 0;

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

// Special handling for 'pedantic'.
const bool IsPedantic = I.first == "pedantic";
Expand Down
10 changes: 5 additions & 5 deletions llvm/utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2871,7 +2871,7 @@ static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info,
static void
emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,
const AsmMatcherInfo &Info, StringRef ClassName,
StringToOffsetTable &StringTable,
const StringToOffsetTable &StringTable,
unsigned MaxMnemonicIndex, unsigned MaxFeaturesIndex,
bool HasMnemonicFirst, const Record &AsmParser) {
unsigned MaxMask = 0;
Expand Down Expand Up @@ -2924,8 +2924,8 @@ emitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,

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

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

Expand Down

0 comments on commit 1193f7d

Please sign in to comment.