mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
[llvm-mc] Make error handling more consistent.
Makes error handling more consistent by using the helpers in support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330536 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
# RUN: not llvm-mc -filetype=obj -triple=i386-unknown-elf -defsym a=a %s 2>&1 | FileCheck %s
|
||||
# CHECK: error: Value is not an integer: a
|
||||
# CHECK: error: value is not an integer: a
|
||||
|
||||
+14
-11
@@ -37,6 +37,7 @@
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Support/ToolOutputFile.h"
|
||||
#include "llvm/Support/WithColor.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@@ -186,7 +187,7 @@ static const Target *GetTarget(const char *ProgName) {
|
||||
const Target *TheTarget = TargetRegistry::lookupTarget(ArchName, TheTriple,
|
||||
Error);
|
||||
if (!TheTarget) {
|
||||
errs() << ProgName << ": " << Error;
|
||||
WithColor::error(errs(), ProgName) << Error;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -203,7 +204,7 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream() {
|
||||
auto Out =
|
||||
llvm::make_unique<ToolOutputFile>(OutputFilename, EC, sys::fs::F_None);
|
||||
if (EC) {
|
||||
errs() << EC.message() << '\n';
|
||||
WithColor::error() << EC.message() << '\n';
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -252,12 +253,13 @@ static int fillCommandLineSymbols(MCAsmParser &Parser) {
|
||||
auto Val = Pair.second;
|
||||
|
||||
if (Sym.empty() || Val.empty()) {
|
||||
errs() << "error: defsym must be of the form: sym=value: " << I << "\n";
|
||||
WithColor::error() << "defsym must be of the form: sym=value: " << I
|
||||
<< "\n";
|
||||
return 1;
|
||||
}
|
||||
int64_t Value;
|
||||
if (Val.getAsInteger(0, Value)) {
|
||||
errs() << "error: Value is not an integer: " << Val << "\n";
|
||||
WithColor::error() << "value is not an integer: " << Val << "\n";
|
||||
return 1;
|
||||
}
|
||||
Parser.getContext().setSymbolValue(Parser.getStreamer(), Sym, Value);
|
||||
@@ -275,8 +277,8 @@ static int AssembleInput(const char *ProgName, const Target *TheTarget,
|
||||
TheTarget->createMCAsmParser(STI, *Parser, MCII, MCOptions));
|
||||
|
||||
if (!TAP) {
|
||||
errs() << ProgName
|
||||
<< ": error: this target does not support assembly parsing.\n";
|
||||
WithColor::error(errs(), ProgName)
|
||||
<< "this target does not support assembly parsing.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -321,7 +323,8 @@ int main(int argc, char **argv) {
|
||||
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
|
||||
MemoryBuffer::getFileOrSTDIN(InputFilename);
|
||||
if (std::error_code EC = BufferPtr.getError()) {
|
||||
errs() << InputFilename << ": " << EC.message() << '\n';
|
||||
WithColor::error(errs(), ProgName)
|
||||
<< InputFilename << ": " << EC.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
MemoryBuffer *Buffer = BufferPtr->get();
|
||||
@@ -345,8 +348,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
if (CompressDebugSections != DebugCompressionType::None) {
|
||||
if (!zlib::isAvailable()) {
|
||||
errs() << ProgName
|
||||
<< ": build tools with zlib to enable -compress-debug-sections";
|
||||
WithColor::error(errs(), ProgName)
|
||||
<< "build tools with zlib to enable -compress-debug-sections";
|
||||
return 1;
|
||||
}
|
||||
MAI->setCompressDebugSections(CompressDebugSections);
|
||||
@@ -425,8 +428,8 @@ int main(int argc, char **argv) {
|
||||
*MAI, *MCII, *MRI);
|
||||
|
||||
if (!IP) {
|
||||
errs()
|
||||
<< "error: unable to create instruction printer for target triple '"
|
||||
WithColor::error()
|
||||
<< "unable to create instruction printer for target triple '"
|
||||
<< TheTriple.normalize() << "' with assembly variant "
|
||||
<< OutputAsmVariant << ".\n";
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user