Skip to content

Commit e0df221

Browse files
committed
[clang][Driver] Rename "FatalError" key to "Error" in multilib.yaml (#110804)
This is a late-breaking change to #105684, suggested after the original patch was already landed.
1 parent 5cfc6bc commit e0df221

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

clang/docs/Multilib.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ For a more comprehensive example see
202202
203203
# If there is no multilib available for a particular set of flags, and the
204204
# other multilibs are not adequate fallbacks, then you can define a variant
205-
# record with a FatalError key in place of the Dir key.
206-
- FatalError: this multilib collection has no hard-float ABI support
205+
# record with an Error key in place of the Dir key.
206+
- Error: this multilib collection has no hard-float ABI support
207207
Flags: [--target=thumbv7m-none-eabi, -mfloat-abi=hard]
208208
209209

clang/include/clang/Driver/Multilib.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Multilib {
5454
// Some Multilib objects don't actually represent library directories you can
5555
// select. Instead, they represent failures of multilib selection, of the
5656
// form 'Sorry, we don't have any library compatible with these constraints'.
57-
std::optional<std::string> FatalError;
57+
std::optional<std::string> Error;
5858

5959
public:
6060
/// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the
@@ -63,7 +63,7 @@ class Multilib {
6363
Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
6464
StringRef IncludeSuffix = {}, const flags_list &Flags = flags_list(),
6565
StringRef ExclusiveGroup = {},
66-
std::optional<StringRef> FatalError = std::nullopt);
66+
std::optional<StringRef> Error = std::nullopt);
6767

6868
/// Get the detected GCC installation path suffix for the multi-arch
6969
/// target variant. Always starts with a '/', unless empty
@@ -94,9 +94,9 @@ class Multilib {
9494

9595
bool operator==(const Multilib &Other) const;
9696

97-
bool isFatalError() const { return FatalError.has_value(); }
97+
bool isError() const { return Error.has_value(); }
9898

99-
const std::string &getFatalError() const { return FatalError.value(); }
99+
const std::string &getErrorMessage() const { return Error.value(); }
100100
};
101101

102102
raw_ostream &operator<<(raw_ostream &OS, const Multilib &M);

clang/lib/Driver/Driver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
23222322

23232323
if (C.getArgs().hasArg(options::OPT_print_multi_lib)) {
23242324
for (const Multilib &Multilib : TC.getMultilibs())
2325-
if (!Multilib.isFatalError())
2325+
if (!Multilib.isError())
23262326
llvm::outs() << Multilib << "\n";
23272327
return false;
23282328
}

clang/lib/Driver/Multilib.cpp

+15-16
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ using namespace llvm::sys;
3232

3333
Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
3434
StringRef IncludeSuffix, const flags_list &Flags,
35-
StringRef ExclusiveGroup,
36-
std::optional<StringRef> FatalError)
35+
StringRef ExclusiveGroup, std::optional<StringRef> Error)
3736
: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
38-
Flags(Flags), ExclusiveGroup(ExclusiveGroup), FatalError(FatalError) {
37+
Flags(Flags), ExclusiveGroup(ExclusiveGroup), Error(Error) {
3938
assert(GCCSuffix.empty() ||
4039
(StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1));
4140
assert(OSSuffix.empty() ||
@@ -123,11 +122,11 @@ bool MultilibSet::select(const Driver &D, const Multilib::flags_list &Flags,
123122
continue;
124123
}
125124

126-
// If this multilib is actually a placeholder containing a fatal
127-
// error message written by the multilib.yaml author, display that
128-
// error message, and return failure.
129-
if (M.isFatalError()) {
130-
D.Diag(clang::diag::err_drv_multilib_custom_error) << M.getFatalError();
125+
// If this multilib is actually a placeholder containing an error message
126+
// written by the multilib.yaml author, display that error message, and
127+
// return failure.
128+
if (M.isError()) {
129+
D.Diag(clang::diag::err_drv_multilib_custom_error) << M.getErrorMessage();
131130
return false;
132131
}
133132

@@ -173,7 +172,7 @@ static const VersionTuple MultilibVersionCurrent(1, 0);
173172

174173
struct MultilibSerialization {
175174
std::string Dir; // if this record successfully selects a library dir
176-
std::string FatalError; // if this record reports a fatal error message
175+
std::string Error; // if this record reports a fatal error message
177176
std::vector<std::string> Flags;
178177
std::string Group;
179178
};
@@ -217,15 +216,15 @@ struct MultilibSetSerialization {
217216
template <> struct llvm::yaml::MappingTraits<MultilibSerialization> {
218217
static void mapping(llvm::yaml::IO &io, MultilibSerialization &V) {
219218
io.mapOptional("Dir", V.Dir);
220-
io.mapOptional("FatalError", V.FatalError);
219+
io.mapOptional("Error", V.Error);
221220
io.mapRequired("Flags", V.Flags);
222221
io.mapOptional("Group", V.Group);
223222
}
224223
static std::string validate(IO &io, MultilibSerialization &V) {
225-
if (V.Dir.empty() && V.FatalError.empty())
226-
return "one of the 'Dir' and 'FatalError' keys must be specified";
227-
if (!V.Dir.empty() && !V.FatalError.empty())
228-
return "the 'Dir' and 'FatalError' keys may not both be specified";
224+
if (V.Dir.empty() && V.Error.empty())
225+
return "one of the 'Dir' and 'Error' keys must be specified";
226+
if (!V.Dir.empty() && !V.Error.empty())
227+
return "the 'Dir' and 'Error' keys may not both be specified";
229228
if (StringRef(V.Dir).starts_with("/"))
230229
return "paths must be relative but \"" + V.Dir + "\" starts with \"/\"";
231230
return std::string{};
@@ -311,8 +310,8 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input,
311310
multilib_list Multilibs;
312311
Multilibs.reserve(MS.Multilibs.size());
313312
for (const auto &M : MS.Multilibs) {
314-
if (!M.FatalError.empty()) {
315-
Multilibs.emplace_back("", "", "", M.Flags, M.Group, M.FatalError);
313+
if (!M.Error.empty()) {
314+
Multilibs.emplace_back("", "", "", M.Flags, M.Group, M.Error);
316315
} else {
317316
std::string Dir;
318317
if (M.Dir != ".")

clang/lib/Driver/ToolChains/BareMetal.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D,
201201
D.Diag(clang::diag::warn_drv_missing_multilib) << llvm::join(Flags, " ");
202202
std::stringstream ss;
203203
for (const Multilib &Multilib : Result.Multilibs)
204-
if (!Multilib.isFatalError())
204+
if (!Multilib.isError())
205205
ss << "\n" << llvm::join(Multilib.flags(), " ");
206206
D.Diag(clang::diag::note_drv_available_multilibs) << ss.str();
207207
}

clang/test/Driver/baremetal-multilib-custom-error.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Variants:
3737
Flags:
3838
- --target=thumbv8.1m.main-unknown-none-eabi
3939

40-
- FatalError: mve-softfloat is not supported
40+
- Error: mve-softfloat is not supported
4141
Flags:
4242
- --target=thumbv8.1m.main-unknown-none-eabi
4343
- -march=thumbv8.1m.main+mve

clang/unittests/Driver/MultilibTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Variants: []
282282
)"));
283283
EXPECT_TRUE(
284284
StringRef(Diagnostic)
285-
.contains("one of the 'Dir' and 'FatalError' keys must be specified"))
285+
.contains("one of the 'Dir' and 'Error' keys must be specified"))
286286
<< Diagnostic;
287287

288288
EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(

0 commit comments

Comments
 (0)