[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)
Zixu Wang via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 5 10:57:16 PDT 2024
================
@@ -0,0 +1,111 @@
+//===- DiagnosticBuilderWrappers.cpp ----------------------------*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DiagnosticBuilderWrappers.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/TextAPI/Platform.h"
+
+using clang::DiagnosticBuilder;
+
+namespace llvm {
+namespace MachO {
+const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ const Architecture &Arch) {
+ DB.AddString(getArchitectureName(Arch));
+ return DB;
+}
+
+const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ const ArchitectureSet &ArchSet) {
+ DB.AddString(std::string(ArchSet));
+ return DB;
+}
+
+const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ const PlatformType &Platform) {
+ DB.AddString(getPlatformName(Platform));
+ return DB;
+}
+
+const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ const PlatformVersionSet &Platforms) {
+ std::string PlatformAsString;
+ raw_string_ostream Stream(PlatformAsString);
+
+ Stream << "[ ";
+ bool NeedsComma = false;
+ for (auto &[Platform, Version] : Platforms) {
+ if (NeedsComma)
----------------
zixu-w wrote:
`STLExtras` has an `interleaveComma(const Container &c, StreamT &os, UnaryFunctor each_fn)` that could simplify some of the trouble here.
https://github.com/llvm/llvm-project/pull/87674
More information about the cfe-commits
mailing list