1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

Error.h - GenericBinaryError - pass Twine arg by reference not value.

This allows us to reduce the Twine.h include to a forward declaration.
This commit is contained in:
Simon Pilgrim 2020-06-27 10:12:20 +01:00
parent 25f590cc77
commit 139cbe87ac
2 changed files with 9 additions and 5 deletions

View File

@ -13,11 +13,13 @@
#ifndef LLVM_OBJECT_ERROR_H #ifndef LLVM_OBJECT_ERROR_H
#define LLVM_OBJECT_ERROR_H #define LLVM_OBJECT_ERROR_H
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
#include <system_error> #include <system_error>
namespace llvm { namespace llvm {
class Twine;
namespace object { namespace object {
class Binary; class Binary;
@ -65,8 +67,8 @@ public:
class GenericBinaryError : public ErrorInfo<GenericBinaryError, BinaryError> { class GenericBinaryError : public ErrorInfo<GenericBinaryError, BinaryError> {
public: public:
static char ID; static char ID;
GenericBinaryError(Twine Msg); GenericBinaryError(const Twine &Msg);
GenericBinaryError(Twine Msg, object_error ECOverride); GenericBinaryError(const Twine &Msg, object_error ECOverride);
const std::string &getMessage() const { return Msg; } const std::string &getMessage() const { return Msg; }
void log(raw_ostream &OS) const override; void log(raw_ostream &OS) const override;
private: private:

View File

@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Object/Error.h" #include "llvm/Object/Error.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ManagedStatic.h"
@ -60,9 +61,10 @@ void BinaryError::anchor() {}
char BinaryError::ID = 0; char BinaryError::ID = 0;
char GenericBinaryError::ID = 0; char GenericBinaryError::ID = 0;
GenericBinaryError::GenericBinaryError(Twine Msg) : Msg(Msg.str()) {} GenericBinaryError::GenericBinaryError(const Twine &Msg) : Msg(Msg.str()) {}
GenericBinaryError::GenericBinaryError(Twine Msg, object_error ECOverride) GenericBinaryError::GenericBinaryError(const Twine &Msg,
object_error ECOverride)
: Msg(Msg.str()) { : Msg(Msg.str()) {
setErrorCode(make_error_code(ECOverride)); setErrorCode(make_error_code(ECOverride));
} }