[clang] d757bbf - [clang][TableGen] Change SyntaxEmitter to use const RecordKeeper (#108478)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 13 07:51:46 PDT 2024
Author: Rahul Joshi
Date: 2024-09-13T07:51:42-07:00
New Revision: d757bbf68f35dbcfd68580e3798cf301862dd314
URL: https://github.com/llvm/llvm-project/commit/d757bbf68f35dbcfd68580e3798cf301862dd314
DIFF: https://github.com/llvm/llvm-project/commit/d757bbf68f35dbcfd68580e3798cf301862dd314.diff
LOG: [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
Added:
Modified:
clang/utils/TableGen/ClangSyntaxEmitter.cpp
clang/utils/TableGen/TableGenBackends.h
Removed:
################################################################################
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 4e59653fac06da..0e09c7917518f2 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -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);
More information about the cfe-commits
mailing list