Skip to content

Commit d757bbf

Browse files
authored
[clang][TableGen] Change SyntaxEmitter to use const RecordKeeper (#108478)
Change SyntaxEmitter to use 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 f637273 commit d757bbf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

clang/utils/TableGen/ClangSyntaxEmitter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ using llvm::formatv;
4141
// stable and useful way, where abstract Node subclasses correspond to ranges.
4242
class Hierarchy {
4343
public:
44-
Hierarchy(llvm::RecordKeeper &Records) {
45-
for (llvm::Record *T : Records.getAllDerivedDefinitions("NodeType"))
44+
Hierarchy(const llvm::RecordKeeper &Records) {
45+
for (const llvm::Record *T : Records.getAllDerivedDefinitions("NodeType"))
4646
add(T);
47-
for (llvm::Record *Derived : Records.getAllDerivedDefinitions("NodeType"))
48-
if (llvm::Record *Base = Derived->getValueAsOptionalDef("base"))
47+
for (const llvm::Record *Derived :
48+
Records.getAllDerivedDefinitions("NodeType"))
49+
if (const llvm::Record *Base = Derived->getValueAsOptionalDef("base"))
4950
link(Derived, Base);
5051
for (NodeType &N : AllTypes) {
5152
llvm::sort(N.Derived, [](const NodeType *L, const NodeType *R) {
@@ -127,7 +128,7 @@ struct SyntaxConstraint {
127128

128129
} // namespace
129130

130-
void clang::EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
131+
void clang::EmitClangSyntaxNodeList(const llvm::RecordKeeper &Records,
131132
llvm::raw_ostream &OS) {
132133
llvm::emitSourceFileHeader("Syntax tree node list", OS, Records);
133134
Hierarchy H(Records);
@@ -186,7 +187,7 @@ static void printDoc(llvm::StringRef Doc, llvm::raw_ostream &OS) {
186187
}
187188
}
188189

189-
void clang::EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
190+
void clang::EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
190191
llvm::raw_ostream &OS) {
191192
llvm::emitSourceFileHeader("Syntax tree node list", OS, Records);
192193
Hierarchy H(Records);

clang/utils/TableGen/TableGenBackends.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ void EmitClangCommentCommandList(const llvm::RecordKeeper &Records,
110110
llvm::raw_ostream &OS);
111111
void EmitClangOpcodes(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
112112

113-
void EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
113+
void EmitClangSyntaxNodeList(const llvm::RecordKeeper &Records,
114114
llvm::raw_ostream &OS);
115-
void EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
115+
void EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
116116
llvm::raw_ostream &OS);
117117

118118
void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);

0 commit comments

Comments
 (0)