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, OpenMP, LLVM.
Herald added subscribers: llvm-commits, openmp-commits, lldb-commits.

Add missing transitive includes missed from https://reviews.llvm.org/D154543.

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/D154763

Files:
  lldb/source/Host/common/File.cpp
  lldb/source/Host/common/Socket.cpp
  lldb/source/Host/common/XML.cpp
  llvm/include/llvm/Support/Error.h
  llvm/lib/Support/Error.cpp
  llvm/lib/WindowsDriver/MSVCPaths.cpp
  openmp/libomptarget/src/omptarget.cpp

Index: openmp/libomptarget/src/omptarget.cpp
===================================================================
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -17,13 +17,14 @@
 #include "rtl.h"

 #include "llvm/ADT/bit.h"
+#include "llvm/ADT/StringExtras.h"

 #include <cassert>
 #include <cstdint>
 #include <vector>

 using llvm::SmallVector;

 int AsyncInfoTy::synchronize() {
   int Result = OFFLOAD_SUCCESS;
   if (!isQueueEmpty()) {
Index: llvm/lib/WindowsDriver/MSVCPaths.cpp
===================================================================
--- llvm/lib/WindowsDriver/MSVCPaths.cpp
+++ llvm/lib/WindowsDriver/MSVCPaths.cpp
@@ -9,6 +9,7 @@
 #include "llvm/WindowsDriver/MSVCPaths.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Path.h"
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/source/Host/common/XML.cpp
===================================================================
--- lldb/source/Host/common/XML.cpp
+++ lldb/source/Host/common/XML.cpp
@@ -9,15 +9,17 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/XML.h"

+#include "llvm/ADT/StringExtras.h"
+
 using namespace lldb;
 using namespace lldb_private;

 #pragma mark-- XMLDocument

 XMLDocument::XMLDocument() = default;

 XMLDocument::~XMLDocument() { Clear(); }

 void XMLDocument::Clear() {
 #if LLDB_ENABLE_LIBXML2
   if (m_document) {
Index: lldb/source/Host/common/Socket.cpp
===================================================================
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -16,15 +16,16 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"

+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/WindowsError.h"

 #if LLDB_ENABLE_POSIX
 #include "lldb/Host/posix/DomainSocket.h"

 #include <arpa/inet.h>
 #include <netdb.h>
 #include <netinet/in.h>
Index: lldb/source/Host/common/File.cpp
===================================================================
--- lldb/source/Host/common/File.cpp
+++ lldb/source/Host/common/File.cpp
@@ -31,21 +31,22 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/VASPrintf.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Process.h"

 using namespace lldb;
 using namespace lldb_private;
 using llvm::Expected;

 Expected<const char *>
 File::GetStreamOpenModeFromOptions(File::OpenOptions options) {
   File::OpenOptions rw =
       options & (File::eOpenOptionReadOnly | File::eOpenOptionWriteOnly |
                  File::eOpenOptionReadWrite);

   if (options & File::eOpenOptionAppend) {
     if (rw == File::eOpenOptionReadWrite) {
       if (options & File::eOpenOptionCanCreateNewOnly)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to