[clang] 57abd4e - [clang][ExtractAPI] Emit environment component of target triple in SGF (#103273)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 15 08:23:35 PDT 2024
Author: Daniel Grumberg
Date: 2024-08-15T16:23:31+01:00
New Revision: 57abd4e4abb705a453134051743542de5fd396bc
URL: https://github.com/llvm/llvm-project/commit/57abd4e4abb705a453134051743542de5fd396bc
DIFF: https://github.com/llvm/llvm-project/commit/57abd4e4abb705a453134051743542de5fd396bc.diff
LOG: [clang][ExtractAPI] Emit environment component of target triple in SGF (#103273)
rdar://133533830
Added:
clang/test/ExtractAPI/platform-serialization.c
Modified:
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
Removed:
################################################################################
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 84ed5467dd2fb9..1f8029cbd39ad2 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -104,6 +104,10 @@ Object serializePlatform(const Triple &T) {
Object Platform;
Platform["architecture"] = T.getArchName();
Platform["vendor"] = T.getVendorName();
+
+ if (!T.getEnvironmentName().empty())
+ Platform["environment"] = T.getEnvironmentName();
+
Platform["operatingSystem"] = serializeOperatingSystem(T);
return Platform;
}
diff --git a/clang/test/ExtractAPI/platform-serialization.c b/clang/test/ExtractAPI/platform-serialization.c
new file mode 100644
index 00000000000000..6d6a13f085cd9d
--- /dev/null
+++ b/clang/test/ExtractAPI/platform-serialization.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -extract-api --pretty-sgf -triple arm64-apple-ios17.1-macabi \
+// RUN: -x c-header %s -verify -o - | FileCheck %s
+
+int a;
+
+// CHECK: "platform": {
+// CHECK-NEXT: "architecture": "arm64",
+// CHECK-NEXT: "environment": "macabi",
+// CHECK-NEXT: "operatingSystem": {
+// CHECK-NEXT: "minimumVersion": {
+// CHECK-NEXT: "major": 14,
+// CHECK-NEXT: "minor": 0,
+// CHECK-NEXT: "patch": 0
+// CHECK-NEXT: },
+// CHECK-NEXT: "name": "ios"
+// CHECK-NEXT: },
+// CHECK-NEXT: "vendor": "apple"
+// CHECK-NEXT: }
+
+// expected-no-diagnostics
More information about the cfe-commits
mailing list