Skip to content

Commit c790d6f

Browse files
committed
[ELF] isCompatile: avoid a toStr and 2 ErrAlways
1 parent 360718f commit c790d6f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static bool isCompatible(Ctx &ctx, InputFile *file) {
284284
StringRef target =
285285
!ctx.arg.bfdname.empty() ? ctx.arg.bfdname : ctx.arg.emulation;
286286
if (!target.empty()) {
287-
ErrAlways(ctx) << file << " is incompatible with " << target;
287+
Err(ctx) << file << " is incompatible with " << target;
288288
return false;
289289
}
290290

@@ -295,10 +295,10 @@ static bool isCompatible(Ctx &ctx, InputFile *file) {
295295
existing = ctx.sharedFiles[0];
296296
else if (!ctx.bitcodeFiles.empty())
297297
existing = ctx.bitcodeFiles[0];
298-
std::string with;
298+
auto diag = Err(ctx);
299+
diag << file << " is incompatible";
299300
if (existing)
300-
with = " with " + toStr(ctx, existing);
301-
ErrAlways(ctx) << file << " is incompatible" << with;
301+
diag << " with " << existing;
302302
return false;
303303
}
304304

lld/test/ELF/incompatible.s

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
// RUN: not ld.lld %ta.o %tb.o -o /dev/null 2>&1 | \
88
// RUN: FileCheck --check-prefix=A-AND-B %s
9-
// A-AND-B: b.o is incompatible with {{.*}}a.o
9+
// A-AND-B: error: {{.*}}b.o is incompatible with {{.*}}a.o
1010

11-
// RUN: not ld.lld %tb.o %tc.o -o /dev/null 2>&1 | \
11+
// RUN: ld.lld --noinhibit-exec %tb.o %tc.o -o /dev/null 2>&1 | \
1212
// RUN: FileCheck --check-prefix=B-AND-C %s
13-
// B-AND-C: c.o is incompatible with {{.*}}b.o
13+
// B-AND-C: warning: {{.*}}c.o is incompatible with {{.*}}b.o
1414

1515
// RUN: not ld.lld %ta.o %ti686.so -o /dev/null 2>&1 | \
1616
// RUN: FileCheck --check-prefix=A-AND-SO %s
@@ -69,8 +69,8 @@
6969
// RUN: rm -f %t.a
7070
// RUN: llvm-ar rc %t.a %tc.o
7171
// RUN: llvm-mc -filetype=obj -triple=i686-linux %s -o %td.o
72-
// RUN: not ld.lld %t.a %td.o 2>&1 -o /dev/null | FileCheck --check-prefix=ARCHIVE %s
73-
// ARCHIVE: {{.*}}d.o is incompatible
72+
// RUN: ld.lld --noinhibit-exec %t.a %td.o 2>&1 -o /dev/null | FileCheck --check-prefix=ARCHIVE %s
73+
// ARCHIVE: warning: {{.*}}d.o is incompatible{{$}}
7474
.global _start
7575
_start:
7676
.data

0 commit comments

Comments
 (0)