Skip to content

Commit dca9f21

Browse files
authored
[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
1 parent 943182e commit dca9f21

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,17 @@ static bool translateCodePointToUTF8(unsigned CodePoint,
4646
return true;
4747
}
4848

49-
void clang::EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records,
50-
raw_ostream &OS) {
51-
std::vector<Record *> Tags = Records.getAllDerivedDefinitions("NCR");
49+
void clang::EmitClangCommentHTMLNamedCharacterReferences(
50+
const RecordKeeper &Records, raw_ostream &OS) {
5251
std::vector<StringMatcher::StringPair> NameToUTF8;
5352
SmallString<32> CLiteral;
54-
for (std::vector<Record *>::iterator I = Tags.begin(), E = Tags.end();
55-
I != E; ++I) {
56-
Record &Tag = **I;
57-
std::string Spelling = std::string(Tag.getValueAsString("Spelling"));
58-
uint64_t CodePoint = Tag.getValueAsInt("CodePoint");
53+
for (const Record *Tag : Records.getAllDerivedDefinitions("NCR")) {
54+
std::string Spelling = std::string(Tag->getValueAsString("Spelling"));
55+
uint64_t CodePoint = Tag->getValueAsInt("CodePoint");
5956
CLiteral.clear();
6057
CLiteral.append("return ");
6158
if (!translateCodePointToUTF8(CodePoint, CLiteral)) {
62-
SrcMgr.PrintMessage(Tag.getLoc().front(),
63-
SourceMgr::DK_Error,
59+
SrcMgr.PrintMessage(Tag->getLoc().front(), SourceMgr::DK_Error,
6460
Twine("invalid code point"));
6561
continue;
6662
}

clang/utils/TableGen/TableGenBackends.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ void EmitClangCommentHTMLTags(llvm::RecordKeeper &Records,
8888
llvm::raw_ostream &OS);
8989
void EmitClangCommentHTMLTagsProperties(llvm::RecordKeeper &Records,
9090
llvm::raw_ostream &OS);
91-
void EmitClangCommentHTMLNamedCharacterReferences(llvm::RecordKeeper &Records,
92-
llvm::raw_ostream &OS);
91+
void EmitClangCommentHTMLNamedCharacterReferences(
92+
const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
9393

9494
void EmitClangCommentCommandInfo(const llvm::RecordKeeper &Records,
9595
llvm::raw_ostream &OS);

0 commit comments

Comments
 (0)