Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
35233 views
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
9
#include "DiagnosticBuilderWrappers.h"
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
15
using clang::DiagnosticBuilder;
16
17
namespace llvm {
18
namespace MachO {
19
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
20
const Architecture &Arch) {
21
DB.AddString(getArchitectureName(Arch));
22
return DB;
23
}
24
25
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
26
const ArchitectureSet &ArchSet) {
27
DB.AddString(std::string(ArchSet));
28
return DB;
29
}
30
31
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
32
const PlatformType &Platform) {
33
DB.AddString(getPlatformName(Platform));
34
return DB;
35
}
36
37
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
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(PlatformAsString);
52
return DB;
53
}
54
55
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
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
89
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
90
const PackedVersion &Version) {
91
std::string VersionString;
92
raw_string_ostream OS(VersionString);
93
OS << Version;
94
DB.AddString(VersionString);
95
return DB;
96
}
97
98
const clang::DiagnosticBuilder &
99
operator<<(const clang::DiagnosticBuilder &DB,
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(IFAsString);
106
return DB;
107
}
108
109
} // namespace MachO
110
} // namespace llvm
111
112