[Lldb-commits] [lldb] [lldb][Test] TestDataFormatterLibcxxChrono.py: skip test on older clang versions (PR #70544)

2023-10-28 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/70544

These tests were failing on the LLDB public matrix build-bots for older clang 
versions:
```
clang-7: warning: argument unused during compilation: '-nostdlib++' 
[-Wunused-command-line-argument]
error: invalid value 'c++20' in '-std=c++20'
note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU 
extensions' standard
note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' 
standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' 
standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' 
standard
note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' 
standard
make: *** [main.o] Error 1
```

The test fails because we try to compile it with `-std=c++20` (which is 
required for std::chrono::{days,weeks,months,years}) on clang versions that 
don't support the `-std=c++20` flag.

We could change the test to conditionally compile the C++20 parts of the test 
based on the `-std=` flag and have two versions of the python tests, one for 
the C++11 chrono features and one for the C++20 features.

This patch instead just disables the test on older clang versions (because it's 
simpler and we don't really lose important coverage).

>From af4fdfe9ad6376423752abb7b4f5a216e35e41cc Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Sat, 28 Oct 2023 08:58:11 +0100
Subject: [PATCH] [lldb][Test] TestDataFormatterLibcxxChrono.py: skip test on
 older clang versions

These tests were failing on the LLDB public matrix build-bots
for older clang versions:
```
clang-7: warning: argument unused during compilation: '-nostdlib++' 
[-Wunused-command-line-argument]
error: invalid value 'c++20' in '-std=c++20'
note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU 
extensions' standard
note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' 
standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' 
standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' 
standard
note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' 
standard
make: *** [main.o] Error 1
```

The test fails because we try to compile it with `-std=c++20` (which is
required for std::chrono::{days,weeks,months,years}) on clang versions
that don't support the `-std=c++20` flag.

We could change the test to conditionally compile the C++20 parts of the
test based on the `-std=` flag and have two versions of the python tests,
one for the C++11 chrono features and one for the C++20 features.

This patch instead just disables the test on older clang versions
(because it's simpler and we don't really lose important coverage).
---
 .../libcxx/chrono/TestDataFormatterLibcxxChrono.py   | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
index 076b0d07b88aec7..b2f86817f3b0e8f 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
@@ -11,6 +11,7 @@
 
 class LibcxxChronoDataFormatterTestCase(TestBase):
 @add_test_categories(["libc++"])
+@skipIf(compiler="clang", compiler_version=["<", "11.0"])
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()

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


[Lldb-commits] [PATCH] D159127: [lldb][libc++] Adds chrono data formatters.

2023-10-28 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

In D159127#4655450 , @aprantl wrote:

> @Mordante @Michael137  This seems to fail on older versions of 
> compiler/libcxx 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-matrix/7247/ You 
> can probably fix this by just requiring a minimum clang version in the tests

https://github.com/llvm/llvm-project/pull/70544


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159127

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


[Lldb-commits] [lldb] [lldb][Test] TestDataFormatterLibcxxChrono.py: skip test on older clang versions (PR #70544)

2023-10-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

These tests were failing on the LLDB public matrix build-bots for older clang 
versions:
```
clang-7: warning: argument unused during compilation: '-nostdlib++' 
[-Wunused-command-line-argument]
error: invalid value 'c++20' in '-std=c++20'
note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU 
extensions' standard
note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' 
standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' 
standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' 
standard
note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' 
standard
make: *** [main.o] Error 1
```

The test fails because we try to compile it with `-std=c++20` (which is 
required for std::chrono::{days,weeks,months,years}) on clang versions that 
don't support the `-std=c++20` flag.

We could change the test to conditionally compile the C++20 parts of the test 
based on the `-std=` flag and have two versions of the python tests, one for 
the C++11 chrono features and one for the C++20 features.

This patch instead just disables the test on older clang versions (because it's 
simpler and we don't really lose important coverage).

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


1 Files Affected:

- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
 (+1) 


``diff
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
index 076b0d07b88aec7..b2f86817f3b0e8f 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
@@ -11,6 +11,7 @@
 
 class LibcxxChronoDataFormatterTestCase(TestBase):
 @add_test_categories(["libc++"])
+@skipIf(compiler="clang", compiler_version=["<", "11.0"])
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()

``




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


[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70551)

2023-10-28 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/70551

>From e02939572877cdc839894454a6fab36ab143d924 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 27 Oct 2023 16:33:07 +0100
Subject: [PATCH 1/3] [clang][DebugInfo][NFC] Add createConstantValueExpression
 helper

This patch factors out the code to create a DIExpression from
an APValue into a separate helper function.

This will be useful in a follow-up patch where we re-use this
logic elsewhere.
---
 clang/lib/CodeGen/CGDebugInfo.cpp | 44 ++-
 clang/lib/CodeGen/CGDebugInfo.h   |  5 
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index c430713b0d77d79..a109f140cca80c8 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5574,25 +5574,8 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl 
*VD, const APValue &Init) {
   auto &GV = DeclCache[VD];
   if (GV)
 return;
-  llvm::DIExpression *InitExpr = nullptr;
-  if (CGM.getContext().getTypeSize(VD->getType()) <= 64) {
-// FIXME: Add a representation for integer constants wider than 64 bits.
-if (Init.isInt()) {
-  const llvm::APSInt &InitInt = Init.getInt();
-  std::optional InitIntOpt;
-  if (InitInt.isUnsigned())
-InitIntOpt = InitInt.tryZExtValue();
-  else if (auto tmp = InitInt.trySExtValue(); tmp.has_value())
-// Transform a signed optional to unsigned optional. When cpp 23 comes,
-// use std::optional::transform
-InitIntOpt = (uint64_t)tmp.value();
-  if (InitIntOpt)
-InitExpr = DBuilder.createConstantValueExpression(InitIntOpt.value());
-} else if (Init.isFloat())
-  InitExpr = DBuilder.createConstantValueExpression(
-  Init.getFloat().bitcastToAPInt().getZExtValue());
-  }
 
+  llvm::DIExpression *InitExpr = createConstantValueExpression(VD, Init);
   llvm::MDTuple *TemplateParameters = nullptr;
 
   if (isa(VD))
@@ -5929,3 +5912,28 @@ llvm::DINode::DIFlags 
CGDebugInfo::getCallSiteRelatedAttrs() const {
 
   return llvm::DINode::FlagAllCallsDescribed;
 }
+
+llvm::DIExpression *
+CGDebugInfo::createConstantValueExpression(clang::ValueDecl const *VD,
+   const APValue &Val) {
+  llvm::DIExpression *ValExpr = nullptr;
+  if (CGM.getContext().getTypeSize(VD->getType()) <= 64) {
+// FIXME: Add a representation for integer constants wider than 64 bits.
+if (Val.isInt()) {
+  const llvm::APSInt &ValInt = Val.getInt();
+  std::optional ValIntOpt;
+  if (ValInt.isUnsigned())
+ValIntOpt = ValInt.tryZExtValue();
+  else if (auto tmp = ValInt.trySExtValue(); tmp.has_value())
+// Transform a signed optional to unsigned optional. When cpp 23 comes,
+// use std::optional::transform
+ValIntOpt = (uint64_t)tmp.value();
+  if (ValIntOpt)
+ValExpr = DBuilder.createConstantValueExpression(ValIntOpt.value());
+} else if (Val.isFloat())
+  ValExpr = DBuilder.createConstantValueExpression(
+  Val.getFloat().bitcastToAPInt().getZExtValue());
+  }
+
+  return ValExpr;
+}
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index ae12485850ca775..7b60e94555d0608 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -800,6 +800,11 @@ class CGDebugInfo {
llvm::MDTuple *&TemplateParameters,
llvm::DIScope *&VDContext);
 
+  /// Create a DIExpression representing the constant corresponding
+  /// to the specified 'Val'. Returns nullptr on failure.
+  llvm::DIExpression *createConstantValueExpression(const clang::ValueDecl *VD,
+const APValue &Val);
+
   /// Allocate a copy of \p A using the DebugInfoNames allocator
   /// and return a reference to it. If multiple arguments are given the strings
   /// are concatenated.

>From 119276638095f48d8d2a5dd8fc7e042059e66378 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 27 Oct 2023 16:19:47 +0100
Subject: [PATCH 2/3] [clang][DebugInfo] Emit global variable definitions for
 static data members with constant initializers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When an LLDB user asks for the value of a static data member, LLDB starts by
searching the Names accelerator table for the corresponding variable definition
DIE. For static data members with out-of-class definitions that works fine,
because those get represented as global variables with a location and making 
them
eligible to be added to the Names table. However, in-class definitions won’t get
indexed because we usually don't emit global variables for them. So in DWARF
we end up with a single `DW_TAG_member` that usually holds the constant 
initializer.
But we don't get a corresponding CU-level `DW_TAG_

[Lldb-commits] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70551)

2023-10-28 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/70551

>From e02939572877cdc839894454a6fab36ab143d924 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 27 Oct 2023 16:33:07 +0100
Subject: [PATCH 1/4] [clang][DebugInfo][NFC] Add createConstantValueExpression
 helper

This patch factors out the code to create a DIExpression from
an APValue into a separate helper function.

This will be useful in a follow-up patch where we re-use this
logic elsewhere.
---
 clang/lib/CodeGen/CGDebugInfo.cpp | 44 ++-
 clang/lib/CodeGen/CGDebugInfo.h   |  5 
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index c430713b0d77d79..a109f140cca80c8 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5574,25 +5574,8 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl 
*VD, const APValue &Init) {
   auto &GV = DeclCache[VD];
   if (GV)
 return;
-  llvm::DIExpression *InitExpr = nullptr;
-  if (CGM.getContext().getTypeSize(VD->getType()) <= 64) {
-// FIXME: Add a representation for integer constants wider than 64 bits.
-if (Init.isInt()) {
-  const llvm::APSInt &InitInt = Init.getInt();
-  std::optional InitIntOpt;
-  if (InitInt.isUnsigned())
-InitIntOpt = InitInt.tryZExtValue();
-  else if (auto tmp = InitInt.trySExtValue(); tmp.has_value())
-// Transform a signed optional to unsigned optional. When cpp 23 comes,
-// use std::optional::transform
-InitIntOpt = (uint64_t)tmp.value();
-  if (InitIntOpt)
-InitExpr = DBuilder.createConstantValueExpression(InitIntOpt.value());
-} else if (Init.isFloat())
-  InitExpr = DBuilder.createConstantValueExpression(
-  Init.getFloat().bitcastToAPInt().getZExtValue());
-  }
 
+  llvm::DIExpression *InitExpr = createConstantValueExpression(VD, Init);
   llvm::MDTuple *TemplateParameters = nullptr;
 
   if (isa(VD))
@@ -5929,3 +5912,28 @@ llvm::DINode::DIFlags 
CGDebugInfo::getCallSiteRelatedAttrs() const {
 
   return llvm::DINode::FlagAllCallsDescribed;
 }
+
+llvm::DIExpression *
+CGDebugInfo::createConstantValueExpression(clang::ValueDecl const *VD,
+   const APValue &Val) {
+  llvm::DIExpression *ValExpr = nullptr;
+  if (CGM.getContext().getTypeSize(VD->getType()) <= 64) {
+// FIXME: Add a representation for integer constants wider than 64 bits.
+if (Val.isInt()) {
+  const llvm::APSInt &ValInt = Val.getInt();
+  std::optional ValIntOpt;
+  if (ValInt.isUnsigned())
+ValIntOpt = ValInt.tryZExtValue();
+  else if (auto tmp = ValInt.trySExtValue(); tmp.has_value())
+// Transform a signed optional to unsigned optional. When cpp 23 comes,
+// use std::optional::transform
+ValIntOpt = (uint64_t)tmp.value();
+  if (ValIntOpt)
+ValExpr = DBuilder.createConstantValueExpression(ValIntOpt.value());
+} else if (Val.isFloat())
+  ValExpr = DBuilder.createConstantValueExpression(
+  Val.getFloat().bitcastToAPInt().getZExtValue());
+  }
+
+  return ValExpr;
+}
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index ae12485850ca775..7b60e94555d0608 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -800,6 +800,11 @@ class CGDebugInfo {
llvm::MDTuple *&TemplateParameters,
llvm::DIScope *&VDContext);
 
+  /// Create a DIExpression representing the constant corresponding
+  /// to the specified 'Val'. Returns nullptr on failure.
+  llvm::DIExpression *createConstantValueExpression(const clang::ValueDecl *VD,
+const APValue &Val);
+
   /// Allocate a copy of \p A using the DebugInfoNames allocator
   /// and return a reference to it. If multiple arguments are given the strings
   /// are concatenated.

>From 119276638095f48d8d2a5dd8fc7e042059e66378 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 27 Oct 2023 16:19:47 +0100
Subject: [PATCH 2/4] [clang][DebugInfo] Emit global variable definitions for
 static data members with constant initializers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When an LLDB user asks for the value of a static data member, LLDB starts by
searching the Names accelerator table for the corresponding variable definition
DIE. For static data members with out-of-class definitions that works fine,
because those get represented as global variables with a location and making 
them
eligible to be added to the Names table. However, in-class definitions won’t get
indexed because we usually don't emit global variables for them. So in DWARF
we end up with a single `DW_TAG_member` that usually holds the constant 
initializer.
But we don't get a corresponding CU-level `DW_TAG_