[clang] [clang][TableGen] Change TypeNodesEmitter to use const RecordKeeper (PR #108476)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 12 20:47:48 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Rahul Joshi (jurahul)
<details>
<summary>Changes</summary>
Change TypeNodesEmitter 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
---
Full diff: https://github.com/llvm/llvm-project/pull/108476.diff
2 Files Affected:
- (modified) clang/utils/TableGen/ClangTypeNodesEmitter.cpp (+6-7)
- (modified) clang/utils/TableGen/TableGenBackends.h (+2-1)
``````````diff
diff --git a/clang/utils/TableGen/ClangTypeNodesEmitter.cpp b/clang/utils/TableGen/ClangTypeNodesEmitter.cpp
index 66bdf5e67602ba..41a2d0cd066fef 100644
--- a/clang/utils/TableGen/ClangTypeNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangTypeNodesEmitter.cpp
@@ -74,16 +74,15 @@ using namespace clang::tblgen;
namespace {
class TypeNodeEmitter {
- RecordKeeper &Records;
+ const RecordKeeper &Records;
raw_ostream &Out;
- const std::vector<Record*> Types;
+ ArrayRef<const Record *> Types;
std::vector<StringRef> MacrosToUndef;
public:
- TypeNodeEmitter(RecordKeeper &records, raw_ostream &out)
- : Records(records), Out(out),
- Types(Records.getAllDerivedDefinitions(TypeNodeClassName)) {
- }
+ TypeNodeEmitter(const RecordKeeper &records, raw_ostream &out)
+ : Records(records), Out(out),
+ Types(Records.getAllDerivedDefinitions(TypeNodeClassName)) {}
void emit();
@@ -203,6 +202,6 @@ void TypeNodeEmitter::emitUndefs() {
}
}
-void clang::EmitClangTypeNodes(RecordKeeper &records, raw_ostream &out) {
+void clang::EmitClangTypeNodes(const RecordKeeper &records, raw_ostream &out) {
TypeNodeEmitter(records, out).emit();
}
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index 01d16d2dc3e5f1..79e9be6c031927 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -39,7 +39,8 @@ void EmitClangBasicReader(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangBasicWriter(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangTypeNodes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitClangTypeNodes(const llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
void EmitClangTypeReader(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangTypeWriter(const llvm::RecordKeeper &Records,
``````````
</details>
https://github.com/llvm/llvm-project/pull/108476
More information about the cfe-commits
mailing list