From aff3e68d6f10dd3087c29a09865683b9d35a362e Mon Sep 17 00:00:00 2001 From: Shao-Ce SUN Date: Mon, 16 Dec 2024 17:45:58 +0800 Subject: [PATCH] [LLVM][tools] Remove unnecessary newline from error message (#120037) The previous missing a newline: ```shell $ llc --mattr=help llc: error: unable to get target for 'unknown', see --version and --triple.$ ``` --- llvm/lib/MC/TargetRegistry.cpp | 2 +- llvm/test/tools/llc/invalid-target.ll | 7 +++++-- llvm/tools/llc/llc.cpp | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/llvm/lib/MC/TargetRegistry.cpp b/llvm/lib/MC/TargetRegistry.cpp index 3be6f1d46349..e1879f97aa56 100644 --- a/llvm/lib/MC/TargetRegistry.cpp +++ b/llvm/lib/MC/TargetRegistry.cpp @@ -126,7 +126,7 @@ const Target *TargetRegistry::lookupTarget(StringRef ArchName, [&](const Target &T) { return ArchName == T.getName(); }); if (I == targets().end()) { - Error = ("invalid target '" + ArchName + "'.\n").str(); + Error = ("invalid target '" + ArchName + "'.").str(); return nullptr; } diff --git a/llvm/test/tools/llc/invalid-target.ll b/llvm/test/tools/llc/invalid-target.ll index 6eed627b0115..7cbb171c7225 100644 --- a/llvm/test/tools/llc/invalid-target.ll +++ b/llvm/test/tools/llc/invalid-target.ll @@ -3,8 +3,11 @@ ; 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.{{$}} +; MARCH: {{.*}}llc{{.*}}: error: invalid target 'arst'. +; MARCH-EMPTY: +; +; MTRIPLE: {{.*}}llc{{.*}}: error: unable to get target for 'arst-unknown-unknown', see --version and --triple. +; MTRIPLE-EMPTY: define void @func() { ret void diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index 150dd50ef293..3694ff79b543 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -549,7 +549,7 @@ static int compileModule(char **argv, LLVMContext &Context) { TheTarget = TargetRegistry::lookupTarget(codegen::getMArch(), TheTriple, Error); if (!TheTarget) { - WithColor::error(errs(), argv[0]) << Error; + WithColor::error(errs(), argv[0]) << Error << "\n"; exit(1); } @@ -592,7 +592,7 @@ static int compileModule(char **argv, LLVMContext &Context) { TheTarget = TargetRegistry::lookupTarget(codegen::getMArch(), TheTriple, Error); if (!TheTarget) { - WithColor::error(errs(), argv[0]) << Error; + WithColor::error(errs(), argv[0]) << Error << "\n"; return 1; }