TargetRegistry: Don't add "error" to error messages

Many of the users of this add their own "error:" to the start,
resulting in error: error.
This commit is contained in:
Matt Arsenault 2022-04-18 20:18:05 -04:00
parent 1900b6c77b
commit 752c9122a6
2 changed files with 13 additions and 2 deletions

View File

@ -33,7 +33,7 @@ const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
[&](const Target &T) { return ArchName == T.getName(); });
if (I == targets().end()) {
Error = "error: invalid target '" + ArchName + "'.\n";
Error = "invalid target '" + ArchName + "'.\n";
return nullptr;
}
@ -49,7 +49,7 @@ const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
std::string TempError;
TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), TempError);
if (!TheTarget) {
Error = ": error: unable to get target for '"
Error = "unable to get target for '"
+ TheTriple.getTriple()
+ "', see --version and --triple.\n";
return nullptr;

View File

@ -0,0 +1,11 @@
; RUN: not llc -march=arst -o /dev/null %s 2>&1 | FileCheck -check-prefix=MARCH %s
; RUN: not llc -mtriple=arst-- -o /dev/null %s 2>&1 | FileCheck -check-prefix=MTRIPLE %s
; Check the error message doesn't say error twice.
; MARCH: {{.*}}llc{{.*}}: error: invalid target 'arst'.{{$}}
; MTRIPLE: {{.*}}llc{{.*}}: error: unable to get target for 'arst-unknown-unknown', see --version and --triple.{{$}}
define void @func() {
ret void
}