[clang] [clang][ExtractAPI] Emit environment component of target triple in SGF (PR #103273)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 13 08:13:15 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Daniel Grumberg (daniel-grumberg)
<details>
<summary>Changes</summary>
rdar://133533830
---
Full diff: https://github.com/llvm/llvm-project/pull/103273.diff
2 Files Affected:
- (modified) clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp (+4)
- (added) clang/test/ExtractAPI/platform-serialization.c (+20)
``````````diff
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 6e56ee5b573f66..647c8659639f35 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
``````````
</details>
https://github.com/llvm/llvm-project/pull/103273
More information about the cfe-commits
mailing list