Author: Rahul Joshi Date: 2024-08-25T05:40:21-07:00 New Revision: 1193f7d6487d2d94009f8d8d27da3907136482b9
URL: https://github.com/llvm/llvm-project/commit/1193f7d6487d2d94009f8d8d27da3907136482b9 DIFF: https://github.com/llvm/llvm-project/commit/1193f7d6487d2d94009f8d8d27da3907136482b9.diff LOG: [NFC] Use const members of `StringToOffsetTable` (#105824) Added: Modified: clang/utils/TableGen/ClangDiagnosticsEmitter.cpp llvm/utils/TableGen/AsmMatcherEmitter.cpp Removed: ################################################################################ diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index b290530444d2ab..6ca24a8c74b2ff 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -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); @@ -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); @@ -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) @@ -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"; diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 5035ef52707f4e..98d0231d3055c2 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -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; @@ -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 << " /* "; @@ -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 << ", "; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits