Skip to content

Commit

Permalink
Revert "[Support] Move StringExtras.h include from Error.h to Error.cpp"
Browse files Browse the repository at this point in the history
This reverts commit 2e2743b.

More transitive includes of `llvm/ADT/StringExtras.h` need to be
removed.
  • Loading branch information
elliotgoodrich committed Jul 8, 2023
1 parent 2e2743b commit d2fb8f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 9 additions & 1 deletion llvm/include/llvm/Support/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions llvm/lib/Support/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit d2fb8f2

Please sign in to comment.