IncludeGuardian created this revision. IncludeGuardian added a reviewer: MaskRay. Herald added a subscriber: hiraditya. Herald added a project: All. IncludeGuardian requested review of this revision. Herald added projects: LLDB, LLVM. Herald added subscribers: llvm-commits, lldb-commits.
**1st commit** [lldb] Add missing StringExtras.h includes In preparation for removing the `#include "llvm/ADT/StringExtras.h"` from the header to source file of `llvm/Support/Error.h`, first add in all the missing includes that were previously included transitively through this header. This is fixing all files missed in b0abd4893fa1 <https://reviews.llvm.org/rGb0abd4893fa1bfae7f71b6b6e98770c9b1c07620>, 39d8e6e22cd1 <https://reviews.llvm.org/rG39d8e6e22cd192db6ace37a4c842265058dcddb8>, a11efd49266f <https://reviews.llvm.org/rGa11efd49266f6cf2a98bdf52428b0c9423158846>, and 5551657b310b <https://reviews.llvm.org/rG5551657b310b0f5f97b26288f87bc41a8050bf93>. --- **2nd commit** [Support] Move StringExtras.h include from Error.h to Error.cpp Move the implementation of the `toString` function from `llvm/Support/Error.h` to the source file, which allows us to move `#include "llvm/ADT/StringExtras.h"` to the source file as well. As `Error.h` is present in a large number of translation units this means we are unnecessarily bringing in the contents of `StringExtras.h` - itself a large file with lots of includes - and slowing down compilation. Also move the `#include "llvm/ADT/SmallVector.h"` directive to the source file as it's no longer needed, but this does not give as much of a benefit. This reduces the total number of preprocessing tokens across the LLVM source files in lib from (roughly) 1,920,413,050 to 1,903,629,230 - a reduction of ~0.87%. This should result in a small improvement in compilation time. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D155018 Files: lldb/tools/lldb-vscode/VSCode.cpp llvm/include/llvm/Support/Error.h llvm/lib/Support/Error.cpp
Index: llvm/lib/Support/Error.cpp =================================================================== --- llvm/lib/Support/Error.cpp +++ 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 <system_error> 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<ErrorErrorCode>(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<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), getErrorErrorCat()); } std::error_code inconvertibleErrorCode() { return std::error_code(static_cast<int>(ErrorErrorCode::InconvertibleError), getErrorErrorCat()); } std::error_code FileError::convertToErrorCode() const { std::error_code NestedEC = Err->convertToErrorCode(); if (NestedEC == inconvertibleErrorCode()) Index: llvm/include/llvm/Support/Error.h =================================================================== --- llvm/include/llvm/Support/Error.h +++ 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<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::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. Index: lldb/tools/lldb-vscode/VSCode.cpp =================================================================== --- lldb/tools/lldb-vscode/VSCode.cpp +++ lldb/tools/lldb-vscode/VSCode.cpp @@ -14,21 +14,22 @@ #include "LLDBUtils.h" #include "VSCode.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Support/FormatVariadic.h" #if defined(_WIN32) #define NOMINMAX #include <fcntl.h> #include <io.h> #include <windows.h> #endif using namespace lldb_vscode; namespace lldb_vscode { VSCode g_vsc; VSCode::VSCode() : broadcaster("lldb-vscode"), exception_breakpoints(
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits