Skip to content

Commit 943182e

Browse files
authored
[clang][TableGen] Change comment command emitter to const RecordKeeper (#108199)
Change comment command emitter to const RecordKeeper. This is a part of effort to have better const correctness in TableGen backends: https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
1 parent f02c72f commit 943182e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020

2121
using namespace llvm;
2222

23-
void clang::EmitClangCommentCommandInfo(RecordKeeper &Records,
23+
void clang::EmitClangCommentCommandInfo(const RecordKeeper &Records,
2424
raw_ostream &OS) {
2525
emitSourceFileHeader("A list of commands useable in documentation comments",
2626
OS, Records);
2727

2828
OS << "namespace {\n"
2929
"const CommandInfo Commands[] = {\n";
30-
std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Command");
30+
ArrayRef<const Record *> Tags = Records.getAllDerivedDefinitions("Command");
3131
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
32-
Record &Tag = *Tags[i];
32+
const Record &Tag = *Tags[i];
3333
OS << " { "
3434
<< "\"" << Tag.getValueAsString("Name") << "\", "
3535
<< "\"" << Tag.getValueAsString("EndCommandName") << "\", " << i << ", "
@@ -62,7 +62,7 @@ void clang::EmitClangCommentCommandInfo(RecordKeeper &Records,
6262

6363
std::vector<StringMatcher::StringPair> Matches;
6464
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
65-
Record &Tag = *Tags[i];
65+
const Record &Tag = *Tags[i];
6666
std::string Name = std::string(Tag.getValueAsString("Name"));
6767
std::string Return;
6868
raw_string_ostream(Return) << "return &Commands[" << i << "];";
@@ -112,7 +112,7 @@ static std::string MangleName(StringRef Str) {
112112
return Mangled;
113113
}
114114

115-
void clang::EmitClangCommentCommandList(RecordKeeper &Records,
115+
void clang::EmitClangCommentCommandList(const RecordKeeper &Records,
116116
raw_ostream &OS) {
117117
emitSourceFileHeader("A list of commands useable in documentation comments",
118118
OS, Records);
@@ -121,9 +121,9 @@ void clang::EmitClangCommentCommandList(RecordKeeper &Records,
121121
<< "# define COMMENT_COMMAND(NAME)\n"
122122
<< "#endif\n";
123123

124-
std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Command");
124+
ArrayRef<const Record *> Tags = Records.getAllDerivedDefinitions("Command");
125125
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
126-
Record &Tag = *Tags[i];
126+
const Record &Tag = *Tags[i];
127127
std::string MangledName = MangleName(Tag.getValueAsString("Name"));
128128

129129
OS << "COMMENT_COMMAND(" << MangledName << ")\n";

clang/utils/TableGen/TableGenBackends.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ void EmitClangCommentHTMLTagsProperties(llvm::RecordKeeper &Records,
9191
void EmitClangCommentHTMLNamedCharacterReferences(llvm::RecordKeeper &Records,
9292
llvm::raw_ostream &OS);
9393

94-
void EmitClangCommentCommandInfo(llvm::RecordKeeper &Records,
94+
void EmitClangCommentCommandInfo(const llvm::RecordKeeper &Records,
9595
llvm::raw_ostream &OS);
96-
void EmitClangCommentCommandList(llvm::RecordKeeper &Records,
96+
void EmitClangCommentCommandList(const llvm::RecordKeeper &Records,
9797
llvm::raw_ostream &OS);
9898
void EmitClangOpcodes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
9999

0 commit comments

Comments
 (0)