[clang] dca9f21 - [clang][TableGen] Change HTML Emitter to use const RecordKeeper (#108201)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 11 10:50:03 PDT 2024
Author: Rahul Joshi
Date: 2024-09-11T10:50:00-07:00
New Revision: dca9f21724c2206973b78ddc3ab3327b85f1e3ec
URL: https://github.com/llvm/llvm-project/commit/dca9f21724c2206973b78ddc3ab3327b85f1e3ec
DIFF: https://github.com/llvm/llvm-project/commit/dca9f21724c2206973b78ddc3ab3327b85f1e3ec.diff
LOG: [clang][TableGen] Change HTML Emitter to use const RecordKeeper (#108201)
Change HTMLNamedCharacterReferenceEmitter 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/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
clang/utils/TableGen/TableGenBackends.h
Removed:
################################################################################
diff --git a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
index f1cd9af0519d1b..bd75b3f6b652a1 100644
--- a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
@@ -46,21 +46,17 @@ static bool translateCodePointToUTF8(unsigned CodePoint,
return true;
}
-void clang::EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records,
- raw_ostream &OS) {
- std::vector<Record *> Tags = Records.getAllDerivedDefinitions("NCR");
+void clang::EmitClangCommentHTMLNamedCharacterReferences(
+ const RecordKeeper &Records, raw_ostream &OS) {
std::vector<StringMatcher::StringPair> NameToUTF8;
SmallString<32> CLiteral;
- for (std::vector<Record *>::iterator I = Tags.begin(), E = Tags.end();
- I != E; ++I) {
- Record &Tag = **I;
- std::string Spelling = std::string(Tag.getValueAsString("Spelling"));
- uint64_t CodePoint = Tag.getValueAsInt("CodePoint");
+ for (const Record *Tag : Records.getAllDerivedDefinitions("NCR")) {
+ std::string Spelling = std::string(Tag->getValueAsString("Spelling"));
+ uint64_t CodePoint = Tag->getValueAsInt("CodePoint");
CLiteral.clear();
CLiteral.append("return ");
if (!translateCodePointToUTF8(CodePoint, CLiteral)) {
- SrcMgr.PrintMessage(Tag.getLoc().front(),
- SourceMgr::DK_Error,
+ SrcMgr.PrintMessage(Tag->getLoc().front(), SourceMgr::DK_Error,
Twine("invalid code point"));
continue;
}
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index 5b1b0153e8cef9..e8287d5bee08b3 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -88,8 +88,8 @@ void EmitClangCommentHTMLTags(llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangCommentHTMLTagsProperties(llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
-void EmitClangCommentHTMLNamedCharacterReferences(llvm::RecordKeeper &Records,
- llvm::raw_ostream &OS);
+void EmitClangCommentHTMLNamedCharacterReferences(
+ const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitClangCommentCommandInfo(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
More information about the cfe-commits
mailing list