Revert "[llvm] Move StringExtras.h include from Error.h to Error.cpp"
authorElliot Goodrich <elliotgoodrich@gmail.com>
Sun, 25 Jun 2023 15:09:36 +0000 (16:09 +0100)
committerElliot Goodrich <elliotgoodrich@gmail.com>
Sun, 25 Jun 2023 15:09:36 +0000 (16:09 +0100)
This reverts commit 2fa0dbd7bf353db98b27b56137cced0a67de2748.

llvm/include/llvm/Support/Error.h
llvm/lib/Support/Error.cpp

index 2292770..0f1b632 100644 (file)
@@ -14,6 +14,8 @@
 #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"
@@ -1023,7 +1025,13 @@ void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner = {});
 
 /// 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);
+inline std::string toString(Error E) {
+  SmallVector<std::string, 2> Errors;
+  handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) {
+    Errors.push_back(EI.message());
+  });
+  return join(Errors.begin(), Errors.end(), "\n");
+}
 
 /// Consume a Error without doing anything. This method should be used
 /// only where an error can be considered a reasonable and expected return
index 21d5915..b339b70 100644 (file)
@@ -7,8 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #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 <system_error>
@@ -72,15 +70,6 @@ void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) {
   });
 }
 
-/// 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<std::string, 2> 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<int>(ErrorErrorCode::MultipleErrors),