clang 22.0.0git
DiagnosticBuilderWrappers.cpp
Go to the documentation of this file.
1//===- DiagnosticBuilderWrappers.cpp ----------------------------*- C++-*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/ADT/STLExtras.h"
11#include "llvm/Support/raw_ostream.h"
12#include "llvm/TextAPI/Platform.h"
13
15
16namespace llvm {
17namespace MachO {
19 const Architecture &Arch) {
20 DB.AddString(getArchitectureName(Arch));
21 return DB;
22}
23
25 const ArchitectureSet &ArchSet) {
26 DB.AddString(std::string(ArchSet));
27 return DB;
28}
29
31 const PlatformType &Platform) {
32 DB.AddString(getPlatformName(Platform));
33 return DB;
34}
35
37 const PlatformVersionSet &Platforms) {
38 std::string PlatformAsString;
39 raw_string_ostream Stream(PlatformAsString);
40
41 Stream << "[ ";
42 llvm::interleaveComma(
43 Platforms, Stream,
44 [&Stream](const std::pair<PlatformType, VersionTuple> &PV) {
45 Stream << getPlatformName(PV.first);
46 if (!PV.second.empty())
47 Stream << PV.second.getAsString();
48 });
49 Stream << " ]";
50 DB.AddString(PlatformAsString);
51 return DB;
52}
53
55 const FileType &Type) {
56 switch (Type) {
57 case FileType::MachO_Bundle:
58 DB.AddString("mach-o bundle");
59 return DB;
60 case FileType::MachO_DynamicLibrary:
61 DB.AddString("mach-o dynamic library");
62 return DB;
63 case FileType::MachO_DynamicLibrary_Stub:
64 DB.AddString("mach-o dynamic library stub");
65 return DB;
66 case FileType::TBD_V1:
67 DB.AddString("tbd-v1");
68 return DB;
69 case FileType::TBD_V2:
70 DB.AddString("tbd-v2");
71 return DB;
72 case FileType::TBD_V3:
73 DB.AddString("tbd-v3");
74 return DB;
75 case FileType::TBD_V4:
76 DB.AddString("tbd-v4");
77 return DB;
78 case FileType::TBD_V5:
79 DB.AddString("tbd-v5");
80 return DB;
81 case FileType::Invalid:
82 case FileType::All:
83 break;
84 }
85 llvm_unreachable("Unexpected file type for diagnostics.");
86}
87
89 const PackedVersion &Version) {
90 std::string VersionString;
91 raw_string_ostream OS(VersionString);
92 OS << Version;
93 DB.AddString(VersionString);
94 return DB;
95}
96
100 std::string Entry;
101 raw_string_ostream OS(Entry);
102
103 OS << LibAttr.first << " [ " << LibAttr.second << " ]";
104 DB.AddString(Entry);
105 return DB;
106}
107
108} // namespace MachO
109} // namespace llvm
static const char * getPlatformName(Darwin::DarwinPlatformKind Platform, Darwin::DarwinEnvironmentKind Environment)
Definition Darwin.cpp:3531
llvm::MachO::ArchitectureSet ArchitectureSet
Definition MachO.h:28
llvm::MachO::PackedVersion PackedVersion
Definition MachO.h:47
llvm::MachO::Architecture Architecture
Definition MachO.h:27
llvm::MachO::FileType FileType
Definition MachO.h:46
llvm::MachO::PlatformType PlatformType
Definition MachO.h:49
A little helper class used to produce diagnostics.
void AddString(StringRef V) const
std::pair< std::string, ArchitectureSet > Entry
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Architecture &Arch)
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30