[clang] [clang][TableGen] Change SyntaxEmitter to use const RecordKeeper (PR #108478)
Rahul Joshi via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 12 18:53:14 PDT 2024
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/108478
Change SyntaxEmitter to use const RecordKeeper.
>From d6c867550f90d27db4324e555b303715ee118319 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Thu, 12 Sep 2024 18:51:44 -0700
Subject: [PATCH] [clang][TableGen] Change SyntaxEmitter to use const
RecordKeeper
---
clang/utils/TableGen/ClangSyntaxEmitter.cpp | 13 +++++++------
clang/utils/TableGen/TableGenBackends.h | 4 ++--
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/clang/utils/TableGen/ClangSyntaxEmitter.cpp b/clang/utils/TableGen/ClangSyntaxEmitter.cpp
index 2a69e4c353b6b4..66b27be88f56f5 100644
--- a/clang/utils/TableGen/ClangSyntaxEmitter.cpp
+++ b/clang/utils/TableGen/ClangSyntaxEmitter.cpp
@@ -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);
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index 01d16d2dc3e5f1..881e9a8c5eec01 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -108,9 +108,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);
More information about the cfe-commits
mailing list