llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Rahul Joshi (jurahul) <details> <summary>Changes</summary> Change SyntaxEmitter 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 --- Full diff: https://github.com/llvm/llvm-project/pull/108478.diff 2 Files Affected: - (modified) clang/utils/TableGen/ClangSyntaxEmitter.cpp (+7-6) - (modified) clang/utils/TableGen/TableGenBackends.h (+2-2) ``````````diff diff --git a/clang/utils/TableGen/ClangSyntaxEmitter.cpp b/clang/utils/TableGen/ClangSyntaxEmitter.cpp index 2a69e4c353b6b4..66b27be88f56f5 100644 --- a/clang/utils/TableGen/ClangSyntaxEmitter.cpp +++ b/clang/utils/TableGen/ClangSyntaxEmitter.cpp @@ -41,11 +41,12 @@ using llvm::formatv; // stable and useful way, where abstract Node subclasses correspond to ranges. class Hierarchy { public: - Hierarchy(llvm::RecordKeeper &Records) { - for (llvm::Record *T : Records.getAllDerivedDefinitions("NodeType")) + Hierarchy(const llvm::RecordKeeper &Records) { + for (const llvm::Record *T : Records.getAllDerivedDefinitions("NodeType")) add(T); - for (llvm::Record *Derived : Records.getAllDerivedDefinitions("NodeType")) - if (llvm::Record *Base = Derived->getValueAsOptionalDef("base")) + for (const llvm::Record *Derived : + Records.getAllDerivedDefinitions("NodeType")) + if (const llvm::Record *Base = Derived->getValueAsOptionalDef("base")) link(Derived, Base); for (NodeType &N : AllTypes) { llvm::sort(N.Derived, [](const NodeType *L, const NodeType *R) { @@ -127,7 +128,7 @@ struct SyntaxConstraint { } // namespace -void clang::EmitClangSyntaxNodeList(llvm::RecordKeeper &Records, +void clang::EmitClangSyntaxNodeList(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS) { llvm::emitSourceFileHeader("Syntax tree node list", OS, Records); Hierarchy H(Records); @@ -186,7 +187,7 @@ static void printDoc(llvm::StringRef Doc, llvm::raw_ostream &OS) { } } -void clang::EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records, +void clang::EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS) { llvm::emitSourceFileHeader("Syntax tree node list", OS, Records); Hierarchy H(Records); diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h index 01d16d2dc3e5f1..881e9a8c5eec01 100644 --- a/clang/utils/TableGen/TableGenBackends.h +++ b/clang/utils/TableGen/TableGenBackends.h @@ -108,9 +108,9 @@ void EmitClangCommentCommandList(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS); void EmitClangOpcodes(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangSyntaxNodeList(llvm::RecordKeeper &Records, +void EmitClangSyntaxNodeList(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records, +void EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS); void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); `````````` </details> https://github.com/llvm/llvm-project/pull/108478 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits