From 139cbe87ac551b6c334817cf6845b779b367924d 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. --- include/llvm/Object/Error.h | 8 +++++--- lib/Object/Error.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/llvm/Object/Error.h b/include/llvm/Object/Error.h index b7bbf06fc86..1e109fa131c 100644 --- a/include/llvm/Object/Error.h +++ b/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/lib/Object/Error.cpp b/lib/Object/Error.cpp index 010c5b42dac..bc75bc6c044 100644 --- a/lib/Object/Error.cpp +++ b/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)); }