diff --git a/lldb/unittests/Symbol/PostfixExpressionTest.cpp b/lldb/unittests/Symbol/PostfixExpressionTest.cpp --- a/lldb/unittests/Symbol/PostfixExpressionTest.cpp +++ b/lldb/unittests/Symbol/PostfixExpressionTest.cpp @@ -9,16 +9,17 @@ #include "lldb/Symbol/PostfixExpression.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/StreamString.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFExpression.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/raw_ostream.h" #include "gmock/gmock.h" #include "gtest/gtest.h" using namespace lldb_private; using namespace lldb_private::postfix; static std::string ToString(BinaryOpNode::OpType type) { switch (type) { case BinaryOpNode::Align: diff --git a/lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp b/lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp --- a/lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp +++ b/lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp @@ -7,24 +7,25 @@ //===----------------------------------------------------------------------===// #include "Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h" +#include "llvm/ADT/StringExtras.h" #include "gmock/gmock.h" #include "gtest/gtest.h" using namespace lldb_private::npdb; using namespace llvm; namespace { using Member = UdtRecordCompleter::Member; using MemberUP = std::unique_ptr; using Record = UdtRecordCompleter::Record; class WrappedMember { public: WrappedMember(const Member &obj) : m_obj(obj) {} private: const Member &m_obj; friend bool operator==(const WrappedMember &lhs, const WrappedMember &rhs) { return lhs.m_obj.kind == rhs.m_obj.kind && lhs.m_obj.name == rhs.m_obj.name && diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -14,8 +14,6 @@ #define LLVM_SUPPORT_ERROR_H #include "llvm-c/Error.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" #include "llvm/Config/abi-breaking.h" #include "llvm/Support/AlignOf.h" @@ -1025,14 +1023,8 @@ /// Write all error messages (if any) in E to a string. The newline character /// is used to separate error messages. -inline std::string toString(Error E) { - SmallVector Errors; - handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) { - Errors.push_back(EI.message()); - }); - return join(Errors.begin(), Errors.end(), "\n"); -} +std::string toString(Error E); /// Consume a Error without doing anything. This method should be used /// only where an error can be considered a reasonable and expected return /// value. diff --git a/llvm/lib/Support/Error.cpp b/llvm/lib/Support/Error.cpp --- a/llvm/lib/Support/Error.cpp +++ b/llvm/lib/Support/Error.cpp @@ -7,27 +7,29 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Error.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/ErrorHandling.h" #include using namespace llvm; namespace { enum class ErrorErrorCode : int { MultipleErrors = 1, FileError, InconvertibleError }; // FIXME: This class is only here to support the transition to llvm::Error. It // will be removed once this transition is complete. Clients should prefer to // deal with the Error value directly, rather than converting to error_code. class ErrorErrorCategory : public std::error_category { public: const char *name() const noexcept override { return "Error"; } std::string message(int condition) const override { switch (static_cast(condition)) { case ErrorErrorCode::MultipleErrors: @@ -70,17 +72,26 @@ }); } +/// Write all error messages (if any) in E to a string. The newline character +/// is used to separate error messages. +std::string toString(Error E) { + SmallVector Errors; + handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) { + Errors.push_back(EI.message()); + }); + return join(Errors.begin(), Errors.end(), "\n"); +} std::error_code ErrorList::convertToErrorCode() const { return std::error_code(static_cast(ErrorErrorCode::MultipleErrors), getErrorErrorCat()); } std::error_code inconvertibleErrorCode() { return std::error_code(static_cast(ErrorErrorCode::InconvertibleError), getErrorErrorCat()); } std::error_code FileError::convertToErrorCode() const { std::error_code NestedEC = Err->convertToErrorCode(); if (NestedEC == inconvertibleErrorCode())