Move the error handling functions to Error.h. NFC.

llvm-svn: 244216
This commit is contained in:
Rafael Espindola 2015-08-06 15:08:23 +00:00
parent b835ae8e4a
commit 192e1fa59d
10 changed files with 74 additions and 29 deletions

View File

@ -6,6 +6,7 @@ add_llvm_library(lldELF2
Chunks.cpp
Driver.cpp
DriverUtils.cpp
Error.cpp
InputFiles.cpp
SymbolTable.cpp
Symbols.cpp

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "Chunks.h"
#include "Driver.h"
#include "Error.h"
using namespace llvm;
using namespace llvm::ELF;

View File

@ -7,8 +7,9 @@
//
//===----------------------------------------------------------------------===//
#include "Config.h"
#include "Driver.h"
#include "Config.h"
#include "Error.h"
#include "InputFiles.h"
#include "SymbolTable.h"
#include "Writer.h"
@ -32,22 +33,6 @@ void link(ArrayRef<const char *> Args) {
Driver->link(Args.slice(1));
}
void error(Twine Msg) {
errs() << Msg << "\n";
exit(1);
}
void error(std::error_code EC, Twine Prefix) {
if (!EC)
return;
error(Prefix + ": " + EC.message());
}
void error(std::error_code EC) {
if (!EC)
return;
error(EC.message());
}
}
}

View File

@ -24,14 +24,6 @@ class InputFile;
// Entry point of the ELF linker.
void link(ArrayRef<const char *> Args);
LLVM_ATTRIBUTE_NORETURN void error(Twine Msg);
void error(std::error_code EC, Twine Prefix);
void error(std::error_code EC);
template <typename T> void error(const ErrorOr<T> &V, Twine Prefix) {
error(V.getError(), Prefix);
}
template <typename T> void error(const ErrorOr<T> &V) { error(V.getError()); }
class ArgParser {
public:
// Parses command line options.

View File

@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "Driver.h"
#include "Error.h"
#include "llvm/ADT/STLExtras.h"
using namespace llvm;

36
lld/ELF/Error.cpp Normal file
View File

@ -0,0 +1,36 @@
//===- Error.cpp ----------------------------------------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "Error.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"
namespace lld {
namespace elf2 {
void error(const Twine &Msg) {
llvm::errs() << Msg << "\n";
exit(1);
}
void error(std::error_code EC, const Twine &Prefix) {
if (!EC)
return;
error(Prefix + ": " + EC.message());
}
void error(std::error_code EC) {
if (!EC)
return;
error(EC.message());
}
} // namespace elf2
} // namespace lld

30
lld/ELF/Error.h Normal file
View File

@ -0,0 +1,30 @@
//===- Error.h ------------------------------------------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_COFF_ERROR_H
#define LLD_COFF_ERROR_H
#include "lld/Core/LLVM.h"
namespace lld {
namespace elf2 {
LLVM_ATTRIBUTE_NORETURN void error(const Twine &Msg);
void error(std::error_code EC, const Twine &Prefix);
void error(std::error_code EC);
template <typename T> void error(const ErrorOr<T> &V, const Twine &Prefix) {
error(V.getError(), Prefix);
}
template <typename T> void error(const ErrorOr<T> &V) { error(V.getError()); }
} // namespace elf2
} // namespace lld
#endif

View File

@ -9,8 +9,8 @@
#include "InputFiles.h"
#include "Chunks.h"
#include "Error.h"
#include "Symbols.h"
#include "Driver.h"
#include "llvm/ADT/STLExtras.h"
using namespace llvm::ELF;

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "SymbolTable.h"
#include "Driver.h"
#include "Error.h"
#include "Symbols.h"
using namespace llvm;

View File

@ -9,7 +9,7 @@
#include "Chunks.h"
#include "Config.h"
#include "Driver.h"
#include "Error.h"
#include "SymbolTable.h"
#include "Writer.h"
#include "llvm/ADT/DenseMap.h"