[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] [lldb] cec33fc - [lldb] Consider TAG_imported_declaration in DebugNamesIndex

2023-07-08 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-07-08T09:16:11-04:00
New Revision: cec33fc87c0c0094b0d627031ff756b2d1f905eb

URL: 
https://github.com/llvm/llvm-project/commit/cec33fc87c0c0094b0d627031ff756b2d1f905eb
DIFF: 
https://github.com/llvm/llvm-project/commit/cec33fc87c0c0094b0d627031ff756b2d1f905eb.diff

LOG: [lldb] Consider TAG_imported_declaration in DebugNamesIndex

In order to recognize namespace aliases as a namespace, the
DW_TAG_imported_declaration has to be taken into account. The name of these DIEs
is already included in all accelerator tables as of D143397.

Two of the three Index classes already handle this correctly:

1. ManualDWARFIndex (as of D143398)
2. AppleDWARFIndex works by default with D143397, since apple has a table
dedicated to namespaces.

This commit updates the third index class, DWARF 5's DebugNamesDWARFIndex.
As a result, it fixes the following test with DWARF 5:
commands/expression/namespace-alias/TestInlineNamespaceAlias.py

Differential Revision: https://reviews.llvm.org/D154730

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 1711a229443672..af2d6c554140bc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -227,7 +227,9 @@ void DebugNamesDWARFIndex::GetNamespaces(
 ConstString name, llvm::function_ref callback) {
   for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
-if (entry.tag() == DW_TAG_namespace) {
+dwarf::Tag entry_tag = entry.tag();
+if (entry_tag == DW_TAG_namespace ||
+entry_tag == DW_TAG_imported_declaration) {
   if (!ProcessEntry(entry, callback))
 return;
 }



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


[Lldb-commits] [PATCH] D154730: [lldb] Consider TAG_imported_declaration in DebugNamesIndex

2023-07-08 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcec33fc87c0c: [lldb] Consider TAG_imported_declaration in 
DebugNamesIndex (authored by fdeazeve).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154730

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -227,7 +227,9 @@
 ConstString name, llvm::function_ref callback) {
   for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
-if (entry.tag() == DW_TAG_namespace) {
+dwarf::Tag entry_tag = entry.tag();
+if (entry_tag == DW_TAG_namespace ||
+entry_tag == DW_TAG_imported_declaration) {
   if (!ProcessEntry(entry, callback))
 return;
 }


Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -227,7 +227,9 @@
 ConstString name, llvm::function_ref callback) {
   for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
-if (entry.tag() == DW_TAG_namespace) {
+dwarf::Tag entry_tag = entry.tag();
+if (entry_tag == DW_TAG_namespace ||
+entry_tag == DW_TAG_imported_declaration) {
   if (!ProcessEntry(entry, callback))
 return;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[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] [lldb] a11efd4 - Add missing StringExtras.h includes

2023-07-08 Thread Elliot Goodrich via lldb-commits

Author: Elliot Goodrich
Date: 2023-07-08T20:06:21+01:00
New Revision: a11efd49266f6cf2a98bdf52428b0c9423158846

URL: 
https://github.com/llvm/llvm-project/commit/a11efd49266f6cf2a98bdf52428b0c9423158846
DIFF: 
https://github.com/llvm/llvm-project/commit/a11efd49266f6cf2a98bdf52428b0c9423158846.diff

LOG: 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 and
39d8e6e22cd1.

Differential Revision: https://reviews.llvm.org/D154763

Added: 


Modified: 
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

Removed: 




diff  --git a/lldb/source/Host/common/File.cpp 
b/lldb/source/Host/common/File.cpp
index 15e7a211e353e7..7c5d71d9426ead 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/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"

diff  --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index c2fb5509034e5c..8ccb27fdd7f452 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/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"

diff  --git a/lldb/source/Host/common/XML.cpp b/lldb/source/Host/common/XML.cpp
index bb2a72938a5e2d..f480ef3166a443 100644
--- a/lldb/source/Host/common/XML.cpp
+++ b/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;
 

diff  --git a/llvm/lib/WindowsDriver/MSVCPaths.cpp 
b/llvm/lib/WindowsDriver/MSVCPaths.cpp
index f8c4259ec8f5ed..1c070bf1bf7d7d 100644
--- a/llvm/lib/WindowsDriver/MSVCPaths.cpp
+++ b/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"

diff  --git a/openmp/libomptarget/src/omptarget.cpp 
b/openmp/libomptarget/src/omptarget.cpp
index 9426d8a0ca76f6..45576c6cd80dc1 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/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 



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


[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