[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
This commit is contained in:
Rahul Joshi 2024-09-13 07:51:42 -07:00 committed by GitHub
parent f637273d77
commit d757bbf68f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 8 deletions

View File

@ -41,11 +41,12 @@ using llvm::formatv;
// stable and useful way, where abstract Node subclasses correspond to ranges.
class Hierarchy {
public:
Hierarchy(llvm::RecordKeeper &Records) {
for (llvm::Record *T : Records.getAllDerivedDefinitions("NodeType"))
Hierarchy(const llvm::RecordKeeper &Records) {
for (const llvm::Record *T : Records.getAllDerivedDefinitions("NodeType"))
add(T);
for (llvm::Record *Derived : Records.getAllDerivedDefinitions("NodeType"))
if (llvm::Record *Base = Derived->getValueAsOptionalDef("base"))
for (const llvm::Record *Derived :
Records.getAllDerivedDefinitions("NodeType"))
if (const llvm::Record *Base = Derived->getValueAsOptionalDef("base"))
link(Derived, Base);
for (NodeType &N : AllTypes) {
llvm::sort(N.Derived, [](const NodeType *L, const NodeType *R) {
@ -127,7 +128,7 @@ struct SyntaxConstraint {
} // namespace
void clang::EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
void clang::EmitClangSyntaxNodeList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS) {
llvm::emitSourceFileHeader("Syntax tree node list", OS, Records);
Hierarchy H(Records);
@ -186,7 +187,7 @@ static void printDoc(llvm::StringRef Doc, llvm::raw_ostream &OS) {
}
}
void clang::EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
void clang::EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS) {
llvm::emitSourceFileHeader("Syntax tree node list", OS, Records);
Hierarchy H(Records);

View File

@ -110,9 +110,9 @@ void EmitClangCommentCommandList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangOpcodes(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
void EmitClangSyntaxNodeList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
void EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);