Skip to content

[clang][TableGen] Change ASTProperties Emitter to use const RecordKeeper #108274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ struct CasedTypeInfo {

class ASTPropsEmitter {
raw_ostream &Out;
RecordKeeper &Records;
const RecordKeeper &Records;
std::map<HasProperties, NodeInfo> NodeInfos;
std::vector<PropertyType> AllPropertyTypes;
std::map<PropertyType, CasedTypeInfo> CasedTypeInfos;

public:
ASTPropsEmitter(RecordKeeper &records, raw_ostream &out)
ASTPropsEmitter(const RecordKeeper &records, raw_ostream &out)
: Out(out), Records(records) {

// Find all the properties.
Expand Down Expand Up @@ -587,28 +587,28 @@ void ASTPropsEmitter::emitWriteOfProperty(StringRef writerName,
/// Emit an .inc file that defines the AbstractFooReader class
/// for the given AST class hierarchy.
template <class NodeClass>
static void emitASTReader(RecordKeeper &records, raw_ostream &out,
static void emitASTReader(const RecordKeeper &records, raw_ostream &out,
StringRef description) {
emitSourceFileHeader(description, out, records);

ASTPropsEmitter(records, out).emitNodeReaderClass<NodeClass>();
}

void clang::EmitClangTypeReader(RecordKeeper &records, raw_ostream &out) {
void clang::EmitClangTypeReader(const RecordKeeper &records, raw_ostream &out) {
emitASTReader<TypeNode>(records, out, "A CRTP reader for Clang Type nodes");
}

/// Emit an .inc file that defines the AbstractFooWriter class
/// for the given AST class hierarchy.
template <class NodeClass>
static void emitASTWriter(RecordKeeper &records, raw_ostream &out,
static void emitASTWriter(const RecordKeeper &records, raw_ostream &out,
StringRef description) {
emitSourceFileHeader(description, out, records);

ASTPropsEmitter(records, out).emitNodeWriterClass<NodeClass>();
}

void clang::EmitClangTypeWriter(RecordKeeper &records, raw_ostream &out) {
void clang::EmitClangTypeWriter(const RecordKeeper &records, raw_ostream &out) {
emitASTWriter<TypeNode>(records, out, "A CRTP writer for Clang Type nodes");
}

Expand Down Expand Up @@ -847,7 +847,8 @@ void ASTPropsEmitter::emitBasicReaderWriterFile(const ReaderWriterInfo &info) {

/// Emit an .inc file that defines some helper classes for reading
/// basic values.
void clang::EmitClangBasicReader(RecordKeeper &records, raw_ostream &out) {
void clang::EmitClangBasicReader(const RecordKeeper &records,
raw_ostream &out) {
emitSourceFileHeader("Helper classes for BasicReaders", out, records);

// Use any property, we won't be using those properties.
Expand All @@ -857,7 +858,8 @@ void clang::EmitClangBasicReader(RecordKeeper &records, raw_ostream &out) {

/// Emit an .inc file that defines some helper classes for writing
/// basic values.
void clang::EmitClangBasicWriter(RecordKeeper &records, raw_ostream &out) {
void clang::EmitClangBasicWriter(const RecordKeeper &records,
raw_ostream &out) {
emitSourceFileHeader("Helper classes for BasicWriters", out, records);

// Use any property, we won't be using those properties.
Expand Down
12 changes: 8 additions & 4 deletions clang/utils/TableGen/TableGenBackends.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ void EmitClangDeclContext(const llvm::RecordKeeper &RK, llvm::raw_ostream &OS);
void EmitClangASTNodes(const llvm::RecordKeeper &RK, llvm::raw_ostream &OS,
const std::string &N, const std::string &S,
std::string_view PriorizeIfSubclassOf = "");
void EmitClangBasicReader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitClangBasicWriter(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
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 EmitClangTypeReader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitClangTypeWriter(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitClangTypeReader(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangTypeWriter(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangAttrParserStringSwitches(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangAttrSubjectMatchRulesParserStringSwitches(
Expand Down
Loading