Skip to content

Revert "Reenable external categories" #87586

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

Closed
wants to merge 1 commit into from

Conversation

vitalybuka
Copy link
Collaborator

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 4, 2024

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)

Changes

Reverts llvm/llvm-project#87357

Breaks https://lab.llvm.org/buildbot/#/builders/5/builds/42306


Patch is 533.30 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/87586.diff

80 Files Affected:

  • (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (-6)
  • (modified) clang/include/clang/Basic/DiagnosticFrontendKinds.td (-4)
  • (modified) clang/include/clang/Basic/DiagnosticGroups.td (-2)
  • (modified) clang/include/clang/Driver/Options.td (+3-18)
  • (modified) clang/include/clang/ExtractAPI/API.h (+834-713)
  • (removed) clang/include/clang/ExtractAPI/APIRecords.inc (-103)
  • (modified) clang/include/clang/ExtractAPI/DeclarationFragments.h (-14)
  • (modified) clang/include/clang/ExtractAPI/ExtractAPIActionBase.h (+3-5)
  • (modified) clang/include/clang/ExtractAPI/ExtractAPIVisitor.h (+328-346)
  • (modified) clang/include/clang/ExtractAPI/FrontendActions.h (+6)
  • (removed) clang/include/clang/ExtractAPI/Serialization/APISetVisitor.h (-172)
  • (added) clang/include/clang/ExtractAPI/Serialization/SerializerBase.h (+314)
  • (modified) clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h (+107-147)
  • (modified) clang/include/clang/Frontend/FrontendOptions.h (+3-18)
  • (modified) clang/lib/Driver/Driver.cpp (-7)
  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (-15)
  • (modified) clang/lib/ExtractAPI/API.cpp (+491-53)
  • (modified) clang/lib/ExtractAPI/DeclarationFragments.cpp (+25-46)
  • (modified) clang/lib/ExtractAPI/ExtractAPIConsumer.cpp (+59-53)
  • (modified) clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp (+564-379)
  • (modified) clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.cpp (+1-5)
  • (modified) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp (+3-7)
  • (modified) clang/test/ExtractAPI/anonymous_record_no_typedef.c (+1-2)
  • (modified) clang/test/ExtractAPI/availability.c (+1-1)
  • (modified) clang/test/ExtractAPI/bool.c (+1-1)
  • (modified) clang/test/ExtractAPI/bool.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/class.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/class_template.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/class_template_param_inheritance.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/class_template_partial_spec.cpp (+2-2)
  • (modified) clang/test/ExtractAPI/class_template_spec.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/concept.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/constructor_destructor.cpp (+3-3)
  • (modified) clang/test/ExtractAPI/conversions.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/emit-symbol-graph/multi_file.c (+3-4)
  • (modified) clang/test/ExtractAPI/emit-symbol-graph/single_file.c (+2-3)
  • (modified) clang/test/ExtractAPI/enum.c (+1-1)
  • (modified) clang/test/ExtractAPI/field_template.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/function_noexcepts.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/global_func_template.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/global_func_template_spec.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/global_record.c (+1-1)
  • (modified) clang/test/ExtractAPI/global_record_multifile.c (+1-1)
  • (modified) clang/test/ExtractAPI/global_var_template.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/global_var_template_partial_spec.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/global_var_template_spec.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/known_files_only.c (+96-5)
  • (modified) clang/test/ExtractAPI/language.c (+3-3)
  • (modified) clang/test/ExtractAPI/macro_undefined.c (+1-1)
  • (modified) clang/test/ExtractAPI/macros.c (+1-1)
  • (removed) clang/test/ExtractAPI/metadata_and_module.c (-32)
  • (modified) clang/test/ExtractAPI/method_template.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/method_template_spec.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/methods.cpp (+453-207)
  • (modified) clang/test/ExtractAPI/multiple_inheritance.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/namespace.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/nested_namespaces.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/objc_block.m (+951-616)
  • (modified) clang/test/ExtractAPI/objc_category.m (+329-9)
  • (removed) clang/test/ExtractAPI/objc_external_category.m (-49)
  • (modified) clang/test/ExtractAPI/objc_id_protocol.m (+309-48)
  • (modified) clang/test/ExtractAPI/objc_instancetype.m (+2-2)
  • (modified) clang/test/ExtractAPI/objc_interface.m (+687-346)
  • (added) clang/test/ExtractAPI/objc_module_category.m (+404)
  • (modified) clang/test/ExtractAPI/objc_property.m (+591-9)
  • (modified) clang/test/ExtractAPI/objc_protocol.m (+1-1)
  • (added) clang/test/ExtractAPI/objc_various_categories.m (+507)
  • (modified) clang/test/ExtractAPI/operator_overload.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/relative_include.m (+1-1)
  • (modified) clang/test/ExtractAPI/simple_inheritance.cpp (+1-1)
  • (modified) clang/test/ExtractAPI/struct.c (+1-1)
  • (modified) clang/test/ExtractAPI/typedef.c (+381-83)
  • (modified) clang/test/ExtractAPI/typedef_anonymous_record.c (+461-151)
  • (modified) clang/test/ExtractAPI/typedef_chain.c (+1-1)
  • (modified) clang/test/ExtractAPI/typedef_struct_enum.c (+430-131)
  • (modified) clang/test/ExtractAPI/underscored.c (+400-11)
  • (modified) clang/test/ExtractAPI/union.c (+2-2)
  • (modified) clang/test/ExtractAPI/vfs_redirected_include.m (+1-1)
  • (modified) clang/test/Index/extract-api-cursor.m (-9)
  • (modified) clang/tools/libclang/CXExtractAPI.cpp (+54-19)
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d86f7510bde20..592ed3bda51506 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -548,12 +548,6 @@ def err_drv_extract_api_wrong_kind : Error<
   "header file '%0' input '%1' does not match the type of prior input "
   "in api extraction; use '-x %2' to override">;
 
-def err_drv_missing_symbol_graph_dir: Error<
-  "Must provide a symbol graph output directory using --symbol-graph-dir=<directory>">;
-
-def err_drv_unexpected_symbol_graph_output : Error<
-  "Unexpected output symbol graph '%1'; please provide --symbol-graph-dir=<directory> instead">;
-
 def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
   InGroup<DiagGroup<"slash-u-filename">>;
 def note_use_dashdash : Note<
diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 14b08d4927ec5e..ba23cf84c5e343 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -366,8 +366,4 @@ def warn_profile_data_misexpect : Warning<
 def err_extract_api_ignores_file_not_found :
   Error<"file '%0' specified by '--extract-api-ignores=' not found">, DefaultFatal;
 
-def warn_missing_symbol_graph_dir : Warning<
-  "Missing symbol graph output directory, defaulting to working directory">,
-  InGroup<ExtractAPIMisuse>;
-
 }
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 5251774ff4efd6..520168f01fd846 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1517,5 +1517,3 @@ def UnsafeBufferUsage : DiagGroup<"unsafe-buffer-usage", [UnsafeBufferUsageInCon
 // Warnings and notes InstallAPI verification.
 def InstallAPIViolation : DiagGroup<"installapi-violation">;
 
-// Warnings about misuse of ExtractAPI options.
-def ExtractAPIMisuse : DiagGroup<"extractapi-misuse">;
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index c3e90a70925b78..f5289fb00c895e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1507,29 +1507,14 @@ def extract_api : Flag<["-"], "extract-api">,
 def product_name_EQ: Joined<["--"], "product-name=">,
   Visibility<[ClangOption, CC1Option]>,
   MarshallingInfoString<FrontendOpts<"ProductName">>;
-def emit_symbol_graph: Flag<["-"], "emit-symbol-graph">,
+def emit_symbol_graph_EQ: JoinedOrSeparate<["--"], "emit-symbol-graph=">,
   Visibility<[ClangOption, CC1Option]>,
-  HelpText<"Generate Extract API information as a side effect of compilation.">,
-  MarshallingInfoFlag<FrontendOpts<"EmitSymbolGraph">>;
-def emit_extension_symbol_graphs: Flag<["--"], "emit-extension-symbol-graphs">,
-  Visibility<[ClangOption, CC1Option]>,
-  HelpText<"Generate additional symbol graphs for extended modules.">,
-  MarshallingInfoFlag<FrontendOpts<"EmitExtensionSymbolGraphs">>;
+    HelpText<"Generate Extract API information as a side effect of compilation.">,
+    MarshallingInfoString<FrontendOpts<"SymbolGraphOutputDir">>;
 def extract_api_ignores_EQ: CommaJoined<["--"], "extract-api-ignores=">,
   Visibility<[ClangOption, CC1Option]>,
     HelpText<"Comma separated list of files containing a new line separated list of API symbols to ignore when extracting API information.">,
     MarshallingInfoStringVector<FrontendOpts<"ExtractAPIIgnoresFileList">>;
-def symbol_graph_dir_EQ: Joined<["--"], "symbol-graph-dir=">,
-   Visibility<[ClangOption, CC1Option]>,
-   HelpText<"Directory in which to emit symbol graphs.">,
-   MarshallingInfoString<FrontendOpts<"SymbolGraphOutputDir">>;
-def emit_pretty_sgf: Flag<["--"], "pretty-sgf">,
-    Visibility<[ClangOption, CC1Option]>,
-    HelpText<"Emit pretty printed symbol graphs">,
-    MarshallingInfoFlag<FrontendOpts<"EmitPrettySymbolGraphs">>;
-def emit_sgf_symbol_labels_for_testing: Flag<["--"], "emit-sgf-symbol-labels-for-testing">,
-   Visibility<[CC1Option]>,
-   MarshallingInfoFlag<FrontendOpts<"EmitSymbolGraphSymbolLabelsForTesting">>;
 def e : Separate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
 def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>,
   Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/include/clang/ExtractAPI/API.h b/clang/include/clang/ExtractAPI/API.h
index 92cacf65c7d64e..b220db294101d8 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -20,25 +20,17 @@
 
 #include "clang/AST/Availability.h"
 #include "clang/AST/Decl.h"
-#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
-#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
-#include <cstddef>
-#include <iterator>
 #include <memory>
-#include <optional>
 #include <type_traits>
 
 namespace clang {
@@ -157,58 +149,15 @@ class Template {
 /// \endcode
 using DocComment = std::vector<RawComment::CommentLine>;
 
-struct APIRecord;
-
-// This represents a reference to another symbol that might come from external
-/// sources.
-struct SymbolReference {
-  StringRef Name;
-  StringRef USR;
-
-  /// The source project/module/product of the referred symbol.
-  StringRef Source;
-
-  // A Pointer to the APIRecord for this reference if known
-  const APIRecord *Record = nullptr;
-
-  SymbolReference() = default;
-  SymbolReference(StringRef Name, StringRef USR, StringRef Source = "")
-      : Name(Name), USR(USR), Source(Source) {}
-  SymbolReference(const APIRecord *R);
-
-  /// Determine if this SymbolReference is empty.
-  ///
-  /// \returns true if and only if all \c Name, \c USR, and \c Source is empty.
-  bool empty() const { return Name.empty() && USR.empty() && Source.empty(); }
-};
-
-class RecordContext;
-
-// Concrete classes deriving from APIRecord need to have a construct with first
-// arguments USR, and Name, in that order. This is so that they
-// are compatible with `APISet::createRecord`.
-// When adding a new kind of record don't forget to update APIRecords.inc!
+// Classes deriving from APIRecord need to have USR be the first constructor
+// argument. This is so that they are compatible with `addTopLevelRecord`
+// defined in API.cpp
 /// The base representation of an API record. Holds common symbol information.
 struct APIRecord {
   /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
   enum RecordKind {
     RK_Unknown,
-    // If adding a record context record kind here make sure to update
-    // RecordContext::classof if needed and add a RECORD_CONTEXT entry to
-    // APIRecords.inc
-    RK_FirstRecordContext,
     RK_Namespace,
-    RK_Enum,
-    RK_Struct,
-    RK_Union,
-    RK_ObjCInterface,
-    RK_ObjCCategory,
-    RK_ObjCProtocol,
-    RK_CXXClass,
-    RK_ClassTemplate,
-    RK_ClassTemplateSpecialization,
-    RK_ClassTemplatePartialSpecialization,
-    RK_LastRecordContext,
     RK_GlobalFunction,
     RK_GlobalFunctionTemplate,
     RK_GlobalFunctionTemplateSpecialization,
@@ -217,11 +166,18 @@ struct APIRecord {
     RK_GlobalVariableTemplateSpecialization,
     RK_GlobalVariableTemplatePartialSpecialization,
     RK_EnumConstant,
+    RK_Enum,
     RK_StructField,
+    RK_Struct,
     RK_UnionField,
+    RK_Union,
     RK_StaticField,
     RK_CXXField,
     RK_CXXFieldTemplate,
+    RK_CXXClass,
+    RK_ClassTemplate,
+    RK_ClassTemplateSpecialization,
+    RK_ClassTemplatePartialSpecialization,
     RK_Concept,
     RK_CXXStaticMethod,
     RK_CXXInstanceMethod,
@@ -234,15 +190,40 @@ struct APIRecord {
     RK_ObjCIvar,
     RK_ObjCClassMethod,
     RK_ObjCInstanceMethod,
+    RK_ObjCInterface,
+    RK_ObjCCategory,
+    RK_ObjCCategoryModule,
+    RK_ObjCProtocol,
     RK_MacroDefinition,
     RK_Typedef,
   };
 
+  /// Stores information about the context of the declaration of this API.
+  /// This is roughly analogous to the DeclContext hierarchy for an AST Node.
+  struct HierarchyInformation {
+    /// The USR of the parent API.
+    StringRef ParentUSR;
+    /// The name of the parent API.
+    StringRef ParentName;
+    /// The record kind of the parent API.
+    RecordKind ParentKind = RK_Unknown;
+    /// A pointer to the parent APIRecord if known.
+    APIRecord *ParentRecord = nullptr;
+
+    HierarchyInformation() = default;
+    HierarchyInformation(StringRef ParentUSR, StringRef ParentName,
+                         RecordKind Kind, APIRecord *ParentRecord = nullptr)
+        : ParentUSR(ParentUSR), ParentName(ParentName), ParentKind(Kind),
+          ParentRecord(ParentRecord) {}
+
+    bool empty() const {
+      return ParentUSR.empty() && ParentName.empty() &&
+             ParentKind == RK_Unknown && ParentRecord == nullptr;
+    }
+  };
+
   StringRef USR;
   StringRef Name;
-
-  SymbolReference Parent;
-
   PresumedLoc Location;
   AvailabilityInfo Availability;
   LinkageInfo Linkage;
@@ -261,169 +242,79 @@ struct APIRecord {
   /// Objective-C class/instance methods).
   DeclarationFragments SubHeading;
 
+  /// Information about the parent record of this record.
+  HierarchyInformation ParentInformation;
+
   /// Whether the symbol was defined in a system header.
   bool IsFromSystemHeader;
 
-  AccessControl Access;
-
 private:
   const RecordKind Kind;
-  friend class RecordContext;
-  // Used to store the next child record in RecordContext. This works because
-  // APIRecords semantically only have one parent.
-  mutable APIRecord *NextInContext = nullptr;
 
 public:
-  APIRecord *getNextInContext() const { return NextInContext; }
-
   RecordKind getKind() const { return Kind; }
 
-  static APIRecord *castFromRecordContext(const RecordContext *Ctx);
-  static RecordContext *castToRecordContext(const APIRecord *Record);
-
   APIRecord() = delete;
 
   APIRecord(RecordKind Kind, StringRef USR, StringRef Name,
-            SymbolReference Parent, PresumedLoc Location,
-            AvailabilityInfo Availability, LinkageInfo Linkage,
-            const DocComment &Comment, DeclarationFragments Declaration,
-            DeclarationFragments SubHeading, bool IsFromSystemHeader,
-            AccessControl Access = AccessControl())
-      : USR(USR), Name(Name), Parent(std::move(Parent)), Location(Location),
+            PresumedLoc Location, AvailabilityInfo Availability,
+            LinkageInfo Linkage, const DocComment &Comment,
+            DeclarationFragments Declaration, DeclarationFragments SubHeading,
+            bool IsFromSystemHeader)
+      : USR(USR), Name(Name), Location(Location),
         Availability(std::move(Availability)), Linkage(Linkage),
         Comment(Comment), Declaration(Declaration), SubHeading(SubHeading),
-        IsFromSystemHeader(IsFromSystemHeader), Access(std::move(Access)),
-        Kind(Kind) {}
+        IsFromSystemHeader(IsFromSystemHeader), Kind(Kind) {}
 
   APIRecord(RecordKind Kind, StringRef USR, StringRef Name)
       : USR(USR), Name(Name), Kind(Kind) {}
 
   // Pure virtual destructor to make APIRecord abstract
   virtual ~APIRecord() = 0;
-  static bool classof(const APIRecord *Record) { return true; }
-  static bool classofKind(RecordKind K) { return true; }
-  static bool classof(const RecordContext *Ctx) { return true; }
-};
-
-/// Base class used for specific record types that have children records this is
-/// analogous to the DeclContext for the AST
-class RecordContext {
-public:
-  static bool classof(const APIRecord *Record) {
-    return classofKind(Record->getKind());
-  }
-  static bool classofKind(APIRecord::RecordKind K) {
-    return K > APIRecord::RK_FirstRecordContext &&
-           K < APIRecord::RK_LastRecordContext;
-  }
-
-  static bool classof(const RecordContext *Context) { return true; }
-
-  RecordContext(APIRecord::RecordKind Kind) : Kind(Kind) {}
-
-  APIRecord::RecordKind getKind() const { return Kind; }
-
-  struct record_iterator {
-  private:
-    APIRecord *Current = nullptr;
-
-  public:
-    using value_type = APIRecord *;
-    using reference = const value_type &;
-    using pointer = const value_type *;
-    using iterator_category = std::forward_iterator_tag;
-    using difference_type = std::ptrdiff_t;
-
-    record_iterator() = default;
-    explicit record_iterator(value_type R) : Current(R) {}
-    reference operator*() const { return Current; }
-    // This doesn't strictly meet the iterator requirements, but it's the
-    // behavior we want here.
-    value_type operator->() const { return Current; }
-    record_iterator &operator++() {
-      Current = Current->getNextInContext();
-      return *this;
-    }
-    record_iterator operator++(int) {
-      record_iterator tmp(*this);
-      ++(*this);
-      return tmp;
-    }
-
-    friend bool operator==(record_iterator x, record_iterator y) {
-      return x.Current == y.Current;
-    }
-    friend bool operator!=(record_iterator x, record_iterator y) {
-      return x.Current != y.Current;
-    }
-  };
-
-  using record_range = llvm::iterator_range<record_iterator>;
-  record_range records() const {
-    return record_range(records_begin(), records_end());
-  }
-  record_iterator records_begin() const { return record_iterator(First); };
-  record_iterator records_end() const { return record_iterator(); }
-  bool records_empty() const { return First == nullptr; };
-
-private:
-  APIRecord::RecordKind Kind;
-  mutable APIRecord *First = nullptr;
-  mutable APIRecord *Last = nullptr;
-
-protected:
-  friend class APISet;
-  void addToRecordChain(APIRecord *) const;
 };
 
-struct NamespaceRecord : APIRecord, RecordContext {
-  NamespaceRecord(StringRef USR, StringRef Name, SymbolReference Parent,
-                  PresumedLoc Loc, AvailabilityInfo Availability,
-                  LinkageInfo Linkage, const DocComment &Comment,
-                  DeclarationFragments Declaration,
+struct NamespaceRecord : APIRecord {
+  NamespaceRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
+                  AvailabilityInfo Availability, LinkageInfo Linkage,
+                  const DocComment &Comment, DeclarationFragments Declaration,
                   DeclarationFragments SubHeading, bool IsFromSystemHeader)
-      : APIRecord(RK_Namespace, USR, Name, Parent, Loc, std::move(Availability),
+      : APIRecord(RK_Namespace, USR, Name, Loc, std::move(Availability),
                   Linkage, Comment, Declaration, SubHeading,
-                  IsFromSystemHeader),
-        RecordContext(RK_Namespace) {}
+                  IsFromSystemHeader) {}
 
   static bool classof(const APIRecord *Record) {
-    return classofKind(Record->getKind());
+    return Record->getKind() == RK_Namespace;
   }
-  static bool classofKind(RecordKind K) { return K == RK_Namespace; }
 };
 
 /// This holds information associated with global functions.
 struct GlobalFunctionRecord : APIRecord {
   FunctionSignature Signature;
 
-  GlobalFunctionRecord(StringRef USR, StringRef Name, SymbolReference Parent,
-                       PresumedLoc Loc, AvailabilityInfo Availability,
-                       LinkageInfo Linkage, const DocComment &Comment,
+  GlobalFunctionRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
+                       AvailabilityInfo Availability, LinkageInfo Linkage,
+                       const DocComment &Comment,
                        DeclarationFragments Declaration,
                        DeclarationFragments SubHeading,
                        FunctionSignature Signature, bool IsFromSystemHeader)
-      : APIRecord(RK_GlobalFunction, USR, Name, Parent, Loc,
-                  std::move(Availability), Linkage, Comment, Declaration,
-                  SubHeading, IsFromSystemHeader),
+      : APIRecord(RK_GlobalFunction, USR, Name, Loc, std::move(Availability),
+                  Linkage, Comment, Declaration, SubHeading,
+                  IsFromSystemHeader),
         Signature(Signature) {}
 
   GlobalFunctionRecord(RecordKind Kind, StringRef USR, StringRef Name,
-                       SymbolReference Parent, PresumedLoc Loc,
-                       AvailabilityInfo Availability, LinkageInfo Linkage,
-                       const DocComment &Comment,
+                       PresumedLoc Loc, AvailabilityInfo Availability,
+                       LinkageInfo Linkage, const DocComment &Comment,
                        DeclarationFragments Declaration,
                        DeclarationFragments SubHeading,
                        FunctionSignature Signature, bool IsFromSystemHeader)
-      : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
-                  Linkage, Comment, Declaration, SubHeading,
-                  IsFromSystemHeader),
+      : APIRecord(Kind, USR, Name, Loc, std::move(Availability), Linkage,
+                  Comment, Declaration, SubHeading, IsFromSystemHeader),
         Signature(Signature) {}
 
   static bool classof(const APIRecord *Record) {
-    return classofKind(Record->getKind());
+    return Record->getKind() == RK_GlobalFunction;
   }
-  static bool classofKind(RecordKind K) { return K == RK_GlobalFunction; }
 
 private:
   virtual void anchor();
@@ -432,74 +323,63 @@ struct GlobalFunctionRecord : APIRecord {
 struct GlobalFunctionTemplateRecord : GlobalFunctionRecord {
   Template Templ;
 
-  GlobalFunctionTemplateRecord(StringRef USR, StringRef Name,
-                               SymbolReference Parent, PresumedLoc Loc,
+  GlobalFunctionTemplateRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
                                AvailabilityInfo Availability,
                                LinkageInfo Linkage, const DocComment &Comment,
                                DeclarationFragments Declaration,
                                DeclarationFragments SubHeading,
                                FunctionSignature Signature, Template Template,
                                bool IsFromSystemHeader)
-      : GlobalFunctionRecord(RK_GlobalFunctionTemplate, USR, Name, Parent, Loc,
+      : GlobalFunctionRecord(RK_GlobalFunctionTemplate, USR, Name, Loc,
                              std::move(Availability), Linkage, Comment,
                              Declaration, SubHeading, Signature,
                              IsFromSystemHeader),
         Templ(Template) {}
 
   static bool classof(const APIRecord *Record) {
-    return classofKind(Record->getKind());
-  }
-  static bool classofKind(RecordKind K) {
-    return K == RK_GlobalFunctionTemplate;
+    return Record->getKind() == RK_GlobalFunctionTemplate;
   }
 };
 
 struct GlobalFunctionTemplateSpecializationRecord : GlobalFunctionRecord {
   GlobalFunctionTemplateSpecializationRecord(
-      StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
+      StringRef USR, StringRef Name, PresumedLoc Loc,
       AvailabilityInfo Availability, LinkageInfo Linkage,
       const DocComment &Comment, DeclarationFragments Declaration,
       DeclarationFragments SubHeading, FunctionSignature Signature,
       bool IsFromSystemHeader)
       : GlobalFunctionRecord(RK_GlobalFunctionTemplateSpecialization, USR, Name,
-                             Parent, Loc, std::move(Availability), Linkage,
-                             Comment, Declaration, SubHeading, Signature,
+                             Loc, std::move(Availability), Linkage, Comment,
+                             Declaration, SubHeading, Signature,
                              IsFromSystemHeader) {}
 
   static bool classof(const APIRecord *Record) {
-    return classofKind(Record->getKind());
-  }
-  static bool classofKind(RecordKind K) {
-    return K == RK_GlobalFunctionTemplateSpecialization;
+    return Record->getKind() == RK_GlobalFunctionTemplateSpecialization;
   }
 };
 
 /// This holds information associated with global functions.
 struct GlobalVariableRecord : APIRecord {
-  GlobalVariableRecord(StringRef USR, StringRef Name, SymbolReference Parent,
-          ...
[truncated]

Copy link

github-actions bot commented Apr 4, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 7e2a1d6f23cb604203324b47237f8e463704a497 28fa873d3642324ba64f1624a8ae0cc34c582489 -- clang/include/clang/ExtractAPI/Serialization/SerializerBase.h clang/include/clang/ExtractAPI/API.h clang/include/clang/ExtractAPI/DeclarationFragments.h clang/include/clang/ExtractAPI/ExtractAPIActionBase.h clang/include/clang/ExtractAPI/ExtractAPIVisitor.h clang/include/clang/ExtractAPI/FrontendActions.h clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h clang/include/clang/Frontend/FrontendOptions.h clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/ExtractAPI/API.cpp clang/lib/ExtractAPI/DeclarationFragments.cpp clang/lib/ExtractAPI/ExtractAPIConsumer.cpp clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.cpp clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp clang/test/ExtractAPI/anonymous_record_no_typedef.c clang/test/ExtractAPI/availability.c clang/test/ExtractAPI/bool.c clang/test/ExtractAPI/bool.cpp clang/test/ExtractAPI/class.cpp clang/test/ExtractAPI/class_template.cpp clang/test/ExtractAPI/class_template_param_inheritance.cpp clang/test/ExtractAPI/class_template_partial_spec.cpp clang/test/ExtractAPI/class_template_spec.cpp clang/test/ExtractAPI/concept.cpp clang/test/ExtractAPI/constructor_destructor.cpp clang/test/ExtractAPI/conversions.cpp clang/test/ExtractAPI/emit-symbol-graph/multi_file.c clang/test/ExtractAPI/emit-symbol-graph/single_file.c clang/test/ExtractAPI/enum.c clang/test/ExtractAPI/field_template.cpp clang/test/ExtractAPI/function_noexcepts.cpp clang/test/ExtractAPI/global_func_template.cpp clang/test/ExtractAPI/global_func_template_spec.cpp clang/test/ExtractAPI/global_record.c clang/test/ExtractAPI/global_record_multifile.c clang/test/ExtractAPI/global_var_template.cpp clang/test/ExtractAPI/global_var_template_partial_spec.cpp clang/test/ExtractAPI/global_var_template_spec.cpp clang/test/ExtractAPI/known_files_only.c clang/test/ExtractAPI/language.c clang/test/ExtractAPI/macro_undefined.c clang/test/ExtractAPI/macros.c clang/test/ExtractAPI/method_template.cpp clang/test/ExtractAPI/method_template_spec.cpp clang/test/ExtractAPI/methods.cpp clang/test/ExtractAPI/multiple_inheritance.cpp clang/test/ExtractAPI/namespace.cpp clang/test/ExtractAPI/nested_namespaces.cpp clang/test/ExtractAPI/operator_overload.cpp clang/test/ExtractAPI/simple_inheritance.cpp clang/test/ExtractAPI/struct.c clang/test/ExtractAPI/typedef.c clang/test/ExtractAPI/typedef_anonymous_record.c clang/test/ExtractAPI/typedef_chain.c clang/test/ExtractAPI/typedef_struct_enum.c clang/test/ExtractAPI/underscored.c clang/test/ExtractAPI/union.c clang/tools/libclang/CXExtractAPI.cpp
View the diff from clang-format here.
diff --git a/clang/include/clang/ExtractAPI/API.h b/clang/include/clang/ExtractAPI/API.h
index b220db2941..a55c850406 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -1135,7 +1135,8 @@ struct has_function_signature<ObjCInstanceMethodRecord>
 template <>
 struct has_function_signature<ObjCClassMethodRecord> : public std::true_type {};
 template <>
-struct has_function_signature<CXXInstanceMethodRecord> : public std::true_type {};
+struct has_function_signature<CXXInstanceMethodRecord> : public std::true_type {
+};
 template <>
 struct has_function_signature<CXXStaticMethodRecord> : public std::true_type {};
 template <>
@@ -1146,7 +1147,8 @@ struct has_function_signature<CXXMethodTemplateSpecializationRecord>
     : public std::true_type {};
 
 template <typename RecordTy> struct has_access : public std::false_type {};
-template <> struct has_access<CXXInstanceMethodRecord> : public std::true_type {};
+template <>
+struct has_access<CXXInstanceMethodRecord> : public std::true_type {};
 template <> struct has_access<CXXStaticMethodRecord> : public std::true_type {};
 template <> struct has_access<CXXFieldRecord> : public std::true_type {};
 template <>
diff --git a/clang/include/clang/ExtractAPI/Serialization/SerializerBase.h b/clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
index f0629a9ad5..9fa520c321 100644
--- a/clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
+++ b/clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
@@ -227,69 +227,69 @@ public:
       getDerived()->visitTypedefRecord(*Typedef.second);
   }
 
-  void visitNamespaceRecord(const NamespaceRecord &Record){};
+  void visitNamespaceRecord(const NamespaceRecord &Record) {};
 
   /// Visit a global function record.
-  void visitGlobalFunctionRecord(const GlobalFunctionRecord &Record){};
+  void visitGlobalFunctionRecord(const GlobalFunctionRecord &Record) {};
 
   /// Visit a global variable record.
-  void visitGlobalVariableRecord(const GlobalVariableRecord &Record){};
+  void visitGlobalVariableRecord(const GlobalVariableRecord &Record) {};
 
   /// Visit an enum record.
-  void visitEnumRecord(const EnumRecord &Record){};
+  void visitEnumRecord(const EnumRecord &Record) {};
 
   /// Visit a record record.
-  void visitRecordRecord(const RecordRecord &Record){};
+  void visitRecordRecord(const RecordRecord &Record) {};
 
-  void visitStaticFieldRecord(const StaticFieldRecord &Record){};
+  void visitStaticFieldRecord(const StaticFieldRecord &Record) {};
 
-  void visitCXXClassRecord(const CXXClassRecord &Record){};
+  void visitCXXClassRecord(const CXXClassRecord &Record) {};
 
-  void visitClassTemplateRecord(const ClassTemplateRecord &Record){};
+  void visitClassTemplateRecord(const ClassTemplateRecord &Record) {};
 
   void visitClassTemplateSpecializationRecord(
-      const ClassTemplateSpecializationRecord &Record){};
+      const ClassTemplateSpecializationRecord &Record) {};
 
   void visitClassTemplatePartialSpecializationRecord(
-      const ClassTemplatePartialSpecializationRecord &Record){};
+      const ClassTemplatePartialSpecializationRecord &Record) {};
 
-  void visitCXXInstanceRecord(const CXXInstanceMethodRecord &Record){};
+  void visitCXXInstanceRecord(const CXXInstanceMethodRecord &Record) {};
 
-  void visitCXXStaticRecord(const CXXStaticMethodRecord &Record){};
+  void visitCXXStaticRecord(const CXXStaticMethodRecord &Record) {};
 
-  void visitMethodTemplateRecord(const CXXMethodTemplateRecord &Record){};
+  void visitMethodTemplateRecord(const CXXMethodTemplateRecord &Record) {};
 
   void visitMethodTemplateSpecializationRecord(
-      const CXXMethodTemplateSpecializationRecord &Record){};
+      const CXXMethodTemplateSpecializationRecord &Record) {};
 
-  void visitCXXFieldTemplateRecord(const CXXFieldTemplateRecord &Record){};
+  void visitCXXFieldTemplateRecord(const CXXFieldTemplateRecord &Record) {};
 
   void visitGlobalVariableTemplateRecord(
       const GlobalVariableTemplateRecord &Record) {}
 
   void visitGlobalVariableTemplateSpecializationRecord(
-      const GlobalVariableTemplateSpecializationRecord &Record){};
+      const GlobalVariableTemplateSpecializationRecord &Record) {};
 
   void visitGlobalVariableTemplatePartialSpecializationRecord(
-      const GlobalVariableTemplatePartialSpecializationRecord &Record){};
+      const GlobalVariableTemplatePartialSpecializationRecord &Record) {};
 
   void visitGlobalFunctionTemplateRecord(
-      const GlobalFunctionTemplateRecord &Record){};
+      const GlobalFunctionTemplateRecord &Record) {};
 
   void visitGlobalFunctionTemplateSpecializationRecord(
-      const GlobalFunctionTemplateSpecializationRecord &Record){};
+      const GlobalFunctionTemplateSpecializationRecord &Record) {};
 
   /// Visit an Objective-C container record.
-  void visitObjCContainerRecord(const ObjCContainerRecord &Record){};
+  void visitObjCContainerRecord(const ObjCContainerRecord &Record) {};
 
   /// Visit an Objective-C category record.
-  void visitObjCCategoryRecord(const ObjCCategoryRecord &Record){};
+  void visitObjCCategoryRecord(const ObjCCategoryRecord &Record) {};
 
   /// Visit a macro definition record.
-  void visitMacroDefinitionRecord(const MacroDefinitionRecord &Record){};
+  void visitMacroDefinitionRecord(const MacroDefinitionRecord &Record) {};
 
   /// Visit a typedef record.
-  void visitTypedefRecord(const TypedefRecord &Record){};
+  void visitTypedefRecord(const TypedefRecord &Record) {};
 
 protected:
   const APISet &API;

@vitalybuka vitalybuka marked this pull request as draft April 4, 2024 00:34
@vitalybuka
Copy link
Collaborator Author

Will try to fix forward

@vitalybuka
Copy link
Collaborator Author

abd05eb is enough

@vitalybuka vitalybuka closed this Apr 4, 2024
@daniel-grumberg
Copy link
Contributor

Thanks for forward fixing this for me!

@nunoplopes nunoplopes deleted the revert-87357-reenable-external-categories branch December 28, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants