Skip to content

[ExtractAPI] reorder the module names in extension symbol graph file names #119925

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

Conversation

QuietMisdreavus
Copy link
Contributor

Resolves rdar://140298287

ExtractAPI's support for printing Objective-C category extensions from other modules emits symbol graphs with an [email protected]. However, this is backwards from existing symbol graph practices, causing issues when these symbol graphs are consumed alongside symbol graphs generated with other tools like Swift. This PR flips the naming scheme to be in line with existing symbol graph tooling.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Dec 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 13, 2024

@llvm/pr-subscribers-clang

Author: QuietMisdreavus (QuietMisdreavus)

Changes

Resolves rdar://140298287

ExtractAPI's support for printing Objective-C category extensions from other modules emits symbol graphs with an ExtendedModule@<!-- -->HostModule.symbols.json. However, this is backwards from existing symbol graph practices, causing issues when these symbol graphs are consumed alongside symbol graphs generated with other tools like Swift. This PR flips the naming scheme to be in line with existing symbol graph tooling.


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

2 Files Affected:

  • (modified) clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp (+2-2)
  • (modified) clang/test/ExtractAPI/objc_external_category.m (+8-1)
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index c730c062b6a1d5..2c70e77b6246c6 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -1067,9 +1067,9 @@ void SymbolGraphSerializer::serializeWithExtensionGraphs(
 
   for (auto &ExtensionSGF : Serializer.ExtendedModules) {
     if (auto ExtensionOS =
-            CreateOutputStream(ExtensionSGF.getKey() + "@" + API.ProductName))
+            CreateOutputStream(API.ProductName + "@" + ExtensionSGF.getKey()))
       Serializer.serializeGraphToStream(*ExtensionOS, Options,
-                                        ExtensionSGF.getKey(),
+                                        API.ProductName,
                                         std::move(ExtensionSGF.getValue()));
   }
 }
diff --git a/clang/test/ExtractAPI/objc_external_category.m b/clang/test/ExtractAPI/objc_external_category.m
index 8afc92489f28b6..1947237d088e8f 100644
--- a/clang/test/ExtractAPI/objc_external_category.m
+++ b/clang/test/ExtractAPI/objc_external_category.m
@@ -46,7 +46,7 @@ @interface ExtInterface
 // Symbol graph from the build without extension SGFs should be identical to main symbol graph with extension SGFs
 // RUN: diff %t/symbols/Module.symbols.json %t/ModuleNoExt.symbols.json
 
-// RUN: FileCheck %s --input-file %t/symbols/[email protected] --check-prefix EXT
+// RUN: FileCheck %s --input-file %t/symbols/[email protected] --check-prefix EXT
 // EXT-DAG: "!testRelLabel": "memberOf $ c:objc(cs)ExtInterface(py)Property $ c:objc(cs)ExtInterface"
 // EXT-DAG: "!testRelLabel": "memberOf $ c:objc(cs)ExtInterface(im)InstanceMethod $ c:objc(cs)ExtInterface"
 // EXT-DAG: "!testRelLabel": "memberOf $ c:objc(cs)ExtInterface(cm)ClassMethod $ c:objc(cs)ExtInterface"
@@ -55,3 +55,10 @@ @interface ExtInterface
 // EXT-DAG: "!testLabel": "c:objc(cs)ExtInterface(cm)ClassMethod"
 // EXT-NOT: "!testLabel": "c:objc(cs)ExtInterface"
 // EXT-NOT: "!testLabel": "c:objc(cs)ModInterface"
+
+// Ensure that the 'module' metadata for the extension symbol graph should still reference the
+// declaring module
+
+// RUN: FileCheck %s --input-file %t/symbols/[email protected] --check-prefix META
+// META:       "module": {
+// META-NEXT:    "name": "Module",

Copy link

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

You can test this locally with the following command:
git-clang-format --diff 91f5f974cb75309a94c9efc76238ef98abcf1582 506ac691d11e5658932f0f9388059f13407011cd --extensions cpp -- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
View the diff from clang-format here.
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 2c70e77b62..e881d56258 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -1068,8 +1068,7 @@ void SymbolGraphSerializer::serializeWithExtensionGraphs(
   for (auto &ExtensionSGF : Serializer.ExtendedModules) {
     if (auto ExtensionOS =
             CreateOutputStream(API.ProductName + "@" + ExtensionSGF.getKey()))
-      Serializer.serializeGraphToStream(*ExtensionOS, Options,
-                                        API.ProductName,
+      Serializer.serializeGraphToStream(*ExtensionOS, Options, API.ProductName,
                                         std::move(ExtensionSGF.getValue()));
   }
 }

@QuietMisdreavus QuietMisdreavus force-pushed the vgm/extractapi-extension-names branch from 506ac69 to 1ab5e1c Compare December 13, 2024 21:03
Copy link
Member

@zixu-w zixu-w left a comment

Choose a reason for hiding this comment

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

LGTM!

@QuietMisdreavus QuietMisdreavus merged commit 1be4a67 into llvm:main Dec 16, 2024
7 checks passed
@QuietMisdreavus QuietMisdreavus deleted the vgm/extractapi-extension-names branch December 16, 2024 20:37
QuietMisdreavus added a commit to swiftlang/llvm-project that referenced this pull request Dec 16, 2024
…names (llvm#119925)

Resolves rdar://140298287

ExtractAPI's support for printing Objective-C category extensions from
other modules emits symbol graphs with an
`[email protected]`. However, this is backwards
from existing symbol graph practices, causing issues when these symbol
graphs are consumed alongside symbol graphs generated with other tools
like Swift. This PR flips the naming scheme to be in line with existing
symbol graph tooling.
QuietMisdreavus added a commit to swiftlang/llvm-project that referenced this pull request Dec 16, 2024
…names (llvm#119925)

Resolves rdar://140298287

ExtractAPI's support for printing Objective-C category extensions from
other modules emits symbol graphs with an
`[email protected]`. However, this is backwards
from existing symbol graph practices, causing issues when these symbol
graphs are consumed alongside symbol graphs generated with other tools
like Swift. This PR flips the naming scheme to be in line with existing
symbol graph tooling.
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