[clang] [clang][ExtractAPI] Flatten all enum cases from anonymous enums at top level (PR #93559)

via cfe-commits cfe-commits at lists.llvm.org
Tue May 28 07:57:13 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 8a395b00b85ad64a56a9c65055cc9a26a9499a8d eeeed453e5b21d369d8c2b1d06c640887ec81ace -- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h clang/test/ExtractAPI/anonymous_record_no_typedef.c clang/test/ExtractAPI/enum.c clang/tools/libclang/CXExtractAPI.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
index 9df5138a22..76d7fd798b 100644
--- a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -416,17 +416,19 @@ bool ExtractAPIVisitorBase<Derived>::VisitEnumDecl(const EnumDecl *Decl) {
       Name = getTypedefName(Decl);
 
     auto *ER = API.createRecord<EnumRecord>(
-      USR, Name, createHierarchyInformationForDecl(*Decl), Loc,
-      AvailabilityInfo::createFromDecl(Decl), Comment, Declaration, SubHeading,
-      isInSystemHeader(Decl), false);
+        USR, Name, createHierarchyInformationForDecl(*Decl), Loc,
+        AvailabilityInfo::createFromDecl(Decl), Comment, Declaration,
+        SubHeading, isInSystemHeader(Decl), false);
     ParentContainer = SymbolReference(ER);
   } else {
-    // If this an anonymous enum then the parent scope of the constants is the top level namespace.
+    // If this an anonymous enum then the parent scope of the constants is the
+    // top level namespace.
     ParentContainer = {};
   }
 
   // Now collect information about the enumerators in this enum.
-  getDerivedExtractAPIVisitor().recordEnumConstants(ParentContainer, Decl->enumerators());
+  getDerivedExtractAPIVisitor().recordEnumConstants(ParentContainer,
+                                                    Decl->enumerators());
 
   return true;
 }
@@ -1218,9 +1220,8 @@ void ExtractAPIVisitorBase<Derived>::recordEnumConstants(
         DeclarationFragmentsBuilder::getSubHeading(Constant);
 
     API.createRecord<EnumConstantRecord>(
-        USR, Name, Container, Loc,
-        AvailabilityInfo::createFromDecl(Constant), Comment, Declaration,
-        SubHeading, isInSystemHeader(Constant));
+        USR, Name, Container, Loc, AvailabilityInfo::createFromDecl(Constant),
+        Comment, Declaration, SubHeading, isInSystemHeader(Constant));
   }
 }
 
@@ -1473,10 +1474,9 @@ public:
       return Comment;
 
     if (const auto *Declarator = dyn_cast<DeclaratorDecl>(D)) {
-      const auto *TagTypeDecl =
-          Declarator->getType()->getAsTagDecl();
+      const auto *TagTypeDecl = Declarator->getType()->getAsTagDecl();
       if (TagTypeDecl && TagTypeDecl->isEmbeddedInDeclarator() &&
-            TagTypeDecl->isCompleteDefinition())
+          TagTypeDecl->isCompleteDefinition())
         return this->Context.getRawCommentForDeclNoCache(TagTypeDecl);
     }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/93559


More information about the cfe-commits mailing list