Skip to content

[LLVM][CLange] Rename NodeType::Record to NodeType::Rec #108826

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 1 commit into from
Sep 16, 2024

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Sep 16, 2024

Fixes build failure by avoiding conflicting with Record class name.

Fixes build failure by avoiding conflicting with `Record` class name.
@jurahul jurahul marked this pull request as ready for review September 16, 2024 13:52
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Sep 16, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 16, 2024

@llvm/pr-subscribers-clang

Author: Rahul Joshi (jurahul)

Changes

Fixes build failure by avoiding conflicting with Record class name.


Full diff: https://github.com/llvm/llvm-project/pull/108826.diff

1 Files Affected:

  • (modified) clang/utils/TableGen/ClangSyntaxEmitter.cpp (+11-11)
diff --git a/clang/utils/TableGen/ClangSyntaxEmitter.cpp b/clang/utils/TableGen/ClangSyntaxEmitter.cpp
index 3457e5bd283706..4098a5e88e6820 100644
--- a/clang/utils/TableGen/ClangSyntaxEmitter.cpp
+++ b/clang/utils/TableGen/ClangSyntaxEmitter.cpp
@@ -50,20 +50,20 @@ class Hierarchy {
         link(Derived, Base);
     for (NodeType &N : AllTypes) {
       sort(N.Derived, [](const NodeType *L, const NodeType *R) {
-        return L->Record->getName() < R->Record->getName();
+        return L->Rec->getName() < R->Rec->getName();
       });
       // Alternatives nodes must have subclasses, External nodes may do.
-      assert(N.Record->isSubClassOf("Alternatives") ||
-             N.Record->isSubClassOf("External") || N.Derived.empty());
-      assert(!N.Record->isSubClassOf("Alternatives") || !N.Derived.empty());
+      assert(N.Rec->isSubClassOf("Alternatives") ||
+             N.Rec->isSubClassOf("External") || N.Derived.empty());
+      assert(!N.Rec->isSubClassOf("Alternatives") || !N.Derived.empty());
     }
   }
 
   struct NodeType {
-    const Record *Record = nullptr;
+    const Record *Rec = nullptr;
     const NodeType *Base = nullptr;
     std::vector<const NodeType *> Derived;
-    StringRef name() const { return Record->getName(); }
+    StringRef name() const { return Rec->getName(); }
   };
 
   NodeType &get(StringRef Name = "Node") {
@@ -85,7 +85,7 @@ class Hierarchy {
 private:
   void add(const Record *R) {
     AllTypes.emplace_back();
-    AllTypes.back().Record = R;
+    AllTypes.back().Rec = R;
     bool Inserted = ByName.try_emplace(R->getName(), &AllTypes.back()).second;
     assert(Inserted && "Duplicate node name");
     (void)Inserted;
@@ -200,9 +200,9 @@ void clang::EmitClangSyntaxNodeClasses(const RecordKeeper &Records,
 
   OS << "\n// Node definitions\n\n";
   H.visit([&](const Hierarchy::NodeType &N) {
-    if (N.Record->isSubClassOf("External"))
+    if (N.Rec->isSubClassOf("External"))
       return;
-    printDoc(N.Record->getValueAsString("documentation"), OS);
+    printDoc(N.Rec->getValueAsString("documentation"), OS);
     OS << formatv("class {0}{1} : public {2} {{\n", N.name(),
                   N.Derived.empty() ? " final" : "", N.Base->name());
 
@@ -214,9 +214,9 @@ void clang::EmitClangSyntaxNodeClasses(const RecordKeeper &Records,
       OS << formatv("protected:\n  {0}(NodeKind K) : {1}(K) {{}\npublic:\n",
                     N.name(), N.Base->name());
 
-    if (N.Record->isSubClassOf("Sequence")) {
+    if (N.Rec->isSubClassOf("Sequence")) {
       // Getters for sequence elements.
-      for (const auto &C : N.Record->getValueAsListOfDefs("children")) {
+      for (const auto &C : N.Rec->getValueAsListOfDefs("children")) {
         assert(C->isSubClassOf("Role"));
         StringRef Role = C->getValueAsString("role");
         SyntaxConstraint Constraint(*C->getValueAsDef("syntax"));

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jurahul jurahul merged commit adb7004 into llvm:main Sep 16, 2024
9 of 11 checks passed
@jurahul jurahul deleted the clang_ast_syntax_build_fix branch September 16, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants