[Lldb-commits] [PATCH] D154763: [Support] Move StringExtras.h include from Error.h to Error.cpp (attempt 3)

2023-07-08 Thread Elliot Goodrich via Phabricator via lldb-commits
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 
 #include 
 #include 

 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 

 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())
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.

[Lldb-commits] [PATCH] D154763: [Support] Move StringExtras.h include from Error.h to Error.cpp (attempt 3)

2023-07-08 Thread Elliot Goodrich via Phabricator via lldb-commits
IncludeGuardian updated this revision to Diff 538372.
IncludeGuardian added a comment.

Run clang-format over changes


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154763/new/

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
@@ -16,14 +16,15 @@
 #include "private.h"
 #include "rtl.h"

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

 #include 
 #include 
 #include 

 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 

 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())
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 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-commits] [PATCH] D154763: [Support] Move StringExtras.h include from Error.h to Error.cpp (attempt 3)

2023-07-08 Thread Elliot Goodrich via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa11efd49266f: Add missing StringExtras.h includes (authored 
by IncludeGuardian).

Changed prior to commit:
  https://reviews.llvm.org/D154763?vs=538372&id=538382#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154763/new/

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/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
@@ -16,6 +16,7 @@
 #include "private.h"
 #include "rtl.h"
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/bit.h"
 
 #include 
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: lldb/source/Host/common/XML.cpp
===
--- lldb/source/Host/common/XML.cpp
+++ lldb/source/Host/common/XML.cpp
@@ -9,6 +9,8 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/XML.h"
 
+#include "llvm/ADT/StringExtras.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
Index: lldb/source/Host/common/Socket.cpp
===
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Utility/Log.h"
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Regex.h"
Index: lldb/source/Host/common/File.cpp
===
--- lldb/source/Host/common/File.cpp
+++ lldb/source/Host/common/File.cpp
@@ -31,6 +31,7 @@
 #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"


Index: openmp/libomptarget/src/omptarget.cpp
===
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -16,6 +16,7 @@
 #include "private.h"
 #include "rtl.h"
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/bit.h"
 
 #include 
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: lldb/source/Host/common/XML.cpp
===
--- lldb/source/Host/common/XML.cpp
+++ lldb/source/Host/common/XML.cpp
@@ -9,6 +9,8 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/XML.h"
 
+#include "llvm/ADT/StringExtras.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
Index: lldb/source/Host/common/Socket.cpp
===
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Utility/Log.h"
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Regex.h"
Index: lldb/source/Host/common/File.cpp
===
--- lldb/source/Host/common/File.cpp
+++ lldb/source/Host/common/File.cpp
@@ -31,6 +31,7 @@
 #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"
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D154775: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 4)

2023-07-08 Thread Elliot Goodrich via Phabricator via lldb-commits
IncludeGuardian created this revision.
IncludeGuardian added a reviewer: MaskRay.
Herald added subscribers: arphaman, 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 
, 
39d8e6e22cd1 
, and
a11efd49266f 
.

---

**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/D154775

Files:
  lldb/source/Core/SourceLocationSpec.cpp
  lldb/source/Plugins/Process/Linux/Procfs.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
  lldb/source/Utility/DataExtractor.cpp
  lldb/source/Utility/Event.cpp
  lldb/source/Utility/FileSpec.cpp
  lldb/source/Utility/Scalar.cpp
  lldb/source/Utility/StructuredData.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 

 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())
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 Errors;
-  handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) {
-Errors.push_back(EI.message());
-  });
-  ret

[Lldb-commits] [PATCH] D154775: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 4)

2023-07-08 Thread Elliot Goodrich via Phabricator via lldb-commits
IncludeGuardian added a comment.
Herald added a subscriber: JDevlieghere.

After the previous attempt, I believe only LLDB was failing to compile.  These 
are the necessary changes needed to fix all of LLDB locally on `main`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154775/new/

https://reviews.llvm.org/D154775

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D154775: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 4)

2023-07-09 Thread Elliot Goodrich via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5551657b310b: [lldb] Add missing StringExtras.h includes 
(authored by IncludeGuardian).

Changed prior to commit:
  https://reviews.llvm.org/D154775?vs=538389&id=538423#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154775/new/

https://reviews.llvm.org/D154775

Files:
  lldb/source/Core/SourceLocationSpec.cpp
  lldb/source/Plugins/Process/Linux/Procfs.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
  lldb/source/Utility/DataExtractor.cpp
  lldb/source/Utility/Event.cpp
  lldb/source/Utility/FileSpec.cpp
  lldb/source/Utility/Scalar.cpp
  lldb/source/Utility/StructuredData.cpp


Index: lldb/source/Utility/StructuredData.cpp
===
--- lldb/source/Utility/StructuredData.cpp
+++ lldb/source/Utility/StructuredData.cpp
@@ -9,6 +9,7 @@
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include 
 #include 
Index: lldb/source/Utility/Scalar.cpp
===
--- lldb/source/Utility/Scalar.cpp
+++ lldb/source/Utility/Scalar.cpp
@@ -16,6 +16,7 @@
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 
 #include 
 #include 
Index: lldb/source/Utility/FileSpec.cpp
===
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -12,6 +12,7 @@
 
 #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/ErrorOr.h"
Index: lldb/source/Utility/Event.cpp
===
--- lldb/source/Utility/Event.cpp
+++ lldb/source/Utility/Event.cpp
@@ -15,6 +15,8 @@
 #include "lldb/Utility/StreamString.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "llvm/ADT/StringExtras.h"
+
 #include 
 
 #include 
Index: lldb/source/Utility/DataExtractor.cpp
===
--- lldb/source/Utility/DataExtractor.cpp
+++ lldb/source/Utility/DataExtractor.cpp
@@ -23,6 +23,7 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
Index: lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
===
--- lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
+++ lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntervalMap.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
 #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
Index: lldb/source/Plugins/Process/Linux/Procfs.cpp
===
--- lldb/source/Plugins/Process/Linux/Procfs.cpp
+++ lldb/source/Plugins/Process/Linux/Procfs.cpp
@@ -8,6 +8,7 @@
 
 #include "Procfs.h"
 #include "lldb/Host/linux/Support.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Threading.h"
Index: lldb/source/Core/SourceLocationSpec.cpp
===
--- lldb/source/Core/SourceLocationSpec.cpp
+++ lldb/source/Core/SourceLocationSpec.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Core/SourceLocationSpec.h"
 #include "lldb/Utility/StreamString.h"
+#include "llvm/ADT/StringExtras.h"
 #include 
 
 using namespace lldb;


Index: lldb/source/Utility/StructuredData.cpp
===
--- lldb/source/Utility/StructuredData.cpp
+++ lldb/source/Utility/StructuredData.cpp
@@ -9,6 +9,7 @@
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include 
 #include 
Index: lldb/source/Utility/Scalar.cpp
===
--- lldb/source/Utility/Scalar.cpp
+++ lldb/source/Utility/Scalar.cpp
@@ -16,6 +16,7 @@
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 
 #include 
 #include 
Index: lldb/source/Utility/FileSpec.cpp

[Lldb-commits] [PATCH] D155018: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 5)

2023-07-11 Thread Elliot Goodrich via Phabricator via lldb-commits
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 
, 
39d8e6e22cd1 
,
a11efd49266f 
, and 
5551657b310b 
.

---

**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 

 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())
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 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 expec

[Lldb-commits] [PATCH] D155018: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 5)

2023-07-11 Thread Elliot Goodrich via Phabricator via lldb-commits
IncludeGuardian added inline comments.
Herald added a subscriber: JDevlieghere.



Comment at: lldb/tools/lldb-vscode/VSCode.cpp:17
 #include "llvm/Support/FormatVariadic.h"

 #if defined(_WIN32)
 #define NOMINMAX

This should be the final failure on the last time landing the `Error.h` change 
to `main` https://lab.llvm.org/buildbot#builders/68/builds/55847


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155018/new/

https://reviews.llvm.org/D155018

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D155018: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 5)

2023-07-13 Thread Elliot Goodrich via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90bfe2df25e7: [lldb] Add missing StringExtras.h includes 
(authored by IncludeGuardian).

Changed prior to commit:
  https://reviews.llvm.org/D155018?vs=539291&id=539872#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155018/new/

https://reviews.llvm.org/D155018

Files:
  lldb/tools/lldb-vscode/VSCode.cpp


Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -14,6 +14,7 @@
 
 #include "LLDBUtils.h"
 #include "VSCode.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/FormatVariadic.h"
 
 #if defined(_WIN32)


Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -14,6 +14,7 @@
 
 #include "LLDBUtils.h"
 #include "VSCode.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/FormatVariadic.h"
 
 #if defined(_WIN32)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D155178: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 6)

2023-07-13 Thread Elliot Goodrich via Phabricator via lldb-commits
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 
, 
39d8e6e22cd1 
,
a11efd49266f 
, 
5551657b310b 
, and 
90bfe2df25e7 
.

---

**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/D155178

Files:
  lldb/unittests/Symbol/PostfixExpressionTest.cpp
  lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.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 

 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())
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 Errors;
-  handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) {
-Errors.push_back(EI.message());
-  });
-  return join(Errors.begin(), Errors.end(), "\n");
-}
+std

[Lldb-commits] [PATCH] D155178: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 6)

2023-07-13 Thread Elliot Goodrich via Phabricator via lldb-commits
IncludeGuardian added a comment.
Herald added subscribers: Michael137, JDevlieghere.

@MaskRay seems like `ninja` on its own after preparing `lldb` isn't enough to 
build tests. I've now built llvm, clang, flang, bolt, lldb, + tests - I'm 
hoping that this is it now!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155178/new/

https://reviews.llvm.org/D155178

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D155178: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 6)

2023-07-13 Thread Elliot Goodrich via Phabricator via lldb-commits
IncludeGuardian added a comment.

@fdeazeve Thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155178/new/

https://reviews.llvm.org/D155178

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D155178: [Support] Move StringExtras.h include from Error.h to Error.cpp (part 6)

2023-07-13 Thread Elliot Goodrich via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ff3af3086da: [lldb] Add missing StringExtras.h includes 
(authored by IncludeGuardian).

Changed prior to commit:
  https://reviews.llvm.org/D155178?vs=539953&id=540163#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155178/new/

https://reviews.llvm.org/D155178

Files:
  lldb/unittests/Symbol/PostfixExpressionTest.cpp
  lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp


Index: lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp
===
--- lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp
+++ lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h"
+#include "llvm/ADT/StringExtras.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
Index: lldb/unittests/Symbol/PostfixExpressionTest.cpp
===
--- lldb/unittests/Symbol/PostfixExpressionTest.cpp
+++ lldb/unittests/Symbol/PostfixExpressionTest.cpp
@@ -9,6 +9,7 @@
 #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"


Index: lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp
===
--- lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp
+++ lldb/unittests/SymbolFile/NativePDB/UdtRecordCompleterTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h"
+#include "llvm/ADT/StringExtras.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
Index: lldb/unittests/Symbol/PostfixExpressionTest.cpp
===
--- lldb/unittests/Symbol/PostfixExpressionTest.cpp
+++ lldb/unittests/Symbol/PostfixExpressionTest.cpp
@@ -9,6 +9,7 @@
 #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"
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits