From df813dc09e1bf5260d8f5cce3643ec90c68cd426 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 27 Jun 2020 10:12:20 +0100 Subject: [PATCH] Error.h - GenericBinaryError - pass Twine arg by reference not value. This allows us to reduce the Twine.h include to a forward declaration. --- llvm/include/llvm/Object/Error.h | 8 +++++--- llvm/lib/Object/Error.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/Object/Error.h b/llvm/include/llvm/Object/Error.h index b7bbf06..1e109fa 100644 --- a/llvm/include/llvm/Object/Error.h +++ b/llvm/include/llvm/Object/Error.h @@ -13,11 +13,13 @@ #ifndef LLVM_OBJECT_ERROR_H #define LLVM_OBJECT_ERROR_H -#include "llvm/ADT/Twine.h" #include "llvm/Support/Error.h" #include namespace llvm { + +class Twine; + namespace object { class Binary; @@ -65,8 +67,8 @@ public: class GenericBinaryError : public ErrorInfo { public: static char ID; - GenericBinaryError(Twine Msg); - GenericBinaryError(Twine Msg, object_error ECOverride); + GenericBinaryError(const Twine &Msg); + GenericBinaryError(const Twine &Msg, object_error ECOverride); const std::string &getMessage() const { return Msg; } void log(raw_ostream &OS) const override; private: diff --git a/llvm/lib/Object/Error.cpp b/llvm/lib/Object/Error.cpp index 010c5b4..bc75bc6 100644 --- a/llvm/lib/Object/Error.cpp +++ b/llvm/lib/Object/Error.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Object/Error.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" @@ -60,9 +61,10 @@ void BinaryError::anchor() {} char BinaryError::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()) { setErrorCode(make_error_code(ECOverride)); } -- 2.7.4