[clang] [clang][TableGen] Change comment command emitter to const RecordKeeper (PR #108199)
Rahul Joshi via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 11 05:01:42 PDT 2024
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/108199
Change comment command emitter to const RecordKeeper.
>From 5e344e11844fc50ef231c8f8937f5251e76a1150 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 11 Sep 2024 04:59:50 -0700
Subject: [PATCH] [clang][TableGen] Change comment command emitter to const
RecordKeeper
---
.../TableGen/ClangCommentCommandInfoEmitter.cpp | 14 +++++++-------
clang/utils/TableGen/TableGenBackends.h | 4 ++--
2 files changed, 9 insertions(+), 9 deletions(-)
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 3a424c9c91fe71..2ead14045329bd 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -90,9 +90,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