[clang] 943182e - [clang][TableGen] Change comment command emitter to const RecordKeeper (#108199)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 11 10:49:37 PDT 2024
Author: Rahul Joshi
Date: 2024-09-11T10:49:33-07:00
New Revision: 943182e3112756de8982babad6b5c8e74fdf8d02
URL: https://github.com/llvm/llvm-project/commit/943182e3112756de8982babad6b5c8e74fdf8d02
DIFF: https://github.com/llvm/llvm-project/commit/943182e3112756de8982babad6b5c8e74fdf8d02.diff
LOG: [clang][TableGen] Change comment command emitter to const RecordKeeper (#108199)
Change comment command emitter to 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/ClangCommentCommandInfoEmitter.cpp
clang/utils/TableGen/TableGenBackends.h
Removed:
################################################################################
diff --git a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
index aee7d38786a51c..1a2503dcf660cf 100644
--- a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
@@ -20,16 +20,16 @@
using namespace llvm;
-void clang::EmitClangCommentCommandInfo(RecordKeeper &Records,
+void clang::EmitClangCommentCommandInfo(const RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader("A list of commands useable in documentation comments",
OS, Records);
OS << "namespace {\n"
"const CommandInfo Commands[] = {\n";
- std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Command");
+ ArrayRef<const Record *> Tags = Records.getAllDerivedDefinitions("Command");
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
- Record &Tag = *Tags[i];
+ const Record &Tag = *Tags[i];
OS << " { "
<< "\"" << Tag.getValueAsString("Name") << "\", "
<< "\"" << Tag.getValueAsString("EndCommandName") << "\", " << i << ", "
@@ -62,7 +62,7 @@ void clang::EmitClangCommentCommandInfo(RecordKeeper &Records,
std::vector<StringMatcher::StringPair> Matches;
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
- Record &Tag = *Tags[i];
+ const Record &Tag = *Tags[i];
std::string Name = std::string(Tag.getValueAsString("Name"));
std::string Return;
raw_string_ostream(Return) << "return &Commands[" << i << "];";
@@ -112,7 +112,7 @@ static std::string MangleName(StringRef Str) {
return Mangled;
}
-void clang::EmitClangCommentCommandList(RecordKeeper &Records,
+void clang::EmitClangCommentCommandList(const RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader("A list of commands useable in documentation comments",
OS, Records);
@@ -121,9 +121,9 @@ void clang::EmitClangCommentCommandList(RecordKeeper &Records,
<< "# define COMMENT_COMMAND(NAME)\n"
<< "#endif\n";
- std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Command");
+ ArrayRef<const Record *> Tags = Records.getAllDerivedDefinitions("Command");
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
- Record &Tag = *Tags[i];
+ const Record &Tag = *Tags[i];
std::string MangledName = MangleName(Tag.getValueAsString("Name"));
OS << "COMMENT_COMMAND(" << MangledName << ")\n";
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index 35cc04d6ef31f4..5b1b0153e8cef9 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -91,9 +91,9 @@ void EmitClangCommentHTMLTagsProperties(llvm::RecordKeeper &Records,
void EmitClangCommentHTMLNamedCharacterReferences(llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangCommentCommandInfo(llvm::RecordKeeper &Records,
+void EmitClangCommentCommandInfo(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangCommentCommandList(llvm::RecordKeeper &Records,
+void EmitClangCommentCommandList(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangOpcodes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
More information about the cfe-commits
mailing list