clang 19.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/ADT/SmallString.h"
12#include "llvm/Support/raw_ostream.h"
13#include "llvm/TextAPI/Platform.h"
14
16
17namespace llvm {
18namespace MachO {
20 const Architecture &Arch) {
21 DB.AddString(getArchitectureName(Arch));
22 return DB;
23}
24
26 const ArchitectureSet &ArchSet) {
27 DB.AddString(std::string(ArchSet));
28 return DB;
29}
30
32 const PlatformType &Platform) {
33 DB.AddString(getPlatformName(Platform));
34 return DB;
35}
36
38 const PlatformVersionSet &Platforms) {
39 std::string PlatformAsString;
40 raw_string_ostream Stream(PlatformAsString);
41
42 Stream << "[ ";
43 llvm::interleaveComma(
44 Platforms, Stream,
45 [&Stream](const std::pair<PlatformType, VersionTuple> &PV) {
46 Stream << getPlatformName(PV.first);
47 if (!PV.second.empty())
48 Stream << PV.second.getAsString();
49 });
50 Stream << " ]";
51 DB.AddString(Stream.str());
52 return DB;
53}
54
56 const FileType &Type) {
57 switch (Type) {
58 case FileType::MachO_Bundle:
59 DB.AddString("mach-o bundle");
60 return DB;
61 case FileType::MachO_DynamicLibrary:
62 DB.AddString("mach-o dynamic library");
63 return DB;
64 case FileType::MachO_DynamicLibrary_Stub:
65 DB.AddString("mach-o dynamic library stub");
66 return DB;
67 case FileType::TBD_V1:
68 DB.AddString("tbd-v1");
69 return DB;
70 case FileType::TBD_V2:
71 DB.AddString("tbd-v2");
72 return DB;
73 case FileType::TBD_V3:
74 DB.AddString("tbd-v3");
75 return DB;
76 case FileType::TBD_V4:
77 DB.AddString("tbd-v4");
78 return DB;
79 case FileType::TBD_V5:
80 DB.AddString("tbd-v5");
81 return DB;
82 case FileType::Invalid:
83 case FileType::All:
84 break;
85 }
86 llvm_unreachable("Unexpected file type for diagnostics.");
87}
88
90 const PackedVersion &Version) {
91 std::string VersionString;
92 raw_string_ostream OS(VersionString);
93 OS << Version;
94 DB.AddString(OS.str());
95 return DB;
96}
97
100 const StringMapEntry<ArchitectureSet> &LibAttr) {
101 std::string IFAsString;
102 raw_string_ostream OS(IFAsString);
103
104 OS << LibAttr.getKey() << " [ " << LibAttr.getValue() << " ]";
105 DB.AddString(OS.str());
106 return DB;
107}
108
109} // namespace MachO
110} // namespace llvm
MatchType Type
static const char * getPlatformName(Darwin::DarwinPlatformKind Platform, Darwin::DarwinEnvironmentKind Environment)
Definition: Darwin.cpp:3174
llvm::MachO::ArchitectureSet ArchitectureSet
Definition: MachO.h:28
llvm::MachO::PackedVersion PackedVersion
Definition: MachO.h:46
llvm::MachO::Architecture Architecture
Definition: MachO.h:27
llvm::MachO::FileType FileType
Definition: MachO.h:45
llvm::MachO::PlatformType PlatformType
Definition: MachO.h:48
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1271
void AddString(StringRef V) const
Definition: Diagnostic.h:1199
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Architecture &Arch)
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30