[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-30 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Please add a note to 
https://github.com/llvm/llvm-project/blob/main/llvm/docs/ReleaseNotes.rst#changes-to-lldb,
 since this is quite a substantial new feature.

> Test Plan:

Did this get discussed? I don't see any tests here.

https://github.com/llvm/llvm-project/pull/70996
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-30 Thread David Spickett via lldb-commits

DavidSpickett wrote:

If this code is calling a library - which itself is already tested, that's fine 
but any smoke test we can do would be good.

E.g. set a bogus URL and expect that it fails to use it (assuming it does so 
visibly). Just to check the integration.

https://github.com/llvm/llvm-project/pull/70996
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)

2023-11-30 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 



@@ -252,11 +253,16 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
-s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
-s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+  if (ConstString demangled = m_mangled.GetDemangledName()) {
+s->Printf(", name=\"");

DavidSpickett wrote:

These printfs with constant strings could be putcstring.

https://github.com/llvm/llvm-project/pull/69422
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-11-30 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 


https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/69422
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-11-30 Thread David Spickett via lldb-commits
=?utf-8?q?Jos=C3=A9?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

Nominating @JDevlieghere to review this.

https://github.com/llvm/llvm-project/pull/69422
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [mlir] [lldb] [lld] [llvm] [flang] [libcxx] [libc] [clang-tools-extra] [compiler-rt] [openmp] [clang] [libcxxabi] [libunwind] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread Mariya Podchishchaeva via lldb-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/73099

>From 1d70b7726e7d1f11622a6d5c8246b0737e024c8d Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Tue, 19 Sep 2023 08:37:18 -0700
Subject: [PATCH 1/6] [C23] Implement N3018: The constexpr specifier for object
 definitions

The implementation mostly reuses C++ code paths where possible,
including narrowing check in order to provide diagnostic messages in
case initializer for constexpr variable is not exactly representable in
target type.

The following won't work due to lack of support for other features:
- Diagnosing of underspecified declarations involving constexpr
- Constexpr attached to compound literals

Also due to lack of support for char8_t some of examples with utf-8
strings don't work properly.
---
 clang/docs/ReleaseNotes.rst   |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  16 +
 clang/include/clang/Basic/TokenKinds.def  |   2 +-
 clang/lib/AST/Decl.cpp|  16 +-
 clang/lib/AST/ExprConstant.cpp|  17 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +
 clang/lib/Sema/SemaDecl.cpp   | 204 +++--
 clang/lib/Sema/SemaOverload.cpp   |  36 ++-
 clang/test/C/C2x/n3018.c  |  86 ++
 clang/test/Parser/c23-constexpr.c |   6 +
 clang/test/Sema/constexpr.c   | 275 ++
 clang/www/c_status.html   |   2 +-
 12 files changed, 627 insertions(+), 36 deletions(-)
 create mode 100644 clang/test/C/C2x/n3018.c
 create mode 100644 clang/test/Parser/c23-constexpr.c
 create mode 100644 clang/test/Sema/constexpr.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b65106b9106d4d7..cae1707f3e30feb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -208,6 +208,7 @@ C23 Feature Support
 
 - Clang now supports  which defines several macros for 
performing
   checked integer arithmetic. It is also exposed in pre-C23 modes.
+- Clang now supports ``N3018 The constexpr specifier for object definitions``.
 
 - Completed the implementation of
   `N2508 `_. We
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 990692c06d7d3a8..11f24583dc55a9b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2932,6 +2932,22 @@ def warn_private_extern : Warning<
 def note_private_extern : Note<
   "use __attribute__((visibility(\"hidden\"))) attribute instead">;
 
+// C23 constexpr
+def err_c23_thread_local_constexpr : Error<
+  "thread-local storage is not allowed with constexpr">;
+def err_c23_extern_constexpr : Error<
+  "extern specifier is not allowed with constexpr">;
+def err_c23_constexpr_not_variable : Error<
+  "constexpr is only allowed in variable declarations">;
+def err_c23_constexpr_invalid_type : Error<
+  "constexpr variable cannot have type %0">;
+def err_c23_constexpr_init_not_representable : Error<
+  "constexpr initializer evaluates to %0 which is not exactly representable in 
type %1">;
+def err_c23_constexpr_init_type_mismatch : Error<
+  "constexpr initializer for type %0 is of type %1">;
+def err_c23_constexpr_pointer_not_null : Error<
+  "constexpr pointer initializer is not null">;
+
 // C++ Concepts
 def err_concept_decls_may_only_appear_in_global_namespace_scope : Error<
   "concept declarations may only appear in global or namespace scope">;
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 3ab420821d82bfe..e9e8f59247662ea 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -393,7 +393,7 @@ CXX11_KEYWORD(alignas   , KEYC23)
 CXX11_UNARY_EXPR_OR_TYPE_TRAIT(alignof, AlignOf, KEYC23)
 CXX11_KEYWORD(char16_t  , KEYNOMS18)
 CXX11_KEYWORD(char32_t  , KEYNOMS18)
-CXX11_KEYWORD(constexpr , 0)
+CXX11_KEYWORD(constexpr , KEYC23)
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , KEYC23)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index c5c2edf1bfe3aba..678a366ed29ad78 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2461,7 +2461,7 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // OpenCL permits const integral variables to be used in constant
   // expressions, like in C++98.
-  if (!Lang.CPlusPlus && !Lang.OpenCL)
+  if (!Lang.CPlusPlus && !Lang.OpenCL && !Lang.C23)
 return false;
 
   // Function parameters are never usable in constant expressions.
@@ -2485,12 +2485,12 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // In C++, const, 

[Lldb-commits] [mlir] [clang] [compiler-rt] [llvm] [lldb] [libcxxabi] [libcxx] [clang-tools-extra] [flang] [lld] [libunwind] [libc] [openmp] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread Mariya Podchishchaeva via lldb-commits


@@ -2485,12 +2485,12 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // In C++, const, non-volatile variables of integral or enumeration types
   // can be used in constant expressions.
-  if (getType()->isIntegralOrEnumerationType())
+  if (getType()->isIntegralOrEnumerationType() && !Lang.C23)
 return true;
 
   // Additionally, in C++11, non-volatile constexpr variables can be used in
   // constant expressions.
-  return Lang.CPlusPlus11 && isConstexpr();
+  return (Lang.CPlusPlus11 || Lang.C23) && isConstexpr();

Fznamznon wrote:

Ok, updated.

https://github.com/llvm/llvm-project/pull/73099
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [libcxx] [libunwind] [clang] [openmp] [llvm] [clang-tools-extra] [libcxxabi] [lld] [flang] [lldb] [mlir] [libc] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread Mariya Podchishchaeva via lldb-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/73099

>From 1d70b7726e7d1f11622a6d5c8246b0737e024c8d Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Tue, 19 Sep 2023 08:37:18 -0700
Subject: [PATCH 1/6] [C23] Implement N3018: The constexpr specifier for object
 definitions

The implementation mostly reuses C++ code paths where possible,
including narrowing check in order to provide diagnostic messages in
case initializer for constexpr variable is not exactly representable in
target type.

The following won't work due to lack of support for other features:
- Diagnosing of underspecified declarations involving constexpr
- Constexpr attached to compound literals

Also due to lack of support for char8_t some of examples with utf-8
strings don't work properly.
---
 clang/docs/ReleaseNotes.rst   |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  16 +
 clang/include/clang/Basic/TokenKinds.def  |   2 +-
 clang/lib/AST/Decl.cpp|  16 +-
 clang/lib/AST/ExprConstant.cpp|  17 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +
 clang/lib/Sema/SemaDecl.cpp   | 204 +++--
 clang/lib/Sema/SemaOverload.cpp   |  36 ++-
 clang/test/C/C2x/n3018.c  |  86 ++
 clang/test/Parser/c23-constexpr.c |   6 +
 clang/test/Sema/constexpr.c   | 275 ++
 clang/www/c_status.html   |   2 +-
 12 files changed, 627 insertions(+), 36 deletions(-)
 create mode 100644 clang/test/C/C2x/n3018.c
 create mode 100644 clang/test/Parser/c23-constexpr.c
 create mode 100644 clang/test/Sema/constexpr.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b65106b9106d4d7..cae1707f3e30feb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -208,6 +208,7 @@ C23 Feature Support
 
 - Clang now supports  which defines several macros for 
performing
   checked integer arithmetic. It is also exposed in pre-C23 modes.
+- Clang now supports ``N3018 The constexpr specifier for object definitions``.
 
 - Completed the implementation of
   `N2508 `_. We
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 990692c06d7d3a8..11f24583dc55a9b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2932,6 +2932,22 @@ def warn_private_extern : Warning<
 def note_private_extern : Note<
   "use __attribute__((visibility(\"hidden\"))) attribute instead">;
 
+// C23 constexpr
+def err_c23_thread_local_constexpr : Error<
+  "thread-local storage is not allowed with constexpr">;
+def err_c23_extern_constexpr : Error<
+  "extern specifier is not allowed with constexpr">;
+def err_c23_constexpr_not_variable : Error<
+  "constexpr is only allowed in variable declarations">;
+def err_c23_constexpr_invalid_type : Error<
+  "constexpr variable cannot have type %0">;
+def err_c23_constexpr_init_not_representable : Error<
+  "constexpr initializer evaluates to %0 which is not exactly representable in 
type %1">;
+def err_c23_constexpr_init_type_mismatch : Error<
+  "constexpr initializer for type %0 is of type %1">;
+def err_c23_constexpr_pointer_not_null : Error<
+  "constexpr pointer initializer is not null">;
+
 // C++ Concepts
 def err_concept_decls_may_only_appear_in_global_namespace_scope : Error<
   "concept declarations may only appear in global or namespace scope">;
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 3ab420821d82bfe..e9e8f59247662ea 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -393,7 +393,7 @@ CXX11_KEYWORD(alignas   , KEYC23)
 CXX11_UNARY_EXPR_OR_TYPE_TRAIT(alignof, AlignOf, KEYC23)
 CXX11_KEYWORD(char16_t  , KEYNOMS18)
 CXX11_KEYWORD(char32_t  , KEYNOMS18)
-CXX11_KEYWORD(constexpr , 0)
+CXX11_KEYWORD(constexpr , KEYC23)
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , KEYC23)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index c5c2edf1bfe3aba..678a366ed29ad78 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2461,7 +2461,7 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // OpenCL permits const integral variables to be used in constant
   // expressions, like in C++98.
-  if (!Lang.CPlusPlus && !Lang.OpenCL)
+  if (!Lang.CPlusPlus && !Lang.OpenCL && !Lang.C23)
 return false;
 
   // Function parameters are never usable in constant expressions.
@@ -2485,12 +2485,12 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // In C++, const, 

[Lldb-commits] [lldb] [lld] [llvm] [flang] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [clang] [libcxxabi] [libunwind] [AMDGPU] Add test for GCNRegPressure tracker bug (PR #73786)

2023-11-30 Thread Piotr Sobczak via lldb-commits

piotrAMD wrote:

Rebased and added missing live-throughs.

https://github.com/llvm/llvm-project/pull/73786
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [clang] [libc] [llvm] [lldb] [clang-tools-extra] [flang] [mlir] [DAGCombiner] Combine frem into fdiv+ftrunc+fma (PR #67642)

2023-11-30 Thread David Green via lldb-commits

davemgreen wrote:

Do you have any analysis on the expected magnitude of the inaccuracy we might 
expect from performing the fdiv/trunc/fma vs the call to fmod?

https://github.com/llvm/llvm-project/pull/67642
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [flang] [lldb] [libc] [clang] [clang-tools-extra] [libcxxabi] [llvm] [compiler-rt] [libcxx] [libunwind] [lld] [libc] Add more functions in CPP/bit.h (PR #73814)

2023-11-30 Thread Guillaume Chatelet via lldb-commits

https://github.com/gchatelet updated 
https://github.com/llvm/llvm-project/pull/73814

>From bdd0a0855c0dd98c93977db6982e480ab270b3cd Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet 
Date: Wed, 29 Nov 2023 16:29:12 +
Subject: [PATCH 1/7] [libc] Add more functions in CPP/bit.h

---
 libc/src/__support/CPP/CMakeLists.txt |   1 +
 libc/src/__support/CPP/bit.h  | 242 --
 libc/src/__support/CPP/limits.h   |  18 +-
 libc/test/src/__support/CPP/CMakeLists.txt|  11 +
 libc/test/src/__support/CPP/bit_test.cpp  | 216 
 .../llvm-project-overlay/libc/BUILD.bazel |   1 +
 .../libc/test/src/__support/CPP/BUILD.bazel   |   9 +
 7 files changed, 478 insertions(+), 20 deletions(-)
 create mode 100644 libc/test/src/__support/CPP/bit_test.cpp

diff --git a/libc/src/__support/CPP/CMakeLists.txt 
b/libc/src/__support/CPP/CMakeLists.txt
index 10bcebf9b04f61d..5c47b2a815356b9 100644
--- a/libc/src/__support/CPP/CMakeLists.txt
+++ b/libc/src/__support/CPP/CMakeLists.txt
@@ -15,6 +15,7 @@ add_header_library(
   HDRS
 bit.h
   DEPENDS
+.limits
 .type_traits
 libc.src.__support.macros.attributes
 libc.src.__support.macros.config
diff --git a/libc/src/__support/CPP/bit.h b/libc/src/__support/CPP/bit.h
index f6f3131c1ccfd81..f744d804398e213 100644
--- a/libc/src/__support/CPP/bit.h
+++ b/libc/src/__support/CPP/bit.h
@@ -1,57 +1,261 @@
-//===-- Freestanding version of bit_cast  ---*- C++ 
-*-===//
+//===-- Implementation of the C++20 bit header  -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===--===//
+// This is inspired from LLVM ADT/bit.h header.
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
 #define LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
 
+#include "src/__support/CPP/limits.h" // numeric_limits
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/macros/attributes.h"
 #include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN
 #include "src/__support/macros/sanitizer.h"
 
-namespace LIBC_NAMESPACE::cpp {
+#include 
 
-#if LIBC_HAS_BUILTIN(__builtin_bit_cast)
-#define LLVM_LIBC_HAS_BUILTIN_BIT_CAST
-#endif
+namespace LIBC_NAMESPACE::cpp {
 
 #if LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
 #define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
 #endif
 
-// This function guarantees the bitcast to be optimized away by the compiler 
for
-// GCC >= 8 and Clang >= 6.
-template 
+// This implementation of bit_cast requires trivially-constructible To, to 
avoid
+// UB in the implementation.
+template <
+typename To, typename From,
+typename = cpp::enable_if_t,
+typename = cpp::enable_if_t::value>,
+typename = cpp::enable_if_t::value>,
+typename = cpp::enable_if_t::value>>
 LIBC_INLINE constexpr To bit_cast(const From &from) {
-  static_assert(sizeof(To) == sizeof(From), "To and From must be of same 
size");
-  static_assert(cpp::is_trivially_copyable::value &&
-cpp::is_trivially_copyable::value,
-"Cannot bit-cast instances of non-trivially copyable 
classes.");
   MSAN_UNPOISON(&from, sizeof(From));
-#if defined(LLVM_LIBC_HAS_BUILTIN_BIT_CAST)
+#if LIBC_HAS_BUILTIN(__builtin_bit_cast)
   return __builtin_bit_cast(To, from);
 #else
-  static_assert(cpp::is_trivially_constructible::value,
-"This implementation additionally requires destination type to 
"
-"be trivially constructible");
   To to;
   char *dst = reinterpret_cast(&to);
   const char *src = reinterpret_cast(&from);
-#if defined(LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE)
+#if LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
   __builtin_memcpy_inline(dst, src, sizeof(To));
 #else
   for (unsigned i = 0; i < sizeof(To); ++i)
 dst[i] = src[i];
-#endif // defined(LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE)
+#endif // LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
   return to;
-#endif // defined(LLVM_LIBC_HAS_BUILTIN_BIT_CAST)
+#endif // LIBC_HAS_BUILTIN(__builtin_bit_cast)
+}
+
+template >>
+[[nodiscard]] LIBC_INLINE constexpr bool has_single_bit(T value) {
+  return (value != 0) && ((value & (value - 1)) == 0);
+}
+
+// A temporary macro to add template function specialization when compiler
+// builtin is available.
+#define ADD_SPECIALIZATION(NAME, TYPE, BUILTIN)
\
+  template <> [[nodiscard]] LIBC_INLINE constexpr int NAME(TYPE value) { 
\
+static_assert(cpp::is_unsigned_v);   
\
+return value == 0 ? cpp::numeric_limits::digits : BUILTIN(value);
\
+  }
+
+/// Count number of 0's from the least significant bit to the most
+///   stopping at the first 1.
+///
+/// Only unsigned integral types are allowed.
+///
+/// Returns cpp::numeric_limits::dig

[Lldb-commits] [compiler-rt] [llvm] [libcxxabi] [clang-tools-extra] [clang] [libunwind] [libc] [flang] [lldb] [libcxx] [lld] [libc] Add more functions in CPP/bit.h (PR #73814)

2023-11-30 Thread Guillaume Chatelet via lldb-commits

https://github.com/gchatelet updated 
https://github.com/llvm/llvm-project/pull/73814

>From bdd0a0855c0dd98c93977db6982e480ab270b3cd Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet 
Date: Wed, 29 Nov 2023 16:29:12 +
Subject: [PATCH 1/8] [libc] Add more functions in CPP/bit.h

---
 libc/src/__support/CPP/CMakeLists.txt |   1 +
 libc/src/__support/CPP/bit.h  | 242 --
 libc/src/__support/CPP/limits.h   |  18 +-
 libc/test/src/__support/CPP/CMakeLists.txt|  11 +
 libc/test/src/__support/CPP/bit_test.cpp  | 216 
 .../llvm-project-overlay/libc/BUILD.bazel |   1 +
 .../libc/test/src/__support/CPP/BUILD.bazel   |   9 +
 7 files changed, 478 insertions(+), 20 deletions(-)
 create mode 100644 libc/test/src/__support/CPP/bit_test.cpp

diff --git a/libc/src/__support/CPP/CMakeLists.txt 
b/libc/src/__support/CPP/CMakeLists.txt
index 10bcebf9b04f61d..5c47b2a815356b9 100644
--- a/libc/src/__support/CPP/CMakeLists.txt
+++ b/libc/src/__support/CPP/CMakeLists.txt
@@ -15,6 +15,7 @@ add_header_library(
   HDRS
 bit.h
   DEPENDS
+.limits
 .type_traits
 libc.src.__support.macros.attributes
 libc.src.__support.macros.config
diff --git a/libc/src/__support/CPP/bit.h b/libc/src/__support/CPP/bit.h
index f6f3131c1ccfd81..f744d804398e213 100644
--- a/libc/src/__support/CPP/bit.h
+++ b/libc/src/__support/CPP/bit.h
@@ -1,57 +1,261 @@
-//===-- Freestanding version of bit_cast  ---*- C++ 
-*-===//
+//===-- Implementation of the C++20 bit header  -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===--===//
+// This is inspired from LLVM ADT/bit.h header.
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
 #define LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
 
+#include "src/__support/CPP/limits.h" // numeric_limits
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/macros/attributes.h"
 #include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN
 #include "src/__support/macros/sanitizer.h"
 
-namespace LIBC_NAMESPACE::cpp {
+#include 
 
-#if LIBC_HAS_BUILTIN(__builtin_bit_cast)
-#define LLVM_LIBC_HAS_BUILTIN_BIT_CAST
-#endif
+namespace LIBC_NAMESPACE::cpp {
 
 #if LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
 #define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
 #endif
 
-// This function guarantees the bitcast to be optimized away by the compiler 
for
-// GCC >= 8 and Clang >= 6.
-template 
+// This implementation of bit_cast requires trivially-constructible To, to 
avoid
+// UB in the implementation.
+template <
+typename To, typename From,
+typename = cpp::enable_if_t,
+typename = cpp::enable_if_t::value>,
+typename = cpp::enable_if_t::value>,
+typename = cpp::enable_if_t::value>>
 LIBC_INLINE constexpr To bit_cast(const From &from) {
-  static_assert(sizeof(To) == sizeof(From), "To and From must be of same 
size");
-  static_assert(cpp::is_trivially_copyable::value &&
-cpp::is_trivially_copyable::value,
-"Cannot bit-cast instances of non-trivially copyable 
classes.");
   MSAN_UNPOISON(&from, sizeof(From));
-#if defined(LLVM_LIBC_HAS_BUILTIN_BIT_CAST)
+#if LIBC_HAS_BUILTIN(__builtin_bit_cast)
   return __builtin_bit_cast(To, from);
 #else
-  static_assert(cpp::is_trivially_constructible::value,
-"This implementation additionally requires destination type to 
"
-"be trivially constructible");
   To to;
   char *dst = reinterpret_cast(&to);
   const char *src = reinterpret_cast(&from);
-#if defined(LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE)
+#if LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
   __builtin_memcpy_inline(dst, src, sizeof(To));
 #else
   for (unsigned i = 0; i < sizeof(To); ++i)
 dst[i] = src[i];
-#endif // defined(LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE)
+#endif // LIBC_HAS_BUILTIN(__builtin_memcpy_inline)
   return to;
-#endif // defined(LLVM_LIBC_HAS_BUILTIN_BIT_CAST)
+#endif // LIBC_HAS_BUILTIN(__builtin_bit_cast)
+}
+
+template >>
+[[nodiscard]] LIBC_INLINE constexpr bool has_single_bit(T value) {
+  return (value != 0) && ((value & (value - 1)) == 0);
+}
+
+// A temporary macro to add template function specialization when compiler
+// builtin is available.
+#define ADD_SPECIALIZATION(NAME, TYPE, BUILTIN)
\
+  template <> [[nodiscard]] LIBC_INLINE constexpr int NAME(TYPE value) { 
\
+static_assert(cpp::is_unsigned_v);   
\
+return value == 0 ? cpp::numeric_limits::digits : BUILTIN(value);
\
+  }
+
+/// Count number of 0's from the least significant bit to the most
+///   stopping at the first 1.
+///
+/// Only unsigned integral types are allowed.
+///
+/// Returns cpp::numeric_limits::dig

[Lldb-commits] [compiler-rt] [llvm] [libcxxabi] [clang-tools-extra] [clang] [libunwind] [libc] [flang] [lldb] [libcxx] [lld] [libc] Add more functions in CPP/bit.h (PR #73814)

2023-11-30 Thread Guillaume Chatelet via lldb-commits

https://github.com/gchatelet closed 
https://github.com/llvm/llvm-project/pull/73814
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [openmp] [llvm] [libcxxabi] [clang-tools-extra] [clang] [libunwind] [flang] [libc] [lldb] [libcxx] [lld] [mlir] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread via lldb-commits


@@ -14240,6 +14294,114 @@ StmtResult Sema::ActOnCXXForRangeIdentifier(Scope *S, 
SourceLocation IdentLoc,
   : IdentLoc);
 }
 
+static ImplicitConversionKind getConversionKind(QualType FromType,
+QualType ToType) {
+  if (ToType->isIntegerType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Integral;
+if (FromType->isIntegerType())
+  return ICK_Integral_Conversion;
+  }
+
+  if (ToType->isFloatingType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Conversion;
+if (FromType->isIntegerType())
+  return ICK_Floating_Integral;
+  }
+
+  return ICK_Identity;
+}
+
+static bool checkC23ConstexprInitConversion(Sema &S, const Expr *Init) {
+  assert(S.getLangOpts().C23);
+  const Expr *InitNoCast = Init->IgnoreImpCasts();
+  StandardConversionSequence SCS;
+  SCS.setAsIdentityConversion();
+  auto FromType = InitNoCast->getType();
+  auto ToType = Init->getType();
+  SCS.setToType(0, FromType);
+  SCS.setToType(1, ToType);
+  SCS.Second = getConversionKind(FromType, ToType);
+
+  APValue Value;
+  QualType PreNarrowingType;
+  // Reuse C++ narrowing check.
+  switch (SCS.getNarrowingKind(S.Context, Init, Value, PreNarrowingType,
+   /*IgnoreFloatToIntegralConversion*/ false)) {
+  // The value doesn't fit.
+  case NK_Constant_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_not_representable)
+<< Value.getAsString(S.Context, PreNarrowingType) << ToType;
+return true;
+
+  // Conversion to a narrower type.
+  case NK_Type_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_type_mismatch)
+<< ToType << FromType;
+return true;
+
+  // Since we only reuse narrowing check for C23 constexpr variables here, 
we're
+  // not really interested in these cases.
+  case NK_Dependent_Narrowing:
+  case NK_Variable_Narrowing:
+  case NK_Not_Narrowing:
+return false;
+  }
+  llvm_unreachable("unhandled case in switch");
+}
+
+static bool checkC23ConstexprInitStringLiteral(const StringLiteral *SE,
+   Sema &SemaRef,
+   SourceLocation Loc) {
+  assert(SemaRef.getLangOpts().C23);
+  // String literals have the target type attached but underneath may contain
+  // values that don't really fit into the target type. Check that every
+  // character fits.
+  const ConstantArrayType *CAT =
+  SemaRef.Context.getAsConstantArrayType(SE->getType());
+  QualType CharType = CAT->getElementType();
+  uint32_t BitWidth = SemaRef.Context.getTypeSize(CharType);
+  bool isUnsigned = CharType->isUnsignedIntegerType();
+  llvm::APSInt Value(BitWidth, isUnsigned);
+  const StringRef S = SE->getBytes();
+  for (unsigned I = 0, N = SE->getLength(); I != N; ++I) {
+Value = S[I];
+if (Value != S[I]) {
+  SemaRef.Diag(Loc, diag::err_c23_constexpr_init_not_representable)
+  << S[I] << CharType;

cor3ntin wrote:

Thanks for pointing out the wording.

I started to write a long reply before realizing I did not initially understand 
what your code was doing,
so I managed to be wrong twice! Sorry for being a bit slow.

Now that I *think* I get it (when do string literal get the target type 
attached?),
I am wondering if we should modify `getCodeUnit` to return an `int64` so that 
we don't loose the sign information in `getCodeUnit`. WDYT?

The alternative would be to reimplement a function similar to getCodeUnit that 
would keep the sign.




https://github.com/llvm/llvm-project/pull/73099
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [openmp] [llvm] [libcxxabi] [clang-tools-extra] [clang] [libunwind] [flang] [libc] [lldb] [libcxx] [lld] [mlir] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread via lldb-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/73099
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [flang] [lldb] [libc] [compiler-rt] [clang] [clang-tools-extra] [libcxxabi] [mlir] [llvm] [openmp] [libcxx] [libunwind] [lld] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread via lldb-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/73099
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [libc] [lld] [lldb] [clang-tools-extra] [llvm] [flang] [libcxx] [clang] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-30 Thread Aaron Ballman via lldb-commits


@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};

AaronBallman wrote:

Thanks for the feedback! I did some research of my own to see what the 
landscape looks like and here's what I found.

1) Support for these types came in 
https://github.com/llvm/llvm-project/commit/55c9877b664c1bc6614ad588f376ef41fe6ab4ca
 and there was no discussion on the patch 
(https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20091109/023777.html) 
before it landed with post-commit review saying it looked good 
(https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20091116/024219.html) 
and no justification beyond wanting a generalized algorithm.

2) There is hardware which supports 48-bit ints 
(https://en.wikipedia.org/wiki/48-bit_computing), 36-bit ints 
(https://en.wikipedia.org/wiki/36-bit_computing), 24-bit ints 
(https://en.wikipedia.org/wiki/24-bit_computing), etc. A lot of it is older 
hardware, but as examples, x86-64 uses a 48-bit addressing scheme, OpenCL 
supports intrinsics for 24-bit multiplication, UniSys has a 36-bit system they 
were selling as of 2015...

3) There's not evidence people are using stdint.h to serve those needs. For 
example: 
https://sourcegraph.com/search?q=context:global+int48_t+-file:.*clang.*+-file:.*stdint.*+-file:.*int48_t.*&patternType=standard&sm=1&groupBy=repo
 shows that most uses are either a custom C++ data type, use of an underlying 
non-basic int type, or bit-fields. I don't think I spotted a single use of 
`int48_t` that came from stdint.h. 
https://sourcegraph.com/search?q=context:global+int24_t+-file:.*clang.*+-file:.*stdint.*+-file:.*int24_t.*&patternType=standard&sm=1&groupBy=repo
 shows similarly for `int24_t`.

4) The code which defines the underlying macros used by stdint.h is here: 
https://github.com/llvm/llvm-project/blob/29a0f3ec2b47630ce229953fe7250e741b6c10b6/clang/lib/Frontend/InitPreprocessor.cpp#L220
 and it uses `TargetInfo::getTypeWidth()` to determine the width generically. 
We have no targets 
(https://github.com/llvm/llvm-project/tree/main/clang/lib/Basic/Targets) which 
define bit widths other than 8, 16, 32, 64, or 128. So Clang itself doesn't 
support those odd types yet.

Based on this and your details above, I think we should ignore these odd types 
for format strings on the assumption they're just not used. As for removing 
them from `stdint.h`, I think that is reasonable to explore given that we have 
no targets defining those widths (and so we should never be defining those 
macros to begin with); the algorithm remains general, we just drop the extra 
cruft from stdint.h. I don't think this should cause any issues.

CC @jrtc27 @jyknight for some extra opinions.

https://github.com/llvm/llvm-project/pull/71771
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [libc] [clang-tools-extra] [libcxx] [lldb] [llvm] [compiler-rt] [lld] [flang] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-30 Thread James Y Knight via lldb-commits


@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};

jyknight wrote:

No objection from my side for removing the weird sizes from Clang's stdint.h. I 
also doubt anyone's using it at all, but if they are, they can request a revert.

https://github.com/llvm/llvm-project/pull/71771
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [libc] [clang-tools-extra] [libcxx] [lldb] [llvm] [compiler-rt] [lld] [flang] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-30 Thread Jessica Clarke via lldb-commits


@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};

jrtc27 wrote:

FreeBSD patches out Clang’s stdint.h and uses its own, which doesn’t have any 
of those peculiar types

https://github.com/llvm/llvm-project/pull/71771
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang-tools-extra] [clang] [llvm] [libc] [compiler-rt] [lld] [flang] [lldb] [libcxx] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-30 Thread Jessica Clarke via lldb-commits

https://github.com/jrtc27 edited https://github.com/llvm/llvm-project/pull/71771
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [lld] [libcxx] [llvm] [clang] [lldb] [libc] [clang-tools-extra] [flang] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-30 Thread Aaron Ballman via lldb-commits


@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};

AaronBallman wrote:

Excellent, thank you (all) for the feedback! It sounds like we've got consensus 
on a direction to move forward after this patch is finished.

https://github.com/llvm/llvm-project/pull/71771
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [compiler-rt] [lld] [libc] [libcxx] [llvm] [flang] [clang-tools-extra] [clang] [libunwind] [libcxxabi] [AMDGPU] Add test for GCNRegPressure tracker bug (PR #73786)

2023-11-30 Thread Piotr Sobczak via lldb-commits

https://github.com/piotrAMD closed 
https://github.com/llvm/llvm-project/pull/73786
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [lldb] [llvm] [clang-tools-extra] [libc] [libcxx] [clang] [lld] [flang] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-30 Thread James Y Knight via lldb-commits


@@ -484,6 +484,26 @@ bool 
clang::analyze_format_string::parseFormatStringHasFormattingSpecifiers(
   return false;
 }
 
+ArgType clang::analyze_format_string::wToArgType(
+int size, bool fast, ASTContext &C) {
+  ArgType fastType = C.getTargetInfo().getTriple().isArch64Bit() ? 
C.LongLongTy : C.IntTy;

jyknight wrote:

It's actually quite a mess right now...

We currently have TargetInfo getIntTypeByWidth/getLeastIntTypeByWidth, but, no 
getFastIntTypeByWidth.

And this is a real problem...e.g. clang's stdint.h builtin-header goes through 
a ton of complexity to obfuscate that in fact it just ends up defining 
int_leastN_t and int_fastN_t as aliases to intN_t, on all platforms we support 
(which have all of 8/16/32/64-bit types available.)

But, clang's stdint.h defers to the libc's stdint.h if that exists, and e.g. on 
glibc, int_fast{16|32}_t are instead defined as int (32bit) or long (64bit). 

OK, fine...Except -- we ALSO define a bunch of preprocessor macros for the fast 
types in InitPreprocessor (e.g. `__INT_FAST16_TYPE__`. Which assume that fast 
== least. And, of course, these don't match the libc stdint.h's definitions...

And then there's the problem of which of 'long' vs 'long long' is used on 
various platforms, when both are 64-bit types.

I think we need to fix all that as a prerequisite. At that point, this code 
simply calls getFastIntTypeByWidth.

https://github.com/llvm/llvm-project/pull/71771
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [mlir] [llvm] [lld] [openmp] [lldb] [clang-tools-extra] [libunwind] [flang] [libcxxabi] [clang] [libc] [libcxx] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread Mariya Podchishchaeva via lldb-commits


@@ -14240,6 +14294,114 @@ StmtResult Sema::ActOnCXXForRangeIdentifier(Scope *S, 
SourceLocation IdentLoc,
   : IdentLoc);
 }
 
+static ImplicitConversionKind getConversionKind(QualType FromType,
+QualType ToType) {
+  if (ToType->isIntegerType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Integral;
+if (FromType->isIntegerType())
+  return ICK_Integral_Conversion;
+  }
+
+  if (ToType->isFloatingType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Conversion;
+if (FromType->isIntegerType())
+  return ICK_Floating_Integral;
+  }
+
+  return ICK_Identity;
+}
+
+static bool checkC23ConstexprInitConversion(Sema &S, const Expr *Init) {
+  assert(S.getLangOpts().C23);
+  const Expr *InitNoCast = Init->IgnoreImpCasts();
+  StandardConversionSequence SCS;
+  SCS.setAsIdentityConversion();
+  auto FromType = InitNoCast->getType();
+  auto ToType = Init->getType();
+  SCS.setToType(0, FromType);
+  SCS.setToType(1, ToType);
+  SCS.Second = getConversionKind(FromType, ToType);
+
+  APValue Value;
+  QualType PreNarrowingType;
+  // Reuse C++ narrowing check.
+  switch (SCS.getNarrowingKind(S.Context, Init, Value, PreNarrowingType,
+   /*IgnoreFloatToIntegralConversion*/ false)) {
+  // The value doesn't fit.
+  case NK_Constant_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_not_representable)
+<< Value.getAsString(S.Context, PreNarrowingType) << ToType;
+return true;
+
+  // Conversion to a narrower type.
+  case NK_Type_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_type_mismatch)
+<< ToType << FromType;
+return true;
+
+  // Since we only reuse narrowing check for C23 constexpr variables here, 
we're
+  // not really interested in these cases.
+  case NK_Dependent_Narrowing:
+  case NK_Variable_Narrowing:
+  case NK_Not_Narrowing:
+return false;
+  }
+  llvm_unreachable("unhandled case in switch");
+}
+
+static bool checkC23ConstexprInitStringLiteral(const StringLiteral *SE,
+   Sema &SemaRef,
+   SourceLocation Loc) {
+  assert(SemaRef.getLangOpts().C23);
+  // String literals have the target type attached but underneath may contain
+  // values that don't really fit into the target type. Check that every
+  // character fits.
+  const ConstantArrayType *CAT =
+  SemaRef.Context.getAsConstantArrayType(SE->getType());
+  QualType CharType = CAT->getElementType();
+  uint32_t BitWidth = SemaRef.Context.getTypeSize(CharType);
+  bool isUnsigned = CharType->isUnsignedIntegerType();
+  llvm::APSInt Value(BitWidth, isUnsigned);
+  const StringRef S = SE->getBytes();
+  for (unsigned I = 0, N = SE->getLength(); I != N; ++I) {
+Value = S[I];
+if (Value != S[I]) {
+  SemaRef.Diag(Loc, diag::err_c23_constexpr_init_not_representable)
+  << S[I] << CharType;

Fznamznon wrote:

I would prefer adding a new function then, since returning an `int64` from 
`getCodeUnit` breaks several tests related to printing string literals in 
diagnostic and ast dumps.

https://github.com/llvm/llvm-project/pull/73099
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang-tools-extra] [libunwind] [openmp] [compiler-rt] [flang] [libcxxabi] [lld] [llvm] [mlir] [libc] [libcxx] [lldb] [clang] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread Mariya Podchishchaeva via lldb-commits


@@ -14240,6 +14294,114 @@ StmtResult Sema::ActOnCXXForRangeIdentifier(Scope *S, 
SourceLocation IdentLoc,
   : IdentLoc);
 }
 
+static ImplicitConversionKind getConversionKind(QualType FromType,
+QualType ToType) {
+  if (ToType->isIntegerType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Integral;
+if (FromType->isIntegerType())
+  return ICK_Integral_Conversion;
+  }
+
+  if (ToType->isFloatingType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Conversion;
+if (FromType->isIntegerType())
+  return ICK_Floating_Integral;
+  }
+
+  return ICK_Identity;
+}
+
+static bool checkC23ConstexprInitConversion(Sema &S, const Expr *Init) {
+  assert(S.getLangOpts().C23);
+  const Expr *InitNoCast = Init->IgnoreImpCasts();
+  StandardConversionSequence SCS;
+  SCS.setAsIdentityConversion();
+  auto FromType = InitNoCast->getType();
+  auto ToType = Init->getType();
+  SCS.setToType(0, FromType);
+  SCS.setToType(1, ToType);
+  SCS.Second = getConversionKind(FromType, ToType);
+
+  APValue Value;
+  QualType PreNarrowingType;
+  // Reuse C++ narrowing check.
+  switch (SCS.getNarrowingKind(S.Context, Init, Value, PreNarrowingType,
+   /*IgnoreFloatToIntegralConversion*/ false)) {
+  // The value doesn't fit.
+  case NK_Constant_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_not_representable)
+<< Value.getAsString(S.Context, PreNarrowingType) << ToType;
+return true;
+
+  // Conversion to a narrower type.
+  case NK_Type_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_type_mismatch)
+<< ToType << FromType;
+return true;
+
+  // Since we only reuse narrowing check for C23 constexpr variables here, 
we're
+  // not really interested in these cases.
+  case NK_Dependent_Narrowing:
+  case NK_Variable_Narrowing:
+  case NK_Not_Narrowing:
+return false;
+  }
+  llvm_unreachable("unhandled case in switch");
+}
+
+static bool checkC23ConstexprInitStringLiteral(const StringLiteral *SE,
+   Sema &SemaRef,
+   SourceLocation Loc) {
+  assert(SemaRef.getLangOpts().C23);
+  // String literals have the target type attached but underneath may contain
+  // values that don't really fit into the target type. Check that every
+  // character fits.
+  const ConstantArrayType *CAT =
+  SemaRef.Context.getAsConstantArrayType(SE->getType());
+  QualType CharType = CAT->getElementType();
+  uint32_t BitWidth = SemaRef.Context.getTypeSize(CharType);
+  bool isUnsigned = CharType->isUnsignedIntegerType();
+  llvm::APSInt Value(BitWidth, isUnsigned);
+  const StringRef S = SE->getBytes();
+  for (unsigned I = 0, N = SE->getLength(); I != N; ++I) {
+Value = S[I];
+if (Value != S[I]) {
+  SemaRef.Diag(Loc, diag::err_c23_constexpr_init_not_representable)
+  << S[I] << CharType;

Fznamznon wrote:

There is also `getStrDataAsUInt16` and `getStrDataAsUInt32`, do we need to 
reimplement these as well?

https://github.com/llvm/llvm-project/pull/73099
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-30 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/70996

>From b04c85dbed0b369e747aa2a3823789203156736b Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Wed, 18 Oct 2023 14:37:34 -0700
Subject: [PATCH 1/8] DEBUGINFOD based DWP acquisition for LLDB

Summary:
I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic 
downloading of
DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set 
to a
space delimited set of web servers, LLDB will try to use them as a last resort 
when
searching for DWP files. If you do *not* have that environment variable set, 
nothing
should be changed. There's also a setting, per Greg Clayton's request, that will
override the env variable, or can be used instead of the env var. This setting 
is the
reason for the additional API added to the llvm's Debuginfod library.

Test Plan:
Suggestions are welcome here. I should probably have some positive and negative 
tests,
but I wanted to get the diff up for people who have a clue what they're doing 
to rip it
to pieces before spending too much time validating my implementation.
---
 lldb/include/lldb/Target/Target.h |  3 +++
 lldb/source/Core/CoreProperties.td|  2 +-
 lldb/source/Core/Debugger.cpp |  5 
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  1 +
 lldb/source/Symbol/CMakeLists.txt |  1 +
 lldb/source/Target/Target.cpp | 19 +-
 lldb/source/Target/TargetProperties.td|  4 +++
 llvm/include/llvm/Debuginfod/Debuginfod.h |  4 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++-
 9 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a03859f..7f10f0409fb1315 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -258,6 +258,8 @@ class TargetProperties : public Properties {
 
   bool GetDebugUtilityExpression() const;
 
+  Args GetDebugInfoDURLs() const;
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();
@@ -270,6 +272,7 @@ class TargetProperties : public Properties {
   void DisableASLRValueChangedCallback();
   void InheritTCCValueChangedCallback();
   void DisableSTDIOValueChangedCallback();
+  void DebugInfoDURLsChangedCallback();
 
   // Settings checker for target.jit-save-objects-dir:
   void CheckJITObjectsDir();
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 92884258347e9be..865030b0133bbb2 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -4,7 +4,7 @@ let Definition = "modulelist" in {
   def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">,
 Global,
 DefaultTrue,
-Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched.">;
+Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched. If all other methods fail, and 
the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol 
is used to acquire symbols from a compatible Debuginfod service.">;
   def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">,
 Global,
 DefaultFalse,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 21f71e449ca5ed0..9a3e82f3e6a2adf 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -61,6 +61,8 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
+#include "llvm/Debuginfod/Debuginfod.h"
+#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Process.h"
@@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() 
const {
 void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) {
   assert(g_debugger_list_ptr == nullptr &&
  "Debugger::Initialize called more than once!");
+  // We might be using the Debuginfod service, s

[Lldb-commits] [flang] [libcxx] [libcxxabi] [lldb] [llvm] [libunwind] [clang-tools-extra] [openmp] [clang] [lld] [Clang][Sema] Don't say "is declared here" for invalid template locations (PR #71264)

2023-11-30 Thread Justin Bogner via lldb-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/71264

>From cab6bcd73081fcbe9807adbf60b345f8d9e654e4 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 3 Nov 2023 18:59:49 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   3 +-
 clang/lib/Sema/SemaInit.cpp   |   3 +-
 clang/lib/Sema/SemaLambda.cpp |   3 +-
 clang/lib/Sema/SemaTemplate.cpp   | 123 --
 clang/lib/Sema/SemaType.cpp   |   3 +-
 .../test/SemaHLSL/BuiltIns/vector-errors.hlsl |   5 -
 7 files changed, 89 insertions(+), 53 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 396566a8f10a9b7..a86c428c9121abf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5929,7 +5929,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) 
{
   Diag(Name.StartLocation,
diag::err_deduction_guide_name_not_class_template)
 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
-  if (Template)
+  if (Template && Template->getLocation().isValid())
 Diag(Template->getLocation(), diag::note_template_decl_here);
   return DeclarationNameInfo();
 }
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 397b7a00e453126..de5cc07f5d42865 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11462,7 +11462,8 @@ bool Sema::CheckDeductionGuideDeclarator(Declarator &D, 
QualType &R,
   GuidedTemplateDecl->getDeclContext()->getRedeclContext())) {
 Diag(D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
   << GuidedTemplateDecl;
-Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
+if (GuidedTemplateDecl->getLocation().isValid())
+  Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
   }
 
   auto &DS = D.getMutableDeclSpec();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ed02d3580f34f9a..0952b065d56b58e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10575,7 +10575,8 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
  diag::err_deduced_non_class_template_specialization_type)
   << (int)getTemplateNameKindForDiagnostics(TemplateName) << TemplateName;
 if (auto *TD = TemplateName.getAsTemplateDecl())
-  Diag(TD->getLocation(), diag::note_template_decl_here);
+  if (TD->getLocation().isValid())
+Diag(TD->getLocation(), diag::note_template_decl_here);
 return QualType();
   }
 
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index ca09b0481bcac76..603b7465323e237 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1444,7 +1444,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer 
&Intro,
   for (const auto &Capture : Intro.Captures) {
 if (Capture.Id == TP->getIdentifier()) {
   Diag(Capture.Loc, diag::err_template_param_shadow) << Capture.Id;
-  Diag(TP->getLocation(), diag::note_template_param_here);
+  if (TP->getLocation().isValid())
+Diag(TP->getLocation(), diag::note_template_param_here);
 }
   }
 }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ee354862212803f..1a6eaa196db09be 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -872,7 +872,7 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation 
PointOfInstantiation,
   Note = diag::note_explicit_instantiation_here;
 }
   }
-  if (Note) // Diagnostics were emitted.
+  if (Note && Pattern->getLocation().isValid()) // Diagnostics were emitted.
 Diag(Pattern->getLocation(), *Note);
 
   // In general, Instantiation isn't marked invalid to get more than one
@@ -899,7 +899,8 @@ void Sema::DiagnoseTemplateParameterShadow(SourceLocation 
Loc, Decl *PrevDecl) {
   unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
  : diag::err_template_param_shadow;
   Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
-  Diag(PrevDecl->getLocation(), diag::note_template_param_here);
+  if (PrevDecl->getLocation().isValid())
+Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
@@ -4434,7 +4435,8 @@ static void checkMoreSpecializedThanPrimary(Sema &S, 
PartialSpecDecl *Partial) {
   << SFINAEArgString;
   }
 
-  S.Diag(Template->getLocation(), diag::note_template_decl_here);
+  if (Template->getLocation().isValid

[Lldb-commits] [flang] [libcxx] [lldb] [libc] [llvm] [libunwind] [clang] [lld] [clang][NFC] Refactor expected directives in C++ DRs 1-99 (PR #73879)

2023-11-30 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/73879
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Allow lldb to load .dwp files with large .debug_info or .debug_types. (PR #73736)

2023-11-30 Thread Greg Clayton via lldb-commits

clayborg wrote:

The original patch that added the ability for the CU and TU indexes being able 
to exceed 4GB was this:
https://reviews.llvm.org/D137882

https://github.com/llvm/llvm-project/pull/73736
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang-tools-extra] [lld] [clang] [openmp] [mlir] [lldb] [llvm] [flang] [libunwind] [libcxx] [libc] [libcxxabi] [Clang][Sema] Don't say "is declared here" for invalid template locations

2023-11-30 Thread Justin Bogner via lldb-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/71264

>From cab6bcd73081fcbe9807adbf60b345f8d9e654e4 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 3 Nov 2023 18:59:49 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   3 +-
 clang/lib/Sema/SemaInit.cpp   |   3 +-
 clang/lib/Sema/SemaLambda.cpp |   3 +-
 clang/lib/Sema/SemaTemplate.cpp   | 123 --
 clang/lib/Sema/SemaType.cpp   |   3 +-
 .../test/SemaHLSL/BuiltIns/vector-errors.hlsl |   5 -
 7 files changed, 89 insertions(+), 53 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 396566a8f10a9b7..a86c428c9121abf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5929,7 +5929,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) 
{
   Diag(Name.StartLocation,
diag::err_deduction_guide_name_not_class_template)
 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
-  if (Template)
+  if (Template && Template->getLocation().isValid())
 Diag(Template->getLocation(), diag::note_template_decl_here);
   return DeclarationNameInfo();
 }
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 397b7a00e453126..de5cc07f5d42865 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11462,7 +11462,8 @@ bool Sema::CheckDeductionGuideDeclarator(Declarator &D, 
QualType &R,
   GuidedTemplateDecl->getDeclContext()->getRedeclContext())) {
 Diag(D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
   << GuidedTemplateDecl;
-Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
+if (GuidedTemplateDecl->getLocation().isValid())
+  Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
   }
 
   auto &DS = D.getMutableDeclSpec();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ed02d3580f34f9a..0952b065d56b58e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10575,7 +10575,8 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
  diag::err_deduced_non_class_template_specialization_type)
   << (int)getTemplateNameKindForDiagnostics(TemplateName) << TemplateName;
 if (auto *TD = TemplateName.getAsTemplateDecl())
-  Diag(TD->getLocation(), diag::note_template_decl_here);
+  if (TD->getLocation().isValid())
+Diag(TD->getLocation(), diag::note_template_decl_here);
 return QualType();
   }
 
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index ca09b0481bcac76..603b7465323e237 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1444,7 +1444,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer 
&Intro,
   for (const auto &Capture : Intro.Captures) {
 if (Capture.Id == TP->getIdentifier()) {
   Diag(Capture.Loc, diag::err_template_param_shadow) << Capture.Id;
-  Diag(TP->getLocation(), diag::note_template_param_here);
+  if (TP->getLocation().isValid())
+Diag(TP->getLocation(), diag::note_template_param_here);
 }
   }
 }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ee354862212803f..1a6eaa196db09be 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -872,7 +872,7 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation 
PointOfInstantiation,
   Note = diag::note_explicit_instantiation_here;
 }
   }
-  if (Note) // Diagnostics were emitted.
+  if (Note && Pattern->getLocation().isValid()) // Diagnostics were emitted.
 Diag(Pattern->getLocation(), *Note);
 
   // In general, Instantiation isn't marked invalid to get more than one
@@ -899,7 +899,8 @@ void Sema::DiagnoseTemplateParameterShadow(SourceLocation 
Loc, Decl *PrevDecl) {
   unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
  : diag::err_template_param_shadow;
   Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
-  Diag(PrevDecl->getLocation(), diag::note_template_param_here);
+  if (PrevDecl->getLocation().isValid())
+Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
@@ -4434,7 +4435,8 @@ static void checkMoreSpecializedThanPrimary(Sema &S, 
PartialSpecDecl *Partial) {
   << SFINAEArgString;
   }
 
-  S.Diag(Template->getLocation(), diag::note_template_decl_here);
+  if (Template->getLocation().isValid

[Lldb-commits] [libc] [clang] [lld] [lldb] [clang-tools-extra] [flang] [libcxx] [libcxxabi] [llvm] [flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (PR #73254)

2023-11-30 Thread Daniel Chen via lldb-commits

DanielCChen wrote:

The changes look good to me. I will wait a day to see if other reviewers have 
any more comments before approving it.

https://github.com/llvm/llvm-project/pull/73254
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d1bf194 - Send an explicit interrupt to cancel an attach waitfor. (#72565)

2023-11-30 Thread via lldb-commits

Author: jimingham
Date: 2023-11-30T09:48:04-08:00
New Revision: d1bf1947e4e4f3ef75f2ba3ac9aa77dc38214de1

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

LOG: Send an explicit interrupt to cancel an attach waitfor. (#72565)

Currently when you interrupt a:

(lldb) process attach -w -n some_process

lldb just closes the connection to the stub and kills the
lldb_private::Process it made for the attach. The stub at the other end
notices the connection go down and exits because of that. But when
communication to a device is handled through some kind of proxy server
which isn't as well behaved as one would wish, that signal might not be
reliable, causing debugserver to persist on the machine, waiting to
steal the next instance of that process.

We can work around those failures by sending an explicit interrupt
before closing down the connection. The stub will also have to be
waiting for the interrupt for this to make any difference. I changed
debugserver to do that.

I didn't make the equivalent change in lldb-server. So long as you
aren't faced with a flakey connection, this should not be necessary.

Added: 
lldb/test/API/python_api/process/cancel_attach/TestCancelAttach.py

Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Process.cpp
lldb/tools/debugserver/source/DNB.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index e653ef5d8ac54e4..9648f1fd52cf7cc 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2371,8 +2371,10 @@ Status ProcessGDBRemote::DoHalt(bool &caused_stop) {
   Status error;
 
   if (m_public_state.GetValue() == eStateAttaching) {
-// We are being asked to halt during an attach. We need to just close our
-// file handle and debugserver will go away, and we can be done...
+// We are being asked to halt during an attach. We used to just close our
+// file handle and debugserver will go away, but with remote proxies, it
+// is better to send a positive signal, so let's send the interrupt 
first...
+caused_stop = m_gdb_comm.Interrupt(GetInterruptTimeout());
 m_gdb_comm.Disconnect();
   } else
 caused_stop = m_gdb_comm.Interrupt(GetInterruptTimeout());

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 21b80b8240ab64b..f3da2839e262e23 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -3156,8 +3156,8 @@ Status Process::Halt(bool clear_thread_plans, bool 
use_run_lock) {
 // Don't hijack and eat the eStateExited as the code that was doing the
 // attach will be waiting for this event...
 RestoreProcessEvents();
-SetExitStatus(SIGKILL, "Cancelled async attach.");
 Destroy(false);
+SetExitStatus(SIGKILL, "Cancelled async attach.");
 return Status();
   }
 
@@ -3843,6 +3843,13 @@ thread_result_t Process::RunPrivateStateThread(bool 
is_secondary_thread) {
   ") woke up with an interrupt while attaching - "
   "forwarding interrupt.",
   __FUNCTION__, static_cast(this), GetID());
+// The server may be spinning waiting for a process to appear, in which
+// case we should tell it to stop doing that.  Normally, we don't NEED
+// to do that because we will next close the communication to the stub
+// and that will get it to shut down.  But there are remote debugging
+// cases where relying on that side-effect causes the shutdown to be 
+// flakey, so we should send a positive signal to interrupt the wait. 
+Status error = HaltPrivate();
 BroadcastEvent(eBroadcastBitInterrupt, nullptr);
   } else if (StateIsRunningState(m_last_broadcast_state)) {
 LLDB_LOGF(log,

diff  --git 
a/lldb/test/API/python_api/process/cancel_attach/TestCancelAttach.py 
b/lldb/test/API/python_api/process/cancel_attach/TestCancelAttach.py
new file mode 100644
index 000..9172c3d333fd1bd
--- /dev/null
+++ b/lldb/test/API/python_api/process/cancel_attach/TestCancelAttach.py
@@ -0,0 +1,57 @@
+"""
+Test using SendAsyncInterrupt to interrupt an "attach wait"
+"""
+
+import lldb
+import sys
+import time
+import threading
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil
+
+
+class AttachCancelTestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_scripted_implementation(self):
+"""Test that cancelling a stuck "attach waitfor" works."""
+# First make an empty target for the attach:
+target = self.dbg.CreateTarget

[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)

2023-11-30 Thread via lldb-commits

https://github.com/jimingham closed 
https://github.com/llvm/llvm-project/pull/72565
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/69516

>From 004e0e6a8a09b34bdc694ca7eb5ef02483693e5f Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 18 Oct 2023 13:07:51 -0700
Subject: [PATCH] [lldb][progress] Add discrete boolean flag to progress
 reports

This commit adds a boolean flag `is_discrete` is to progress reports in
LLDB. The flag is set to false by default and indicates if a progress event is 
discrete, i.e. an
operation that has no clear start and end and can happen multiple times
during the course of a debug session. Operations that happen
in this manner will report multiple individual progress events as they
happen, so this flag gives the functionality to group multiple progress
events so they can be reported in a less haphazard manner.
---
 lldb/include/lldb/Core/Debugger.h |  8 +-
 lldb/include/lldb/Core/DebuggerEvents.h   | 11 ++--
 lldb/include/lldb/Core/Progress.h | 28 ++-
 lldb/source/Core/Debugger.cpp | 17 ++-
 lldb/source/Core/DebuggerEvents.cpp   |  1 +
 lldb/source/Core/Progress.cpp |  9 +++---
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp |  3 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |  2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  6 ++--
 lldb/source/Symbol/LocateSymbolFile.cpp   |  8 --
 .../TestProgressReporting.py  | 13 +++--
 11 files changed, 82 insertions(+), 24 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 5532cace606bfed..462c033e88af623 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -615,10 +615,16 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
+  ///
+  ///  \param [in] report_type
+  ///   Indicates whether the operation for which this progress reporting is
+  ///   reporting on will happen as an aggregate of multiple individual
+  ///   progress reports or not.
   static void ReportProgress(uint64_t progress_id, std::string title,
  std::string details, uint64_t completed,
  uint64_t total,
- std::optional debugger_id);
+ std::optional debugger_id,
+ Progress::ProgressReportType report_type);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 982b9701f89..dc933c47dcf53f0 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility/StructuredData.h"
 
@@ -21,10 +22,11 @@ class Stream;
 class ProgressEventData : public EventData {
 public:
   ProgressEventData(uint64_t progress_id, std::string title, std::string 
update,
-uint64_t completed, uint64_t total, bool debugger_specific)
+uint64_t completed, uint64_t total, bool debugger_specific,
+Progress::ProgressReportType report_type)
   : m_title(std::move(title)), m_details(std::move(update)),
 m_id(progress_id), m_completed(completed), m_total(total),
-m_debugger_specific(debugger_specific) {}
+m_debugger_specific(debugger_specific), m_report_type(report_type) {}
 
   static llvm::StringRef GetFlavorString();
 
@@ -52,6 +54,10 @@ class ProgressEventData : public EventData {
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }
   bool IsDebuggerSpecific() const { return m_debugger_specific; }
+  bool IsAggregate() const {
+return m_report_type ==
+   Progress::ProgressReportType::eAggregateProgressReport;
+  }
 
 private:
   /// The title of this progress event. The value is expected to remain stable
@@ -68,6 +74,7 @@ class ProgressEventData : public EventData {
   uint64_t m_completed;
   const uint64_t m_total;
   const bool m_debugger_specific;
+  const Progress::ProgressReportType m_report_type;
   ProgressEventData(const ProgressEventData &) = delete;
   const ProgressEventData &operator=(const ProgressEventData &) = delete;
 };
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index b2b8781a43b0591..41343ce890ed887 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -55,6 +55,11 @@ namespace lldb_private {
 
 cla

[Lldb-commits] [flang] [libcxx] [clang] [libc] [libcxxabi] [lldb] [clang-tools-extra] [lld] [llvm] [flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (PR #73254)

2023-11-30 Thread Kiran Chandramohan via lldb-commits

https://github.com/kiranchandramohan approved this pull request.

LG.

https://github.com/llvm/llvm-project/pull/73254
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang-tools-extra] [llvm] [libcxxabi] [libc] [flang] [lld] [clang] [libcxx] [flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (PR #73254)

2023-11-30 Thread Kiran Chandramohan via lldb-commits

https://github.com/kiranchandramohan edited 
https://github.com/llvm/llvm-project/pull/73254
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang-tools-extra] [libcxx] [lld] [libcxxabi] [libc] [flang] [lldb] [llvm] [clang] [flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (PR #73254)

2023-11-30 Thread Kiran Chandramohan via lldb-commits


@@ -101,6 +101,8 @@ class CompilerInvocation : public CompilerInvocationBase {
 
   bool warnAsErr = false;
 
+  const char *argv0;

kiranchandramohan wrote:

Nit: This is probably obvious but will be good to add executable name as a 
comment above.

https://github.com/llvm/llvm-project/pull/73254
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang-tools-extra] [llvm] [libunwind] [mlir] [lld] [compiler-rt] [libc] [clang] [flang] [libcxx] [libcxxabi] [lldb] [openmp] [C23] Implement N3018: The constexpr specifier for object d

2023-11-30 Thread via lldb-commits


@@ -14240,6 +14294,114 @@ StmtResult Sema::ActOnCXXForRangeIdentifier(Scope *S, 
SourceLocation IdentLoc,
   : IdentLoc);
 }
 
+static ImplicitConversionKind getConversionKind(QualType FromType,
+QualType ToType) {
+  if (ToType->isIntegerType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Integral;
+if (FromType->isIntegerType())
+  return ICK_Integral_Conversion;
+  }
+
+  if (ToType->isFloatingType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Conversion;
+if (FromType->isIntegerType())
+  return ICK_Floating_Integral;
+  }
+
+  return ICK_Identity;
+}
+
+static bool checkC23ConstexprInitConversion(Sema &S, const Expr *Init) {
+  assert(S.getLangOpts().C23);
+  const Expr *InitNoCast = Init->IgnoreImpCasts();
+  StandardConversionSequence SCS;
+  SCS.setAsIdentityConversion();
+  auto FromType = InitNoCast->getType();
+  auto ToType = Init->getType();
+  SCS.setToType(0, FromType);
+  SCS.setToType(1, ToType);
+  SCS.Second = getConversionKind(FromType, ToType);
+
+  APValue Value;
+  QualType PreNarrowingType;
+  // Reuse C++ narrowing check.
+  switch (SCS.getNarrowingKind(S.Context, Init, Value, PreNarrowingType,
+   /*IgnoreFloatToIntegralConversion*/ false)) {
+  // The value doesn't fit.
+  case NK_Constant_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_not_representable)
+<< Value.getAsString(S.Context, PreNarrowingType) << ToType;
+return true;
+
+  // Conversion to a narrower type.
+  case NK_Type_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_type_mismatch)
+<< ToType << FromType;
+return true;
+
+  // Since we only reuse narrowing check for C23 constexpr variables here, 
we're
+  // not really interested in these cases.
+  case NK_Dependent_Narrowing:
+  case NK_Variable_Narrowing:
+  case NK_Not_Narrowing:
+return false;
+  }
+  llvm_unreachable("unhandled case in switch");
+}
+
+static bool checkC23ConstexprInitStringLiteral(const StringLiteral *SE,
+   Sema &SemaRef,
+   SourceLocation Loc) {
+  assert(SemaRef.getLangOpts().C23);
+  // String literals have the target type attached but underneath may contain
+  // values that don't really fit into the target type. Check that every
+  // character fits.
+  const ConstantArrayType *CAT =
+  SemaRef.Context.getAsConstantArrayType(SE->getType());
+  QualType CharType = CAT->getElementType();
+  uint32_t BitWidth = SemaRef.Context.getTypeSize(CharType);
+  bool isUnsigned = CharType->isUnsignedIntegerType();
+  llvm::APSInt Value(BitWidth, isUnsigned);
+  const StringRef S = SE->getBytes();
+  for (unsigned I = 0, N = SE->getLength(); I != N; ++I) {
+Value = S[I];
+if (Value != S[I]) {
+  SemaRef.Diag(Loc, diag::err_c23_constexpr_init_not_representable)
+  << S[I] << CharType;

cor3ntin wrote:

Yes, because `wchar_t` can be signed.

Here is something that might work and avoid duplicating half of `StringLiteral` 
with dubious casts:
Get the unsigned value, and manually do the two complement to sign cast using 
`APInt`.

```
int64_t V = str.getCodeUnit(I); 
if(str.isOrdinary() || str.isWide()) {
Width W = str.getCharByteWidth();
APInt  apint(str.getCharByteWidth(), (uint64_t)V);
apint.sext(Width + 1).trunc(Width);
V = apint.getExtValue();
}
```

the `sext` idea credit of @erichkeane . I haven't tested it though.



https://github.com/llvm/llvm-project/pull/73099
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang-tools-extra] [libc] [lld] [openmp] [libcxx] [clang] [lldb] [llvm] [flang] [libcxxabi] [mlir] [libunwind] [Clang][Sema] Don't say "is declared here" for invalid template locations

2023-11-30 Thread via lldb-commits


@@ -7909,6 +7903,37 @@ bool 
Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param,
  Arg.getLocation());
 }
 
+static Sema::SemaDiagnosticBuilder noteLocation(Sema &S, const NamedDecl &Decl,
+unsigned HereDiagID,
+unsigned ExternalDiagID) {
+  if (Decl.getLocation().isValid())
+return S.Diag(Decl.getLocation(), HereDiagID);
+
+  SmallString<128> Str;
+  llvm::raw_svector_ostream Out(Str);
+  PrintingPolicy PP = S.getPrintingPolicy();
+  PP.TerseOutput = 1;
+  Decl.print(Out, PP);
+  return S.Diag(Decl.getLocation(), ExternalDiagID) << Out.str();

cor3ntin wrote:

Why not `<< Decl` directly?

https://github.com/llvm/llvm-project/pull/71264
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/69516

>From 83ca6c8e94ded4378b4c0cd067aaeca1d92719d0 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 18 Oct 2023 13:07:51 -0700
Subject: [PATCH] [lldb][progress] Add discrete boolean flag to progress
 reports

This commit adds a boolean flag `is_discrete` is to progress reports in
LLDB. The flag is set to false by default and indicates if a progress event is 
discrete, i.e. an
operation that has no clear start and end and can happen multiple times
during the course of a debug session. Operations that happen
in this manner will report multiple individual progress events as they
happen, so this flag gives the functionality to group multiple progress
events so they can be reported in a less haphazard manner.
---
 lldb/include/lldb/Core/Debugger.h |   8 +-
 lldb/include/lldb/Core/DebuggerEvents.h   |  11 +-
 lldb/include/lldb/Core/Progress.h |  28 +-
 lldb/source/Core/Debugger.cpp |  17 +-
 lldb/source/Core/DebuggerEvents.cpp   |   1 +
 lldb/source/Core/Progress.cpp |   9 +-
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 835 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |   6 +-
 .../TestProgressReporting.py  |  13 +-
 10 files changed, 503 insertions(+), 427 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index e4ee94809cf1a09..395ac09a965e05b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -618,10 +618,16 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
+  ///
+  ///  \param [in] report_type
+  ///   Indicates whether the operation for which this progress reporting is
+  ///   reporting on will happen as an aggregate of multiple individual
+  ///   progress reports or not.
   static void ReportProgress(uint64_t progress_id, std::string title,
  std::string details, uint64_t completed,
  uint64_t total,
- std::optional debugger_id);
+ std::optional debugger_id,
+ Progress::ProgressReportType report_type);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 982b9701f89..dc933c47dcf53f0 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility/StructuredData.h"
 
@@ -21,10 +22,11 @@ class Stream;
 class ProgressEventData : public EventData {
 public:
   ProgressEventData(uint64_t progress_id, std::string title, std::string 
update,
-uint64_t completed, uint64_t total, bool debugger_specific)
+uint64_t completed, uint64_t total, bool debugger_specific,
+Progress::ProgressReportType report_type)
   : m_title(std::move(title)), m_details(std::move(update)),
 m_id(progress_id), m_completed(completed), m_total(total),
-m_debugger_specific(debugger_specific) {}
+m_debugger_specific(debugger_specific), m_report_type(report_type) {}
 
   static llvm::StringRef GetFlavorString();
 
@@ -52,6 +54,10 @@ class ProgressEventData : public EventData {
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }
   bool IsDebuggerSpecific() const { return m_debugger_specific; }
+  bool IsAggregate() const {
+return m_report_type ==
+   Progress::ProgressReportType::eAggregateProgressReport;
+  }
 
 private:
   /// The title of this progress event. The value is expected to remain stable
@@ -68,6 +74,7 @@ class ProgressEventData : public EventData {
   uint64_t m_completed;
   const uint64_t m_total;
   const bool m_debugger_specific;
+  const Progress::ProgressReportType m_report_type;
   ProgressEventData(const ProgressEventData &) = delete;
   const ProgressEventData &operator=(const ProgressEventData &) = delete;
 };
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index b2b8781a43b0591..41343ce890ed887 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -55,6 +55,11 @@ namespace lldb_private {
 
 class Progress {
 public:
+  /// Enum that indicates the type of progress report
+ 

[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)

2023-11-30 Thread Michael Christensen via lldb-commits


@@ -1296,10 +1296,11 @@ enum CompletionType {
   eRemoteDiskFileCompletion = (1u << 22),
   eRemoteDiskDirectoryCompletion = (1u << 23),
   eTypeCategoryNameCompletion = (1u << 24),
+  eThreadIDCompletion = (1u << 25),

mdko wrote:

@clayborg Is there anything special about `eCustomCompletion` being last? The 
comment in 1300-1302 seems to allude to this, but I don't see anything in the 
code base requiring this nor any other custom completions.

https://github.com/llvm/llvm-project/pull/73596
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang-tools-extra] [llvm] [libunwind] [mlir] [lld] [libc] [clang] [flang] [libcxx] [libcxxabi] [lldb] [openmp] [Clang][Sema] Don't say "is declared here" for invalid template locations

2023-11-30 Thread Justin Bogner via lldb-commits


@@ -7909,6 +7903,37 @@ bool 
Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param,
  Arg.getLocation());
 }
 
+static Sema::SemaDiagnosticBuilder noteLocation(Sema &S, const NamedDecl &Decl,
+unsigned HereDiagID,
+unsigned ExternalDiagID) {
+  if (Decl.getLocation().isValid())
+return S.Diag(Decl.getLocation(), HereDiagID);
+
+  SmallString<128> Str;
+  llvm::raw_svector_ostream Out(Str);
+  PrintingPolicy PP = S.getPrintingPolicy();
+  PP.TerseOutput = 1;
+  Decl.print(Out, PP);
+  return S.Diag(Decl.getLocation(), ExternalDiagID) << Out.str();

bogner wrote:

Using `<< &Decl` here just gives the name. With print we get:
```
template declaration from hidden source: template  using vector = element 
__attribute__((ext_vector_type(element_count)))
template parameter from hidden source: class element = float
```
whereas with the stream operator it's
```
note: template declaration from hidden source: 'vector'
note: template parameter from hidden source: 'element'
```

Similarly in #71265 it's the difference between printing `template  class RWBuffer final` vs just `RWBuffer`

https://github.com/llvm/llvm-project/pull/71264
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)

2023-11-30 Thread Greg Clayton via lldb-commits


@@ -1296,10 +1296,11 @@ enum CompletionType {
   eRemoteDiskFileCompletion = (1u << 22),
   eRemoteDiskDirectoryCompletion = (1u << 23),
   eTypeCategoryNameCompletion = (1u << 24),
+  eThreadIDCompletion = (1u << 25),

clayborg wrote:

> @clayborg Is there anything special about `eCustomCompletion` being last? The 
> comment in 1300-1302 seems to allude to this, but I don't see anything in the 
> code base requiring this nor any other custom completions.

Yes, this is a problem. If there ever is a magic bit it should be something 
like:
```
eCustomCompletion = (1u << 63) // Pick the last bit in a 64 bit value
```
But this is public API now which causes a problem for reasons I mentioned 
before. @jimingham any ideas on if we care about adding the thread ID before 
the `eCustomCompletion` from an API standpoint? lldb-rpc-server is the main 
thing I worry about here since it sends enums as integers, not as strings which 
are then converted back into integers.

https://github.com/llvm/llvm-project/pull/73596
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-30 Thread David Goldman via lldb-commits

https://github.com/DavidGoldman closed 
https://github.com/llvm/llvm-project/pull/72292
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c8f7285 - [lldb-dap] Fixing a type encoding issue with dap Stopped events. (#72292)

2023-11-30 Thread via lldb-commits

Author: John Harrison
Date: 2023-11-30T15:17:12-05:00
New Revision: c8f72856dbdd0039fc16eae51726da105ea679c0

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

LOG: [lldb-dap] Fixing a type encoding issue with dap Stopped events. (#72292)

Previously the type of the breakpoint id in the Stopped event was a
uint64_t, however thats the wrong type for a breakpoint id, which can
cause encoding issues when internal breakpoints are hit.

Added: 


Modified: 
lldb/tools/lldb-dap/JSONUtils.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 03a43f9da87f241..3a63046d9a888bf 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -13,6 +13,7 @@
 #include 
 
 #include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -959,11 +960,10 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
&thread,
   EmplaceSafeString(body, "description", exc_bp->label);
 } else {
   body.try_emplace("reason", "breakpoint");
-  char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
-   bp_id, bp_loc_id);
+  lldb::break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+  lldb::break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+  std::string desc_str =
+  llvm::formatv("breakpoint {0}.{1}", bp_id, bp_loc_id);
   body.try_emplace("hitBreakpointIds",
llvm::json::Array{llvm::json::Value(bp_id)});
   EmplaceSafeString(body, "description", desc_str);



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


[Lldb-commits] [lldb] [lldb] Remove pre GCC 4.8 workaround (PR #73981)

2023-11-30 Thread Brad Smith via lldb-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/73981

The minimum GCC version was bumped up from 4.8 to 5.1 and then even newer
awhile ago so garbage collect the pre 4.8 workaround.

https://reviews.llvm.org/D66188

>From a79e4d06f16e2460c7521874c13370022bbb5952 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Thu, 30 Nov 2023 15:20:27 -0500
Subject: [PATCH] [lldb] Remove pre GCC 4.8 workaround

The minimum GCC version was bumped up from 4.8 to 5.1 and then even newer
awhile ago so garbage collect the pre 4.8 workaround.

https://reviews.llvm.org/D66188
---
 lldb/source/Host/common/Host.cpp | 4 
 1 file changed, 4 deletions(-)

diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 49eac0b0fa7b0c6..8314d3581f6a47f 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -133,11 +133,7 @@ class ScopedPThreadCancelDisabler {
 #endif // __linux__
 
 #ifdef __linux__
-#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 
8))
-static __thread volatile sig_atomic_t g_usr1_called;
-#else
 static thread_local volatile sig_atomic_t g_usr1_called;
-#endif
 
 static void SigUsr1Handler(int) { g_usr1_called = 1; }
 #endif // __linux__

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


[Lldb-commits] [lldb] [lldb] Remove pre GCC 4.8 workaround (PR #73981)

2023-11-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Brad Smith (brad0)


Changes

The minimum GCC version was bumped up from 4.8 to 5.1 and then even newer
awhile ago so garbage collect the pre 4.8 workaround.

https://reviews.llvm.org/D66188

---
Full diff: https://github.com/llvm/llvm-project/pull/73981.diff


1 Files Affected:

- (modified) lldb/source/Host/common/Host.cpp (-4) 


``diff
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 49eac0b0fa7b0c6..8314d3581f6a47f 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -133,11 +133,7 @@ class ScopedPThreadCancelDisabler {
 #endif // __linux__
 
 #ifdef __linux__
-#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 
8))
-static __thread volatile sig_atomic_t g_usr1_called;
-#else
 static thread_local volatile sig_atomic_t g_usr1_called;
-#endif
 
 static void SigUsr1Handler(int) { g_usr1_called = 1; }
 #endif // __linux__

``




https://github.com/llvm/llvm-project/pull/73981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Alex Langford via lldb-commits


@@ -1451,7 +1451,8 @@ static lldb::SectionType GetSectionType(uint32_t flags,
   static ConstString g_sect_name_dwarf_debug_line_str("__debug_line_str");
   static ConstString g_sect_name_dwarf_debug_loc("__debug_loc");
   static ConstString g_sect_name_dwarf_debug_loclists("__debug_loclists");
-  static ConstString 
g_sect_name_dwarf_debug_loclists_dwo("__debug_loclists.dwo");
+  static ConstString g_sect_name_dwarf_debug_loclists_dwo(
+  "__debug_loclists.dwo");

bulbazord wrote:

Is this change (and the one below it) related?

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Alex Langford via lldb-commits

https://github.com/bulbazord edited 
https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Alex Langford via lldb-commits

https://github.com/bulbazord requested changes to this pull request.

There looks to be a ton of unrelated changes in ObjectFileMachO.cpp. Mostly 
formatting from what I can tell. Please revert to preserve blame history.

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove pre GCC 4.8 workaround (PR #73981)

2023-11-30 Thread Alex Langford via lldb-commits

https://github.com/bulbazord approved this pull request.

LGTM

>From the look of it, it looks like the minimum version of GCC that is 
>currently supported is 7.1. (See: 
>`llvm/cmake/modules/CheckCompilerVersion.cmake`)

https://github.com/llvm/llvm-project/pull/73981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Greg Clayton via lldb-commits


@@ -63,13 +68,30 @@ class Progress {
   ///
   /// @param [in] title The title of this progress activity.
   ///
+  /// @param [in] report_type Enum value indicating how the progress is being
+  /// reported. Progress reports considered "aggregate" are reports done for
+  /// operations that may happen multiple times during a debug session.
+  ///
+  /// For example, when a debug session is first started it needs to parse the
+  /// symbol tables for all files that were initially included and this
+  /// operation will deliver progress reports. If new dSYMs are added later
+  /// during the session then these will also be parsed and deliver more
+  /// progress reports. This type of operation would use the
+  /// eAggregateProgressReport enum. Using this enum would allow these progress
+  /// reports to be grouped together as one, even though their reports are
+  /// happening individually.
+  ///
   /// @param [in] total The total units of work to be done if specified, if
   /// set to UINT64_MAX then an indeterminate progress indicator should be
   /// displayed.
   ///
   /// @param [in] debugger An optional debugger pointer to specify that this
   /// progress is to be reported only to specific debuggers.
-  Progress(std::string title, uint64_t total = UINT64_MAX,
+  ///
+  Progress(std::string title,
+   ProgressReportType report_type =
+   ProgressReportType::eNonAggregateProgressReport,

clayborg wrote:

As long as `enum class ProgressReportType` can't implicitly convert an integer 
to a `ProgressReportType` this is safe to switch the order of arguments that 
were defaulted before (`total`).

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Greg Clayton via lldb-commits


@@ -63,13 +68,30 @@ class Progress {
   ///
   /// @param [in] title The title of this progress activity.
   ///
+  /// @param [in] report_type Enum value indicating how the progress is being
+  /// reported. Progress reports considered "aggregate" are reports done for
+  /// operations that may happen multiple times during a debug session.
+  ///
+  /// For example, when a debug session is first started it needs to parse the
+  /// symbol tables for all files that were initially included and this
+  /// operation will deliver progress reports. If new dSYMs are added later
+  /// during the session then these will also be parsed and deliver more
+  /// progress reports. This type of operation would use the
+  /// eAggregateProgressReport enum. Using this enum would allow these progress
+  /// reports to be grouped together as one, even though their reports are
+  /// happening individually.
+  ///
   /// @param [in] total The total units of work to be done if specified, if
   /// set to UINT64_MAX then an indeterminate progress indicator should be
   /// displayed.
   ///
   /// @param [in] debugger An optional debugger pointer to specify that this
   /// progress is to be reported only to specific debuggers.
-  Progress(std::string title, uint64_t total = UINT64_MAX,
+  ///
+  Progress(std::string title,
+   ProgressReportType report_type =
+   ProgressReportType::eNonAggregateProgressReport,
+   uint64_t total = UINT64_MAX,

clayborg wrote:

Since we are modifying the API a bit, it might be nice to start using a 
`std::optional total` for the parameter and for the instance variable 
to make things clear and avoid people having to specify `UINT64_MAX` (they can 
use `std::nullopt`).

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Greg Clayton via lldb-commits


@@ -97,6 +119,10 @@ class Progress {
   /// The title of the progress activity.
   std::string m_title;
   std::mutex m_mutex;
+  /// Set to true if the progress event is aggregate; meaning it will happen
+  /// multiple times during a debug session as individual progress events

clayborg wrote:

comment is out of date, it mentions "Set to true ..."

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove pre GCC 4.8 workaround (PR #73981)

2023-11-30 Thread Brad Smith via lldb-commits

brad0 wrote:

> From the look of it, it looks like the minimum version of GCC that is 
> currently supported is 7.1. (See: 
> `llvm/cmake/modules/CheckCompilerVersion.cmake`)

It was 7.1, it is now 7.4.

https://reviews.llvm.org/D156286

https://github.com/llvm/llvm-project/pull/73981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Chelsea Cassanova via lldb-commits


@@ -1451,7 +1451,8 @@ static lldb::SectionType GetSectionType(uint32_t flags,
   static ConstString g_sect_name_dwarf_debug_line_str("__debug_line_str");
   static ConstString g_sect_name_dwarf_debug_loc("__debug_loc");
   static ConstString g_sect_name_dwarf_debug_loclists("__debug_loclists");
-  static ConstString 
g_sect_name_dwarf_debug_loclists_dwo("__debug_loclists.dwo");
+  static ConstString g_sect_name_dwarf_debug_loclists_dwo(
+  "__debug_loclists.dwo");

chelcassanova wrote:

They aren't, giant formatting issue on my part.

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/69516

>From 417d99ff038517fed596ebf6605e203110e88e6f Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 18 Oct 2023 13:07:51 -0700
Subject: [PATCH] [lldb][progress] Add discrete boolean flag to progress
 reports

This commit adds a boolean flag `is_discrete` is to progress reports in
LLDB. The flag is set to false by default and indicates if a progress event is 
discrete, i.e. an
operation that has no clear start and end and can happen multiple times
during the course of a debug session. Operations that happen
in this manner will report multiple individual progress events as they
happen, so this flag gives the functionality to group multiple progress
events so they can be reported in a less haphazard manner.
---
 lldb/include/lldb/Core/Debugger.h |  8 +-
 lldb/include/lldb/Core/DebuggerEvents.h   | 11 ++--
 lldb/include/lldb/Core/Progress.h | 28 ++-
 lldb/source/Core/Debugger.cpp | 17 ++-
 lldb/source/Core/DebuggerEvents.cpp   |  1 +
 lldb/source/Core/Progress.cpp |  9 +++---
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp |  3 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |  2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  6 ++--
 .../TestProgressReporting.py  | 13 +++--
 10 files changed, 77 insertions(+), 21 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index e4ee94809cf1a09..395ac09a965e05b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -618,10 +618,16 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
+  ///
+  ///  \param [in] report_type
+  ///   Indicates whether the operation for which this progress reporting is
+  ///   reporting on will happen as an aggregate of multiple individual
+  ///   progress reports or not.
   static void ReportProgress(uint64_t progress_id, std::string title,
  std::string details, uint64_t completed,
  uint64_t total,
- std::optional debugger_id);
+ std::optional debugger_id,
+ Progress::ProgressReportType report_type);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 982b9701f89..dc933c47dcf53f0 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility/StructuredData.h"
 
@@ -21,10 +22,11 @@ class Stream;
 class ProgressEventData : public EventData {
 public:
   ProgressEventData(uint64_t progress_id, std::string title, std::string 
update,
-uint64_t completed, uint64_t total, bool debugger_specific)
+uint64_t completed, uint64_t total, bool debugger_specific,
+Progress::ProgressReportType report_type)
   : m_title(std::move(title)), m_details(std::move(update)),
 m_id(progress_id), m_completed(completed), m_total(total),
-m_debugger_specific(debugger_specific) {}
+m_debugger_specific(debugger_specific), m_report_type(report_type) {}
 
   static llvm::StringRef GetFlavorString();
 
@@ -52,6 +54,10 @@ class ProgressEventData : public EventData {
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }
   bool IsDebuggerSpecific() const { return m_debugger_specific; }
+  bool IsAggregate() const {
+return m_report_type ==
+   Progress::ProgressReportType::eAggregateProgressReport;
+  }
 
 private:
   /// The title of this progress event. The value is expected to remain stable
@@ -68,6 +74,7 @@ class ProgressEventData : public EventData {
   uint64_t m_completed;
   const uint64_t m_total;
   const bool m_debugger_specific;
+  const Progress::ProgressReportType m_report_type;
   ProgressEventData(const ProgressEventData &) = delete;
   const ProgressEventData &operator=(const ProgressEventData &) = delete;
 };
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index b2b8781a43b0591..41343ce890ed887 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -55,6 +55,11 @@ namespace lldb_private {
 
 class Progress {
 public:
+  /// Enum that indicates the type 

[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova edited 
https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Chelsea Cassanova via lldb-commits


@@ -97,6 +119,10 @@ class Progress {
   /// The title of the progress activity.
   std::string m_title;
   std::mutex m_mutex;
+  /// Set to true if the progress event is aggregate; meaning it will happen
+  /// multiple times during a debug session as individual progress events

chelcassanova wrote:

Noted, I'll change this 👍🏾 

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-30 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/70996

>From b04c85dbed0b369e747aa2a3823789203156736b Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Wed, 18 Oct 2023 14:37:34 -0700
Subject: [PATCH 1/9] DEBUGINFOD based DWP acquisition for LLDB

Summary:
I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic 
downloading of
DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set 
to a
space delimited set of web servers, LLDB will try to use them as a last resort 
when
searching for DWP files. If you do *not* have that environment variable set, 
nothing
should be changed. There's also a setting, per Greg Clayton's request, that will
override the env variable, or can be used instead of the env var. This setting 
is the
reason for the additional API added to the llvm's Debuginfod library.

Test Plan:
Suggestions are welcome here. I should probably have some positive and negative 
tests,
but I wanted to get the diff up for people who have a clue what they're doing 
to rip it
to pieces before spending too much time validating my implementation.
---
 lldb/include/lldb/Target/Target.h |  3 +++
 lldb/source/Core/CoreProperties.td|  2 +-
 lldb/source/Core/Debugger.cpp |  5 
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  1 +
 lldb/source/Symbol/CMakeLists.txt |  1 +
 lldb/source/Target/Target.cpp | 19 +-
 lldb/source/Target/TargetProperties.td|  4 +++
 llvm/include/llvm/Debuginfod/Debuginfod.h |  4 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++-
 9 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a03859f..7f10f0409fb1315 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -258,6 +258,8 @@ class TargetProperties : public Properties {
 
   bool GetDebugUtilityExpression() const;
 
+  Args GetDebugInfoDURLs() const;
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();
@@ -270,6 +272,7 @@ class TargetProperties : public Properties {
   void DisableASLRValueChangedCallback();
   void InheritTCCValueChangedCallback();
   void DisableSTDIOValueChangedCallback();
+  void DebugInfoDURLsChangedCallback();
 
   // Settings checker for target.jit-save-objects-dir:
   void CheckJITObjectsDir();
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 92884258347e9be..865030b0133bbb2 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -4,7 +4,7 @@ let Definition = "modulelist" in {
   def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">,
 Global,
 DefaultTrue,
-Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched.">;
+Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched. If all other methods fail, and 
the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol 
is used to acquire symbols from a compatible Debuginfod service.">;
   def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">,
 Global,
 DefaultFalse,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 21f71e449ca5ed0..9a3e82f3e6a2adf 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -61,6 +61,8 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
+#include "llvm/Debuginfod/Debuginfod.h"
+#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Process.h"
@@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() 
const {
 void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) {
   assert(g_debugger_list_ptr == nullptr &&
  "Debugger::Initialize called more than once!");
+  // We might be using the Debuginfod service, s

[Lldb-commits] [lldb] 162e4b8 - Include in WatchpointResource.h

2023-11-30 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-11-30T14:59:10-08:00
New Revision: 162e4b8c494459ea7509f598d15addd6ffc3dc9c

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

LOG: Include  in WatchpointResource.h

On macOS  was already included via another
header file, but this failed on the CI bots.  I'd
tested on linux earlier in this patch's life when
the headers were differently arranged.

(cherry picked from commit a0a1ff3ab40e347589b4e27d8fd350c600526735)

Added: 


Modified: 
lldb/include/lldb/Breakpoint/WatchpointResource.h

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/WatchpointResource.h 
b/lldb/include/lldb/Breakpoint/WatchpointResource.h
index e83ba0bbe8c6591..4b1d733850f1bbf 100644
--- a/lldb/include/lldb/Breakpoint/WatchpointResource.h
+++ b/lldb/include/lldb/Breakpoint/WatchpointResource.h
@@ -13,7 +13,7 @@
 #include "lldb/lldb-public.h"
 
 #include 
-#include 
+#include 
 
 namespace lldb_private {
 



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


[Lldb-commits] [lldb] 22f7264 - [lldb] try to fix build on linux after fc6b72523f3d7

2023-11-30 Thread Jason Molenda via lldb-commits

Author: Nico Weber
Date: 2023-11-30T14:59:10-08:00
New Revision: 22f72642fe6cd8f049bc905e0f0a69243b650f89

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

LOG: [lldb] try to fix build on linux after fc6b72523f3d7

Tries to fix:

../../lldb/source/Breakpoint/WatchpointResource.cpp:59:12:
error: no member named 'find' in namespace 'std'; did you mean 'fill'?
  std::find(m_constituents.begin(), m_constituents.end(), wp_sp);
  ~^~~~
   fill

(cherry picked from commit a6c62bf1a4717accc852463b664cd1012237d334)

Added: 


Modified: 
lldb/source/Breakpoint/WatchpointResource.cpp

Removed: 




diff  --git a/lldb/source/Breakpoint/WatchpointResource.cpp 
b/lldb/source/Breakpoint/WatchpointResource.cpp
index 4b8fbe42c865e25..d0f8dc346f3c024 100644
--- a/lldb/source/Breakpoint/WatchpointResource.cpp
+++ b/lldb/source/Breakpoint/WatchpointResource.cpp
@@ -10,6 +10,8 @@
 
 #include "lldb/Breakpoint/WatchpointResource.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 



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


[Lldb-commits] [lldb] 9e77d66 - Correctly disable hardware watchpoints after a fork event

2023-11-30 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-11-30T14:59:10-08:00
New Revision: 9e77d666d88d407a7705caa623f7bfc8dc90287d

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

LOG: Correctly disable hardware watchpoints after a fork event

Fix a failure on Linux system where follow-fork-mode
exists, which caused the large watchpoint NFC patch
to be reverted earlier this week.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index fb6715140492010..b04319703b9469a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -5546,7 +5546,7 @@ void ProcessGDBRemote::DidForkSwitchHardwareTraps(bool 
enable) {
 addr_t addr = wp_res_sp->GetLoadAddress();
 size_t size = wp_res_sp->GetByteSize();
 GDBStoppointType type = GetGDBStoppointType(wp_res_sp);
-m_gdb_comm.SendGDBStoppointTypePacket(type, true, addr, size,
+m_gdb_comm.SendGDBStoppointTypePacket(type, enable, addr, size,
   GetInterruptTimeout());
   }
 }



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


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-11-30 Thread Chelsea Cassanova via lldb-commits


@@ -63,13 +68,30 @@ class Progress {
   ///
   /// @param [in] title The title of this progress activity.
   ///
+  /// @param [in] report_type Enum value indicating how the progress is being
+  /// reported. Progress reports considered "aggregate" are reports done for
+  /// operations that may happen multiple times during a debug session.
+  ///
+  /// For example, when a debug session is first started it needs to parse the
+  /// symbol tables for all files that were initially included and this
+  /// operation will deliver progress reports. If new dSYMs are added later
+  /// during the session then these will also be parsed and deliver more
+  /// progress reports. This type of operation would use the
+  /// eAggregateProgressReport enum. Using this enum would allow these progress
+  /// reports to be grouped together as one, even though their reports are
+  /// happening individually.
+  ///
   /// @param [in] total The total units of work to be done if specified, if
   /// set to UINT64_MAX then an indeterminate progress indicator should be
   /// displayed.
   ///
   /// @param [in] debugger An optional debugger pointer to specify that this
   /// progress is to be reported only to specific debuggers.
-  Progress(std::string title, uint64_t total = UINT64_MAX,
+  ///
+  Progress(std::string title,
+   ProgressReportType report_type =
+   ProgressReportType::eNonAggregateProgressReport,
+   uint64_t total = UINT64_MAX,

chelcassanova wrote:

Yes, that would be much cleaner for future usage, I'll change `total` to use a 
`std::optional`

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [flang] [libcxx] [libunwind] [libc] [llvm] [clang] [lld] [lldb] [clang-tools-extra] [compiler-rt] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-30 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/71771

>From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 9 Nov 2023 02:21:46 +
Subject: [PATCH 1/3] Fix clang to recognize new C23 modifiers %w and %wf when
 printing

---
 clang/include/clang/AST/FormatString.h | 16 +++-
 clang/lib/AST/FormatString.cpp | 52 +-
 clang/lib/AST/PrintfFormatString.cpp   | 19 ++
 clang/test/Sema/format-strings-ms.c| 28 ++
 4 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/FormatString.h 
b/clang/include/clang/AST/FormatString.h
index 5c4ad9baaef608c..6a886854650f1d9 100644
--- a/clang/include/clang/AST/FormatString.h
+++ b/clang/include/clang/AST/FormatString.h
@@ -81,8 +81,10 @@ class LengthModifier {
 AsLongDouble, // 'L'
 AsAllocate,   // for '%as', GNU extension to C90 scanf
 AsMAllocate,  // for '%ms', GNU extension to scanf
-AsWide,   // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
-AsWideChar = AsLong // for '%ls', only makes sense for printf
+AsWide,   // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on 
windows
+  // 2. for b, d, i, o, u, x, or X when a size followed(like 
8, 16, 32 or 64)
+AsWideFast,   // 'wf' (for b, d, i, o, u, x, or X)
+AsWideChar = AsLong, // for '%ls', only makes sense for printf
   };
 
   LengthModifier()
@@ -417,6 +419,7 @@ class FormatSpecifier {
   ///  http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
   bool UsesPositionalArg;
   unsigned argIndex;
+  unsigned size;
 public:
   FormatSpecifier(bool isPrintf)
 : CS(isPrintf), VectorNumElts(false),
@@ -460,6 +463,15 @@ class FormatSpecifier {
 FieldWidth = Amt;
   }
 
+  void setSize(unsigned s) {
+size = s;
+  }
+
+  unsigned getSize() const {
+return size;
+  }
+
+
   bool usesPositionalArg() const { return UsesPositionalArg; }
 
   bool hasValidLengthModifier(const TargetInfo &Target,
diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index e0c9e18cfe3a243..ebc136e780717e4 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};
+if (supported_list.count(s) == 0) {
+  return false;
+}
+FS.setSize(s);
+  }
+
+  break;
   }
   LengthModifier lm(lmPosition, lmKind);
   FS.setLengthModifier(lm);
@@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const {
 return "m";
   case AsWide:
 return "w";
+  case AsWideFast:
+return "wf";
   case None:
 return "";
   }
@@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const 
TargetInfo &Target,
 case ConversionSpecifier::SArg:
 case ConversionSpecifier::ZArg:
   return Target.getTriple().isOSMSVCRT();
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
+default:
+  return false;
+  }
+case LengthModifier::AsWideFast:
+  switch (CS.getKind()) {
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
 default:
   return false;
   }
@@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const {
 case LengthModifier::AsInt3264:
 case LengthModifier::AsInt64:
 case LengthModifier::AsWide:
+case LengthModifier::AsWideFast:
 case LengthModifier::AsShortLong: // ???
   return false;
   }
diff --git a/clang/lib/AST/PrintfFormatString.cpp 
b/clang/lib/AST/PrintfFormatString.cpp
index f0b9d0ecaf23461..4b9111e8bcf509a 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/l

[Lldb-commits] [lldb] [lldb] Implement DiagnosticManager::Consume (PR #74011)

2023-11-30 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/74011

In some situations it may be useful to have a separate DiagnosticManager 
instance, and then later of move the contents of that instance back to the 
"main" DiagnosticManager. For example, when silently retrying some operation 
with different parameters, depending on whether the retry succeeded or failed, 
LLDB may want to present a different set of diagnostics to the user (the ones 
generated on the first try vs the retry). Implement DiagnosticManager::Consume 
to allow for this use case.

>From 7fdc9832d3a0c9024d867f8cdc35706d0a8b643e Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Wed, 29 Nov 2023 17:30:12 -0800
Subject: [PATCH] [NFC][lldb] Implement DiagnosticManager::Consume

In some situations it may be useful to have a separate DiagnosticManager
instance, and then later of move the contents of that instance back to
the "main" DiagnosticManager. For example, when silently retrying some
operation with different parameters, depending on whether the retry
succeeded or failed, LLDB may want to present a different set of
diagnostics to the user (the ones generated on the first try vs the
retry). Implement DiagnosticManager::Consume to allow for this use case.
---
 lldb/include/lldb/Expression/DiagnosticManager.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h 
b/lldb/include/lldb/Expression/DiagnosticManager.h
index df9ba3b245f51e8..06bf1d115f15419 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -118,6 +118,15 @@ class DiagnosticManager {
   m_diagnostics.push_back(std::move(diagnostic));
   }
 
+  /// Moves over the contents of a second diagnostic manager over. Leaves other
+  /// diagnostic manager in an empty state.
+  void Consume(DiagnosticManager &&other) {
+std::move(other.m_diagnostics.begin(), other.m_diagnostics.end(),
+  std::back_inserter(m_diagnostics));
+m_fixed_expression = std::move(other.m_fixed_expression);
+other.Clear();
+  }
+
   size_t Printf(DiagnosticSeverity severity, const char *format, ...)
   __attribute__((format(printf, 3, 4)));
   void PutString(DiagnosticSeverity severity, llvm::StringRef str);

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


[Lldb-commits] [lldb] [NFC][lldb] Implement DiagnosticManager::Consume (PR #74011)

2023-11-30 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 edited 
https://github.com/llvm/llvm-project/pull/74011
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [NFC][lldb] Implement DiagnosticManager::Consume (PR #74011)

2023-11-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)


Changes

In some situations it may be useful to have a separate DiagnosticManager 
instance, and then later of move the contents of that instance back to the 
"main" DiagnosticManager. For example, when silently retrying some operation 
with different parameters, depending on whether the retry succeeded or failed, 
LLDB may want to present a different set of diagnostics to the user (the ones 
generated on the first try vs the retry). Implement DiagnosticManager::Consume 
to allow for this use case.

---
Full diff: https://github.com/llvm/llvm-project/pull/74011.diff


1 Files Affected:

- (modified) lldb/include/lldb/Expression/DiagnosticManager.h (+9) 


``diff
diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h 
b/lldb/include/lldb/Expression/DiagnosticManager.h
index df9ba3b245f51e8..06bf1d115f15419 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -118,6 +118,15 @@ class DiagnosticManager {
   m_diagnostics.push_back(std::move(diagnostic));
   }
 
+  /// Moves over the contents of a second diagnostic manager over. Leaves other
+  /// diagnostic manager in an empty state.
+  void Consume(DiagnosticManager &&other) {
+std::move(other.m_diagnostics.begin(), other.m_diagnostics.end(),
+  std::back_inserter(m_diagnostics));
+m_fixed_expression = std::move(other.m_fixed_expression);
+other.Clear();
+  }
+
   size_t Printf(DiagnosticSeverity severity, const char *format, ...)
   __attribute__((format(printf, 3, 4)));
   void PutString(DiagnosticSeverity severity, llvm::StringRef str);

``




https://github.com/llvm/llvm-project/pull/74011
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] pipe2(2) is also supported by OpenBSD (PR #74012)

2023-11-30 Thread Brad Smith via lldb-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/74012

None

>From e3d6d0b6040516ee761c1b635093fd13244e9d2a Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Thu, 30 Nov 2023 19:17:53 -0500
Subject: [PATCH] [lldb] pipe2(2) is also supported by OpenBSD

---
 lldb/source/Host/posix/PipePosix.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Host/posix/PipePosix.cpp 
b/lldb/source/Host/posix/PipePosix.cpp
index c02869cbf4d73066..6fc4646953b4257d 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -32,7 +32,7 @@ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and 
WRITE
 // pipe2 is supported by a limited set of platforms
 // TODO: Add more platforms that support pipe2.
 #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) ||   
\
-defined(__NetBSD__)
+defined(__NetBSD__) || defined(__OpenBSD__)
 #define PIPE2_SUPPORTED 1
 #else
 #define PIPE2_SUPPORTED 0

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


[Lldb-commits] [lldb] [lldb] pipe2(2) is also supported by OpenBSD (PR #74012)

2023-11-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Brad Smith (brad0)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/74012.diff


1 Files Affected:

- (modified) lldb/source/Host/posix/PipePosix.cpp (+1-1) 


``diff
diff --git a/lldb/source/Host/posix/PipePosix.cpp 
b/lldb/source/Host/posix/PipePosix.cpp
index c02869cbf4d7306..6fc4646953b4257 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -32,7 +32,7 @@ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and 
WRITE
 // pipe2 is supported by a limited set of platforms
 // TODO: Add more platforms that support pipe2.
 #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) ||   
\
-defined(__NetBSD__)
+defined(__NetBSD__) || defined(__OpenBSD__)
 #define PIPE2_SUPPORTED 1
 #else
 #define PIPE2_SUPPORTED 0

``




https://github.com/llvm/llvm-project/pull/74012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] pipe2(2) is also supported by OpenBSD (PR #74012)

2023-11-30 Thread Alex Langford via lldb-commits

https://github.com/bulbazord approved this pull request.

If [this man page](https://man.openbsd.org/pipe2) is to be believed, this seems 
alright to do.

https://github.com/llvm/llvm-project/pull/74012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Make use of LD_LIBRARY_PATH on OpenBSD (PR #74017)

2023-11-30 Thread Brad Smith via lldb-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/74017

None

>From adf0027c83805290dd259b8f431c91a19c15955a Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Thu, 30 Nov 2023 20:14:22 -0500
Subject: [PATCH] [lldb] Make use of LD_LIBRARY_PATH on OpenBSD

---
 lldb/packages/Python/lldbsuite/test/lldbplatformutil.py | 2 +-
 lldb/test/API/lit.cfg.py| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 4b58ab3814626c4..1966153415fe1fb 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -173,7 +173,7 @@ def __init__(
 def createPlatformContext():
 if platformIsDarwin():
 return _PlatformContext("DYLD_LIBRARY_PATH", ":", "lib", "dylib")
-elif getPlatform() in ("freebsd", "linux", "netbsd"):
+elif getPlatform() in ("linux", "freebsd", "netbsd", "openbsd"):
 return _PlatformContext("LD_LIBRARY_PATH", ":", "lib", "so")
 else:
 return _PlatformContext("PATH", ";", "", "dll")
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 8b35e8b2a217cf7..12675edc0fd3b9e 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -45,7 +45,7 @@ def find_sanitizer_runtime(name):
 
 
 def find_shlibpath_var():
-if platform.system() in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
+if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]:
 yield "LD_LIBRARY_PATH"
 elif platform.system() == "Darwin":
 yield "DYLD_LIBRARY_PATH"

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


[Lldb-commits] [lldb] [lldb] Make use of LD_LIBRARY_PATH on OpenBSD (PR #74017)

2023-11-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Brad Smith (brad0)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/74017.diff


2 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbplatformutil.py (+1-1) 
- (modified) lldb/test/API/lit.cfg.py (+1-1) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 4b58ab3814626c4..1966153415fe1fb 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -173,7 +173,7 @@ def __init__(
 def createPlatformContext():
 if platformIsDarwin():
 return _PlatformContext("DYLD_LIBRARY_PATH", ":", "lib", "dylib")
-elif getPlatform() in ("freebsd", "linux", "netbsd"):
+elif getPlatform() in ("linux", "freebsd", "netbsd", "openbsd"):
 return _PlatformContext("LD_LIBRARY_PATH", ":", "lib", "so")
 else:
 return _PlatformContext("PATH", ";", "", "dll")
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 8b35e8b2a217cf7..12675edc0fd3b9e 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -45,7 +45,7 @@ def find_sanitizer_runtime(name):
 
 
 def find_shlibpath_var():
-if platform.system() in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
+if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]:
 yield "LD_LIBRARY_PATH"
 elif platform.system() == "Darwin":
 yield "DYLD_LIBRARY_PATH"

``




https://github.com/llvm/llvm-project/pull/74017
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] pipe2(2) is also supported by OpenBSD (PR #74012)

2023-11-30 Thread Brad Smith via lldb-commits

brad0 wrote:

> If [this man page](https://man.openbsd.org/pipe2) is to be believed, this 
> seems alright to do.

Yes, that is correct. 8+ years ago / 18 releases ago at 5.7.

https://github.com/llvm/llvm-project/pull/74012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] pipe2(2) is also supported by OpenBSD (PR #74012)

2023-11-30 Thread Brad Smith via lldb-commits

https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/74012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Simplify pipe2(2) handling on FreeBSD (PR #74019)

2023-11-30 Thread Brad Smith via lldb-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/74019

FreeBSD 10.x and 11.x support has been dropped leaving 12.x as the minimum 
version. This FreeBSD check can be simplified.

https://github.com/llvm/llvm-project/commit/812dad536ed50abe94d6e2b2519f351791c24c59

>From 7209d0ac47c64a3fa0d55cfd645e332fa5054884 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Thu, 30 Nov 2023 20:22:50 -0500
Subject: [PATCH] [lldb] Simplify pipe2(2) handling on FreeBSD

FreeBSD 10.x and 11.x support has been dropped leaving 12.x as the
minimum version. This FreeBSD check can be simplified.

https://github.com/llvm/llvm-project/commit/812dad536ed50abe94d6e2b2519f351791c24c59
---
 lldb/source/Host/posix/PipePosix.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Host/posix/PipePosix.cpp 
b/lldb/source/Host/posix/PipePosix.cpp
index 6fc4646953b4257d..afd3fe39059ac176 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -31,8 +31,8 @@ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and 
WRITE
 
 // pipe2 is supported by a limited set of platforms
 // TODO: Add more platforms that support pipe2.
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) ||   
\
-defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
 #define PIPE2_SUPPORTED 1
 #else
 #define PIPE2_SUPPORTED 0

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


[Lldb-commits] [lldb] [lldb] Simplify pipe2(2) handling on FreeBSD (PR #74019)

2023-11-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Brad Smith (brad0)


Changes

FreeBSD 10.x and 11.x support has been dropped leaving 12.x as the minimum 
version. This FreeBSD check can be simplified.

https://github.com/llvm/llvm-project/commit/812dad536ed50abe94d6e2b2519f351791c24c59

---
Full diff: https://github.com/llvm/llvm-project/pull/74019.diff


1 Files Affected:

- (modified) lldb/source/Host/posix/PipePosix.cpp (+2-2) 


``diff
diff --git a/lldb/source/Host/posix/PipePosix.cpp 
b/lldb/source/Host/posix/PipePosix.cpp
index 6fc4646953b4257..afd3fe39059ac17 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -31,8 +31,8 @@ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and 
WRITE
 
 // pipe2 is supported by a limited set of platforms
 // TODO: Add more platforms that support pipe2.
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) ||   
\
-defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
 #define PIPE2_SUPPORTED 1
 #else
 #define PIPE2_SUPPORTED 0

``




https://github.com/llvm/llvm-project/pull/74019
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/test] Add OpenBSD to _get_platform_os (PR #74036)

2023-11-30 Thread Brad Smith via lldb-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/74036

None

>From 260de5f42f3216321349ff316ff800c5fa2c60f9 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Thu, 30 Nov 2023 23:07:45 -0500
Subject: [PATCH] [lldb/test] Add OpenBSD to _get_platform_os

---
 lldb/packages/Python/lldbsuite/test/lldbplatformutil.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 4b58ab3814626c4..37d06f7e88f98ca 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -108,6 +108,8 @@ def _get_platform_os(p):
 platform = "freebsd"
 elif platform.startswith("netbsd"):
 platform = "netbsd"
+elif platform.startswith("openbsd"):
+platform = "openbsd"
 return platform
 
 return ""

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


[Lldb-commits] [lldb] [lldb/test] Add OpenBSD to _get_platform_os (PR #74036)

2023-11-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Brad Smith (brad0)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/74036.diff


1 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbplatformutil.py (+2) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 4b58ab3814626c4..37d06f7e88f98ca 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -108,6 +108,8 @@ def _get_platform_os(p):
 platform = "freebsd"
 elif platform.startswith("netbsd"):
 platform = "netbsd"
+elif platform.startswith("openbsd"):
+platform = "openbsd"
 return platform
 
 return ""

``




https://github.com/llvm/llvm-project/pull/74036
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove pre GCC 4.8 workaround (PR #73981)

2023-11-30 Thread Brad Smith via lldb-commits

https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/73981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a37c69e - [lldb] Remove pre GCC 4.8 workaround (#73981)

2023-11-30 Thread via lldb-commits

Author: Brad Smith
Date: 2023-11-30T23:14:46-05:00
New Revision: a37c69ec315b9526a3532022be3ebe1af9ca356a

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

LOG: [lldb] Remove pre GCC 4.8 workaround (#73981)

The minimum GCC version was bumped up from 4.8 to 5.1 and then even newer
awhile ago so garbage collect the pre 4.8 workaround.

https://reviews.llvm.org/D66188

Added: 


Modified: 
lldb/source/Host/common/Host.cpp

Removed: 




diff  --git a/lldb/source/Host/common/Host.cpp 
b/lldb/source/Host/common/Host.cpp
index 49eac0b0fa7b0c6..8314d3581f6a47f 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -133,11 +133,7 @@ class ScopedPThreadCancelDisabler {
 #endif // __linux__
 
 #ifdef __linux__
-#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 
8))
-static __thread volatile sig_atomic_t g_usr1_called;
-#else
 static thread_local volatile sig_atomic_t g_usr1_called;
-#endif
 
 static void SigUsr1Handler(int) { g_usr1_called = 1; }
 #endif // __linux__



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


[Lldb-commits] [libcxx] [compiler-rt] [openmp] [libc] [lld] [libunwind] [clang-tools-extra] [clang] [libcxxabi] [llvm] [mlir] [lldb] [flang] Fix Logical expression used for merged conditional if in Fl

2023-11-30 Thread via lldb-commits

https://github.com/mahtohappy updated 
https://github.com/llvm/llvm-project/pull/72522

Sorry, this diff is unavailable.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [mlir] [llvm] [lldb] [libcxx] [clang-tools-extra] [libc] [clang] [openmp] [compiler-rt] [libunwind] [flang] [lld] [libcxxabi] Fix Logical expression used for merged conditional if in Fl

2023-11-30 Thread Matt Arsenault via lldb-commits


@@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 {
 entry:
   %cmp0 = icmp eq i32 %in_a, -1
   %cmp1 = icmp ne i32 %in_a, 0
-  %cond0 = and i1 %cmp0, %cmp1
+  %cond0 = or i1 %cmp0, %cmp1

arsenm wrote:

Original tests still changing? Needs new copies 

https://github.com/llvm/llvm-project/pull/72522
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits