[Lldb-commits] [lldb] 60a7188 - [lldb][test] TestInlineNamespaceAlias.py: skip on older compiler versions

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

Author: Michael Buch
Date: 2023-03-10T12:20:58Z
New Revision: 60a7188cb086abe172bc46582356f30b3c3e1c4c

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

LOG: [lldb][test] TestInlineNamespaceAlias.py: skip on older compiler versions

This was failing with versions of clang that didn't support the
dsymutil (D143458) and llvm (D143397) changes that are needed for this test.

Remove unused parameters that we tried passing for the `dwarf` variant, which
is an NFC change. LLDB doesn't yet support `-gdwarf-5` debugging yet so
passing it to the `Makefile` would actually cause the test to fail.

Added: 


Modified: 

lldb/test/API/commands/expression/namespace-alias/TestInlineNamespaceAlias.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/namespace-alias/TestInlineNamespaceAlias.py 
b/lldb/test/API/commands/expression/namespace-alias/TestInlineNamespaceAlias.py
index 0c3f3d457f254..5220a6e0099cd 100644
--- 
a/lldb/test/API/commands/expression/namespace-alias/TestInlineNamespaceAlias.py
+++ 
b/lldb/test/API/commands/expression/namespace-alias/TestInlineNamespaceAlias.py
@@ -11,7 +11,8 @@
 from lldbsuite.test import lldbutil
 
 class TestInlineNamespace(TestBase):
-def do_test(self, params):
+@skipIf(compiler="clang", compiler_version=['<', '16.0'])
+def test(self):
 self.build()
 
 lldbutil.run_to_source_breakpoint(self,
@@ -27,11 +28,3 @@ def do_test(self, params):
 self.expect_expr("E::D::a", result_type="int", result_value="-1")
 self.expect_expr("F::a", result_type="int", result_value="-1")
 self.expect_expr("G::a", result_type="int", result_value="-1")
-
-@skipIf(debug_info=no_match(["dsym"]))
-def test_dsym(self):
-self.do_test({})
-
-@skipIf(debug_info="dsym")
-def test_dwarf(self):
-self.do_test(dict(CFLAGS_EXTRAS="-gdwarf-5 -gpubnames"))



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


[Lldb-commits] [PATCH] D145078: [WIP][lldb][DWARFASTParserClang] Support DW_AT_LLVM_preferred_name attribute

2023-03-10 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a reviewer: shafik.
Herald added a project: All.
Michael137 updated this revision to Diff 502692.
Michael137 added a comment.
Michael137 updated this revision to Diff 502694.
Michael137 updated this revision to Diff 504098.
Michael137 published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

- Add tests


Michael137 added a comment.

- Revert redundant change


Michael137 added a comment.

- Clean up patch


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145078

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Symbol/Type.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  lldb/test/API/lang/cpp/preferred_name/Makefile
  lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
  lldb/test/API/lang/cpp/preferred_name/main.cpp

Index: lldb/test/API/lang/cpp/preferred_name/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/main.cpp
@@ -0,0 +1,25 @@
+template  struct Foo;
+
+typedef Foo BarInt;
+typedef Foo BarDouble;
+
+template  using Bar = Foo;
+
+template 
+struct [[clang::preferred_name(BarInt), clang::preferred_name(BarDouble),
+ clang::preferred_name(Bar), clang::preferred_name(Bar),
+ clang::preferred_name(Bar),
+ clang::preferred_name(Bar)]] Foo{};
+
+int main() {
+  BarInt varInt;
+  BarDouble varDouble;
+  Bar varShort;
+  Bar varChar;
+
+  Foo varInt;
+  Foo varDouble;
+  Foo varShort;
+  Foo varChar;
+  return 0;
+}
Index: lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
@@ -0,0 +1,40 @@
+"""
+Test formatting of types annotated with
+[[clang::preferred_name]] attributes.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+
+class TestPreferredName(TestBase):
+
+def test_frame_var(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
+
+self.expect("frame variable barInt", substrs=["BarInt"])
+self.expect("frame variable barDouble", substrs=["BarDouble"])
+self.expect("frame variable barShort", substrs=["Bar"])
+self.expect("frame variable barChar", substrs=["Bar"])
+
+self.expect("frame variable varInt", substrs=["BarInt"])
+self.expect("frame variable varDouble", substrs=["BarDouble"])
+self.expect("frame variable varShort", substrs=["Bar"])
+self.expect("frame variable varChar", substrs=["Bar"])
+
+def test_expr(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("barInt", result_type="BarInt")
+self.expect_expr("barDouble", result_type="BarDouble")
+self.expect_expr("barShort", result_type="Bar")
+self.expect_expr("barChar", result_type="Bar")
+
+self.expect_expr("varInt", result_type="BarInt")
+self.expect_expr("varDouble", result_type="BarDouble")
+self.expect_expr("varShort", result_type="Bar")
+self.expect_expr("varChar", result_type="Bar")
Index: lldb/test/API/lang/cpp/preferred_name/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++20 -glldb
+include Makefile.rules
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -22,7 +22,7 @@
 
 def make_expected_basic_string_ptr(self) -> str:
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(['>', '16.0']):
-return f'std::unique_ptr >'
+return f'std::unique_ptr'
 else:
 return 'std::unique_ptr, std::allocator >, ' \
'std::default_delete, std::allocator > > >'
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
===
--- 

[Lldb-commits] [PATCH] D145078: [WIP][lldb][DWARFASTParserClang] Support DW_AT_LLVM_preferred_name attribute

2023-03-10 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 504103.
Michael137 added a comment.

- Update variable names in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145078

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Symbol/Type.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  lldb/test/API/lang/cpp/preferred_name/Makefile
  lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
  lldb/test/API/lang/cpp/preferred_name/main.cpp

Index: lldb/test/API/lang/cpp/preferred_name/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/main.cpp
@@ -0,0 +1,25 @@
+template  struct Foo;
+
+typedef Foo BarInt;
+typedef Foo BarDouble;
+
+template  using Bar = Foo;
+
+template 
+struct [[clang::preferred_name(BarInt), clang::preferred_name(BarDouble),
+ clang::preferred_name(Bar), clang::preferred_name(Bar),
+ clang::preferred_name(Bar),
+ clang::preferred_name(Bar)]] Foo{};
+
+int main() {
+  BarInt barInt;
+  BarDouble barDouble;
+  Bar barShort;
+  Bar barChar;
+
+  Foo varInt;
+  Foo varDouble;
+  Foo varShort;
+  Foo varChar;
+  return 0;
+}
Index: lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
@@ -0,0 +1,40 @@
+"""
+Test formatting of types annotated with
+[[clang::preferred_name]] attributes.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+
+class TestPreferredName(TestBase):
+
+def test_frame_var(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
+
+self.expect("frame variable barInt", substrs=["BarInt"])
+self.expect("frame variable barDouble", substrs=["BarDouble"])
+self.expect("frame variable barShort", substrs=["Bar"])
+self.expect("frame variable barChar", substrs=["Bar"])
+
+self.expect("frame variable varInt", substrs=["BarInt"])
+self.expect("frame variable varDouble", substrs=["BarDouble"])
+self.expect("frame variable varShort", substrs=["Bar"])
+self.expect("frame variable varChar", substrs=["Bar"])
+
+def test_expr(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("barInt", result_type="BarInt")
+self.expect_expr("barDouble", result_type="BarDouble")
+self.expect_expr("barShort", result_type="Bar")
+self.expect_expr("barChar", result_type="Bar")
+
+self.expect_expr("varInt", result_type="BarInt")
+self.expect_expr("varDouble", result_type="BarDouble")
+self.expect_expr("varShort", result_type="Bar")
+self.expect_expr("varChar", result_type="Bar")
Index: lldb/test/API/lang/cpp/preferred_name/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++20 -glldb
+include Makefile.rules
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -22,7 +22,7 @@
 
 def make_expected_basic_string_ptr(self) -> str:
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(['>', '16.0']):
-return f'std::unique_ptr >'
+return f'std::unique_ptr'
 else:
 return 'std::unique_ptr, std::allocator >, ' \
'std::default_delete, std::allocator > > >'
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
@@ -59,13 +59,13 @@
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
 if self.expectedCompiler(["clang"]) and

[Lldb-commits] [PATCH] D145566: [lldb] Add RegisterFlags class

2023-03-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 504104.
DavidSpickett added a comment.

Fix typo, remove `m_type` which is not used by the following patches.

We could use it down the road, but we can also just guess that single
bit fields are bools and anything else is a number. So we don't lose much.

Everything I've seen out of gdbserver only sends a type for the other
information types, struct and unions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145566

Files:
  lldb/include/lldb/Target/RegisterFlags.h
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/RegisterFlags.cpp
  lldb/unittests/Target/CMakeLists.txt
  lldb/unittests/Target/RegisterFlagsTest.cpp

Index: lldb/unittests/Target/RegisterFlagsTest.cpp
===
--- /dev/null
+++ lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -0,0 +1,123 @@
+//===-- RegisterFlagsTest.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "lldb/Target/RegisterFlags.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+TEST(RegisterFlagsTest, Field) {
+  // We assume that start <= end is always true, so that is not tested here.
+
+  RegisterFlags::Field f1("abc", 0, 0);
+  ASSERT_EQ(f1.GetName(), "abc");
+  // start == end means a 1 bit field.
+  ASSERT_EQ(f1.GetSizeInBits(), (unsigned)1);
+  ASSERT_EQ(f1.GetMask(), (uint64_t)1);
+  ASSERT_EQ(f1.GetValue(0), (uint64_t)0);
+  ASSERT_EQ(f1.GetValue(3), (uint64_t)1);
+
+  // End is inclusive meaning that start 0 to end 1 includes bit 1
+  // to make a 2 bit field.
+  RegisterFlags::Field f2("", 0, 1);
+  ASSERT_EQ(f2.GetSizeInBits(), (unsigned)2);
+  ASSERT_EQ(f2.GetMask(), (uint64_t)3);
+  ASSERT_EQ(f2.GetValue(UINT64_MAX), (uint64_t)3);
+  ASSERT_EQ(f2.GetValue(UINT64_MAX & ~(uint64_t)3), (uint64_t)0);
+
+  // If the field doesn't start at 0 we need to shift up/down
+  // to account for it.
+  RegisterFlags::Field f3("", 2, 5);
+  ASSERT_EQ(f3.GetSizeInBits(), (unsigned)4);
+  ASSERT_EQ(f3.GetMask(), (uint64_t)0x3c);
+  ASSERT_EQ(f3.GetValue(UINT64_MAX), (uint64_t)0xf);
+  ASSERT_EQ(f3.GetValue(UINT64_MAX & ~(uint64_t)0x3c), (uint64_t)0);
+
+  // Fields are sorted lowest starting bit first.
+  ASSERT_TRUE(f2 < f3);
+  ASSERT_FALSE(f3 < f1);
+  ASSERT_FALSE(f1 < f2);
+  ASSERT_FALSE(f1 < f1);
+}
+
+static RegisterFlags::Field make_field(unsigned start, unsigned end) {
+  return RegisterFlags::Field("", start, end);
+}
+
+TEST(RegisterFlagsTest, FieldOverlaps) {
+  // Single bit fields
+  ASSERT_FALSE(make_field(0, 0).Overlaps(make_field(1, 1)));
+  ASSERT_TRUE(make_field(1, 1).Overlaps(make_field(1, 1)));
+  ASSERT_FALSE(make_field(1, 1).Overlaps(make_field(3, 3)));
+
+  ASSERT_TRUE(make_field(0, 1).Overlaps(make_field(1, 2)));
+  ASSERT_TRUE(make_field(1, 2).Overlaps(make_field(0, 1)));
+  ASSERT_FALSE(make_field(0, 1).Overlaps(make_field(2, 3)));
+  ASSERT_FALSE(make_field(2, 3).Overlaps(make_field(0, 1)));
+
+  ASSERT_FALSE(make_field(1, 5).Overlaps(make_field(10, 20)));
+  ASSERT_FALSE(make_field(15, 30).Overlaps(make_field(7, 12)));
+}
+
+TEST(RegisterFlagsTest, PaddingDistance) {
+  // We assume that this method is always called with a more significant
+  // (start bit is higher) field first and that they do not overlap.
+
+  // [field 1][field 2]
+  ASSERT_EQ(make_field(1, 1).PaddingDistance(make_field(0, 0)), 0ULL);
+  // [field 1][..][field 2]
+  ASSERT_EQ(make_field(2, 2).PaddingDistance(make_field(0, 0)), 1ULL);
+  // [field 1][field 1][field 2]
+  ASSERT_EQ(make_field(1, 2).PaddingDistance(make_field(0, 0)), 0ULL);
+  // [field 1][30 bits free][field 2]
+  ASSERT_EQ(make_field(31, 31).PaddingDistance(make_field(0, 0)), 30ULL);
+}
+
+static void test_padding(const std::vector &fields,
+ const std::vector &expected) {
+  RegisterFlags rf("", 4, fields);
+  EXPECT_THAT(expected, ::testing::ContainerEq(rf.GetFields()));
+}
+
+TEST(RegisterFlagsTest, RegisterFlagsPadding) {
+  // When creating a set of flags we assume that:
+  // * There are >= 1 fields.
+  // * They are sorted in descending order.
+  // * There may be gaps between each field.
+
+  // Needs no padding
+  auto fields =
+  std::vector{make_field(16, 31), make_field(0, 15)};
+  test_padding(fields, fields);
+
+  // Needs padding in between the fields, single bit.
+  test_padding({make_field(17, 31), make_field(0, 15)},
+   {make_field(17, 31), make_field(16, 16), make_field(0, 15)});
+  // Multiple bits of padding.
+  test_padding({make_field(17, 31), make_field(0, 14)},
+   {make_field(17,

[Lldb-commits] [PATCH] D145574: [lldb] Read register fields from target XML

2023-03-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 504106.
DavidSpickett added a comment.

Remove use of type attribute on flags. We will recognise it as valid,
but do nothing with it as it's not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145574

Files:
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/include/lldb/lldb-private-types.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/DynamicRegisterInfo.cpp

Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -407,7 +407,7 @@
   {reg.regnum_ehframe, reg.regnum_dwarf, reg.regnum_generic,
reg.regnum_remote, local_regnum},
   // value_regs and invalidate_regs are filled by Finalize()
-  nullptr, nullptr, nullptr
+  nullptr, nullptr, reg.flags_type
 };
 
 m_regs.push_back(reg_info);
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -38,6 +38,7 @@
 #include "GDBRemoteRegisterContext.h"
 
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
 
 namespace lldb_private {
 namespace repro {
@@ -466,6 +467,15 @@
   // fork helpers
   void DidForkSwitchSoftwareBreakpoints(bool enable);
   void DidForkSwitchHardwareTraps(bool enable);
+
+  // Lists of register fields generated from the remote's target XML.
+  // Pointers to these RegisterFlags will be set in the register info passed
+  // back to the upper levels of lldb. Doing so is safe because this class will
+  // live at least as long as the debug session. We therefore do not store the
+  // data directly in the map because the map may reallocate it's storage as new
+  // entries are added. Which would invalidate any pointers set in the register
+  // info up to that point.
+  llvm::StringMap> m_registers_flags_types;
 };
 
 } // namespace process_gdb_remote
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -53,6 +53,7 @@
 #include "lldb/Target/ABI.h"
 #include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Target/RegisterFlags.h"
 #include "lldb/Target/SystemRuntime.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/TargetList.h"
@@ -84,6 +85,7 @@
 #include "lldb/Utility/StringExtractorGDBRemote.h"
 
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Threading.h"
@@ -4029,15 +4031,212 @@
   RegisterSetMap reg_set_map;
 };
 
-bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
-std::vector ®isters) {
+static std::vector ParseFlagsFields(XMLNode flags_node,
+  unsigned size) {
+  Log *log(GetLog(GDBRLog::Process));
+  const unsigned max_start_bit = size * 8 - 1;
+
+  // Process the fields of this set of flags.
+  std::vector fields;
+  flags_node.ForEachChildElementWithName("field", [&fields, max_start_bit,
+   &log](const XMLNode
+ &field_node) {
+std::optional name;
+std::optional start;
+std::optional end;
+
+field_node.ForEachAttribute([&name, &start, &end, max_start_bit,
+ &log](const llvm::StringRef &attr_name,
+   const llvm::StringRef &attr_value) {
+  // Note that XML in general requires that each of these attributes only
+  // appears once, so we don't have to handle that here.
+  if (attr_name == "name") {
+LLDB_LOGF(log,
+  "ProcessGDBRemote::ParseFlags Found field node name \"%s\"",
+  attr_value.data());
+name = attr_value;
+  } else if (attr_name == "start") {
+unsigned parsed_start = 0;
+if (llvm::to_integer(attr_value, parsed_start)) {
+  if (parsed_start > max_start_bit) {
+LLDB_LOGF(
+log,
+"ProcessGDBRemote::ParseFlags Invalid start %d in field node, "
+"cannot be > %d",
+parsed_start, max_start_bit);
+  } else
+start = parsed_start;
+} else {
+  LLDB_LOGF(
+  log,
+  "ProcessGDBRemote::ParseFlags

[Lldb-commits] [PATCH] D145574: [lldb] Read register fields from target XML

2023-03-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 504107.
DavidSpickett added a comment.

Correct printf for `unsigned`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145574

Files:
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/include/lldb/lldb-private-types.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/DynamicRegisterInfo.cpp

Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -407,7 +407,7 @@
   {reg.regnum_ehframe, reg.regnum_dwarf, reg.regnum_generic,
reg.regnum_remote, local_regnum},
   // value_regs and invalidate_regs are filled by Finalize()
-  nullptr, nullptr, nullptr
+  nullptr, nullptr, reg.flags_type
 };
 
 m_regs.push_back(reg_info);
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -38,6 +38,7 @@
 #include "GDBRemoteRegisterContext.h"
 
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
 
 namespace lldb_private {
 namespace repro {
@@ -466,6 +467,15 @@
   // fork helpers
   void DidForkSwitchSoftwareBreakpoints(bool enable);
   void DidForkSwitchHardwareTraps(bool enable);
+
+  // Lists of register fields generated from the remote's target XML.
+  // Pointers to these RegisterFlags will be set in the register info passed
+  // back to the upper levels of lldb. Doing so is safe because this class will
+  // live at least as long as the debug session. We therefore do not store the
+  // data directly in the map because the map may reallocate it's storage as new
+  // entries are added. Which would invalidate any pointers set in the register
+  // info up to that point.
+  llvm::StringMap> m_registers_flags_types;
 };
 
 } // namespace process_gdb_remote
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -53,6 +53,7 @@
 #include "lldb/Target/ABI.h"
 #include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Target/RegisterFlags.h"
 #include "lldb/Target/SystemRuntime.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/TargetList.h"
@@ -84,6 +85,7 @@
 #include "lldb/Utility/StringExtractorGDBRemote.h"
 
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Threading.h"
@@ -4029,15 +4031,212 @@
   RegisterSetMap reg_set_map;
 };
 
-bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
-std::vector ®isters) {
+static std::vector ParseFlagsFields(XMLNode flags_node,
+  unsigned size) {
+  Log *log(GetLog(GDBRLog::Process));
+  const unsigned max_start_bit = size * 8 - 1;
+
+  // Process the fields of this set of flags.
+  std::vector fields;
+  flags_node.ForEachChildElementWithName("field", [&fields, max_start_bit,
+   &log](const XMLNode
+ &field_node) {
+std::optional name;
+std::optional start;
+std::optional end;
+
+field_node.ForEachAttribute([&name, &start, &end, max_start_bit,
+ &log](const llvm::StringRef &attr_name,
+   const llvm::StringRef &attr_value) {
+  // Note that XML in general requires that each of these attributes only
+  // appears once, so we don't have to handle that here.
+  if (attr_name == "name") {
+LLDB_LOGF(log,
+  "ProcessGDBRemote::ParseFlags Found field node name \"%s\"",
+  attr_value.data());
+name = attr_value;
+  } else if (attr_name == "start") {
+unsigned parsed_start = 0;
+if (llvm::to_integer(attr_value, parsed_start)) {
+  if (parsed_start > max_start_bit) {
+LLDB_LOGF(
+log,
+"ProcessGDBRemote::ParseFlags Invalid start %u in field node, "
+"cannot be > %u",
+parsed_start, max_start_bit);
+  } else
+start = parsed_start;
+} else {
+  LLDB_LOGF(
+  log,
+  "ProcessGDBRemote::ParseFlags Invalid start \"%s\" in field node",
+  attr_value.data());
+

[Lldb-commits] [PATCH] D145580: [lldb] Show register fields using bitfield struct types

2023-03-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 504109.
DavidSpickett added a comment.

- Rebase
- Add a test to show the register fields respect the child limit setting.
- Make sure alignment is correct both when printed as one line and multiple.
- Correct indentation in test file so it's all 4 space tabs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145580

Files:
  lldb/include/lldb/Core/DumpRegisterValue.h
  lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
  lldb/include/lldb/Target/RegisterFlags.h
  lldb/source/Commands/CommandObjectRegister.cpp
  lldb/source/Core/DumpRegisterValue.cpp
  lldb/source/DataFormatters/DumpValueObjectOptions.cpp
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
  lldb/unittests/Target/RegisterFlagsTest.cpp
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -192,6 +192,12 @@
   omit defaulted template parameters. The full template parameter list can still be
   viewed with ``expr --raw-output``/``frame var --raw-output``. (`D141828 `_)
 
+* LLDB can now display register fields if they are described in target XML sent
+  by a debug server such as ``gdbserver`` (``lldb-server`` does not currently produce
+  this information). Fields are only printed when reading named registers, for
+  example ``register read cpsr``. They are not shown when reading a register set,
+  ``register read -s 0``.
+
 Changes to Sanitizers
 -
 
Index: lldb/unittests/Target/RegisterFlagsTest.cpp
===
--- lldb/unittests/Target/RegisterFlagsTest.cpp
+++ lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -121,3 +121,19 @@
 make_field(20, 21), make_field(12, 19), make_field(8, 11),
 make_field(0, 7)});
 }
+
+TEST(RegisterFieldsTest, ReverseFieldOrder) {
+  // Unchanged
+  RegisterFlags rf("", 4, {make_field(0, 31)});
+  ASSERT_EQ(0x12345678ULL, rf.ReverseFieldOrder(0x12345678));
+
+  // Swap the two halves around.
+  RegisterFlags rf2("", 4, {make_field(16, 31), make_field(0, 15)});
+  ASSERT_EQ(0x56781234ULL, rf2.ReverseFieldOrder(0x12345678));
+
+  // Many small fields.
+  RegisterFlags rf3("", 4,
+{make_field(31, 31), make_field(30, 30), make_field(29, 29),
+ make_field(28, 28)});
+  ASSERT_EQ(0x0005ULL, rf3.ReverseFieldOrder(0xA000));
+}
Index: lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
@@ -0,0 +1,514 @@
+""" Check that register fields found in target XML are properly processed."""
+
+from textwrap import dedent
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
+
+class MyResponder(MockGDBServerResponder):
+def __init__(self, registers):
+super().__init__()
+# This *must* begin with the opening tag, leading whitespace is not allowed.
+self.target_xml = dedent("""\
+  
+
+  aarch64
+  
+{}
+  
+  """.format(registers))
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return self.target_xml, False
+else:
+return None,
+
+def readRegister(self, regnum):
+return "E01"
+
+def readRegisters(self):
+# Data for all registers requested by the tests below.
+# 0x7 and 0xE are used because their lsb and msb are opposites, which
+# is needed for a byte order test.
+return ''.join([
+  '', # 64 bit x0
+  '', # 32 bit cpsr
+  '', # 64 bit pc
+])
+
+class MyMultiDocResponder(MockGDBServerResponder):
+# docs is a dictionary of filename -> file content.
+def __init__(self, docs):
+super().__init__()
+self.docs = docs
+
+def qXferRead(self, obj, annex, offset, length):
+try:
+return self.docs[annex], False
+except KeyError:
+return None,
+
+def readRegister(self, regnum):
+return "E01"
+
+def readRegisters(self):
+return ''.join([
+  '', # 64 bit x0
+  '', # 32 bit cpsr
+  '', # 64 bit pc
+])
+
+class TestAArch64XMLRegisterFlags(GDBRemoteTestBase):
+def setup_register_test(self, registers):
+target = self.createTarget("bas

[Lldb-commits] [PATCH] D145580: [lldb] Show register fields using bitfield struct types

2023-03-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

The last update changes the format slightly, though for the better I think.

  (lldb) register read cpsr x0 fpcr fpsr x1
  cpsr = 0x60001000
   = (N = 0, Z = 1, C = 1, V = 0, TCO = 0, DIT = 0, UAO = 0, PAN = 0, 
SS = 0, IL = 0, SSBS = 1, BTYPE = 0, D = 0, A = 0, I = 0, F = 0, nRW = 0, EL = 
0, SP = 0)

As we don't print the root type name we get this orphaned `=`, so I've aligned 
that with the usual value line above. I think it's clear that it's a second 
view on the register not a new name (and removing the `=` is fiddly).

If the fields end up on multiple lines, we handle that too:

  (lldb) register read fpcr
  fpcr = 0x
   = {
   AHP = 0
   DN = 0
  <...>
 }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145580

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


[Lldb-commits] [PATCH] D145580: [lldb] Show register fields using bitfield struct types

2023-03-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

> This all looks good to me. the phab says there's a missing newline at the end 
> of TestXMLRegisterFlags.py.

Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145580

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


[Lldb-commits] [PATCH] D145580: [lldb] Show register fields using bitfield struct types

2023-03-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 504140.
DavidSpickett added a comment.

Remove need for aarch64 yaml file in tests. Refactor the responders.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145580

Files:
  lldb/include/lldb/Core/DumpRegisterValue.h
  lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
  lldb/include/lldb/Target/RegisterFlags.h
  lldb/source/Commands/CommandObjectRegister.cpp
  lldb/source/Core/DumpRegisterValue.cpp
  lldb/source/DataFormatters/DumpValueObjectOptions.cpp
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
  lldb/unittests/Target/RegisterFlagsTest.cpp
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -192,6 +192,12 @@
   omit defaulted template parameters. The full template parameter list can still be
   viewed with ``expr --raw-output``/``frame var --raw-output``. (`D141828 `_)
 
+* LLDB can now display register fields if they are described in target XML sent
+  by a debug server such as ``gdbserver`` (``lldb-server`` does not currently produce
+  this information). Fields are only printed when reading named registers, for
+  example ``register read cpsr``. They are not shown when reading a register set,
+  ``register read -s 0``.
+
 Changes to Sanitizers
 -
 
Index: lldb/unittests/Target/RegisterFlagsTest.cpp
===
--- lldb/unittests/Target/RegisterFlagsTest.cpp
+++ lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -121,3 +121,19 @@
 make_field(20, 21), make_field(12, 19), make_field(8, 11),
 make_field(0, 7)});
 }
+
+TEST(RegisterFieldsTest, ReverseFieldOrder) {
+  // Unchanged
+  RegisterFlags rf("", 4, {make_field(0, 31)});
+  ASSERT_EQ(0x12345678ULL, rf.ReverseFieldOrder(0x12345678));
+
+  // Swap the two halves around.
+  RegisterFlags rf2("", 4, {make_field(16, 31), make_field(0, 15)});
+  ASSERT_EQ(0x56781234ULL, rf2.ReverseFieldOrder(0x12345678));
+
+  // Many small fields.
+  RegisterFlags rf3("", 4,
+{make_field(31, 31), make_field(30, 30), make_field(29, 29),
+ make_field(28, 28)});
+  ASSERT_EQ(0x0005ULL, rf3.ReverseFieldOrder(0xA000));
+}
Index: lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
@@ -0,0 +1,471 @@
+""" Check that register fields found in target XML are properly processed.
+
+These tests make XML out of string substitution. This can lead to some strange
+failures. Check that the final XML is valid and each child is indented more than
+the parent tag.
+"""
+
+from textwrap import dedent
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
+
+class MultiDocResponder(MockGDBServerResponder):
+# docs is a dictionary of filename -> file content.
+def __init__(self, docs):
+super().__init__()
+self.docs = docs
+
+def qXferRead(self, obj, annex, offset, length):
+try:
+return self.docs[annex], False
+except KeyError:
+return None,
+
+def readRegister(self, regnum):
+return "E01"
+
+def readRegisters(self):
+return ''.join([
+  # Data for all registers requested by the tests below.
+  # 0x7 and 0xE are used because their lsb and msb are opposites, which
+  # is needed for a byte order test.
+  '', # 64 bit x0
+  '', # 32 bit cpsr
+  '', # 64 bit pc
+])
+
+class TestXMLRegisterFlags(GDBRemoteTestBase):
+def setup_register_test(self, registers):
+self.server.responder = MultiDocResponder(
+  # This *must* begin with the opening tag, leading whitespace is not allowed.
+  {'target.xml' : dedent("""\
+
+  
+aarch64
+
+  {}
+
+""").format(registers)})
+target = self.dbg.CreateTarget('')
+
+if self.TraceOn():
+self.runCmd("log enable gdb-remote packets process")
+self.addTearDownHook(
+lambda: self.runCmd("log disable gdb-remote packets process"))
+
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateStopped])
+
+def setup_flags_test(self, flags):
+  

[Lldb-commits] [PATCH] D145580: [lldb] Show register fields using bitfield struct types

2023-03-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

I'm trying to get an s390x test going in the same fashion but figuring it out 
is tricky.

Also, I realise that all this XML substitution with strings is very brittle. I 
want to replace that with Python's xml.etree but will do that later in another 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145580

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


[Lldb-commits] [lldb] e1462d1 - Don't produce a dynamic value if there was an error creating it.

2023-03-10 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2023-03-10T10:21:50-08:00
New Revision: e1462d14b1e4be329a95bdd08181b97a7a3ad6e6

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

LOG: Don't produce a dynamic value if there was an error creating it.

We used to make a dynamic value that "pretended to be its parent"
but that's hard for some of the more complex ValueObject types, and
it's better in this case just to return no dynamic value.

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

Added: 
lldb/test/API/python_api/value/addr_of_void_star/Makefile

lldb/test/API/python_api/value/addr_of_void_star/TestValueAPIAddressOfVoidStar.py
lldb/test/API/python_api/value/addr_of_void_star/main.c

Modified: 
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectConstResult.cpp
lldb/source/Core/ValueObjectDynamicValue.cpp

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

Removed: 




diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index 6e79a04d024e5..1be7e2c322f0d 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1859,7 +1859,7 @@ ValueObjectSP 
ValueObject::GetDynamicValue(DynamicValueType use_dynamic) {
   if (!IsDynamic() && m_dynamic_value == nullptr) {
 CalculateDynamicValue(use_dynamic);
   }
-  if (m_dynamic_value)
+  if (m_dynamic_value && m_dynamic_value->GetError().Success())
 return m_dynamic_value->GetSP();
   else
 return ValueObjectSP();

diff  --git a/lldb/source/Core/ValueObjectConstResult.cpp 
b/lldb/source/Core/ValueObjectConstResult.cpp
index 640abdddfcad5..17a725dcc7dd8 100644
--- a/lldb/source/Core/ValueObjectConstResult.cpp
+++ b/lldb/source/Core/ValueObjectConstResult.cpp
@@ -287,7 +287,7 @@ 
ValueObjectConstResult::GetDynamicValue(lldb::DynamicValueType use_dynamic) {
   if (process && process->IsPossibleDynamicValue(*this))
 m_dynamic_value = new ValueObjectDynamicValue(*this, use_dynamic);
 }
-if (m_dynamic_value)
+if (m_dynamic_value && m_dynamic_value->GetError().Success())
   return m_dynamic_value->GetSP();
   }
   return ValueObjectSP();

diff  --git a/lldb/source/Core/ValueObjectDynamicValue.cpp 
b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 0659c771918a5..9db50aeeec9ea 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -187,17 +187,19 @@ bool ValueObjectDynamicValue::UpdateValue() {
 m_type_impl.Clear();
   }
 
-  // If we don't have a dynamic type, then make ourselves just a echo of our
-  // parent. Or we could return false, and make ourselves an echo of our
-  // parent?
+  // If we don't have a dynamic type, set ourselves to be invalid and return
+  // false.  We used to try to produce a dynamic ValueObject that behaved 
"like"
+  // its parent, but that failed for ValueObjectConstResult, which is too 
+  // complex a beast to try to emulate.  If we return an invalid ValueObject,
+  // clients will end up getting the static value instead, which behaves
+  // correctly.
   if (!found_dynamic_type) {
 if (m_dynamic_type_info)
   SetValueDidChange(true);
 ClearDynamicTypeInformation();
 m_dynamic_type_info.Clear();
-m_value = m_parent->GetValue();
-m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
-return m_error.Success();
+m_error.SetErrorString("no dynamic type found");
+return false;
   }
 
   Value old_value(m_value);

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index f05997fa03af8..2879aa64fd7c3 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -583,7 +583,11 @@ ValueObjectSP 
ItaniumABILanguageRuntime::GetExceptionObjectForThread(
   ValueObjectSP exception = ValueObject::CreateValueObjectFromData(
   "exception", exception_isw.GetAsData(m_process->GetByteOrder()), exe_ctx,
   voidstar);
-  exception = exception->GetDynamicValue(eDynamicDontRunTarget);
+  ValueObjectSP dyn_exception 
+  = exception->GetDynamicValue(eDynamicDontRunTarget);
+  // If we succeed in making a dynamic value, return that:
+  if (dyn_exception) 
+ return dyn_exception;
 
   return exception;
 }

diff  --git a/lldb/test/API/python_api/value/addr_of_void_star/Makefile 
b/lldb/test/API/python_api/value/addr_of_void_star/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ b/lldb/test/API/python_api/value/addr_of_void_star/Makefile
@@ -0,0 +1,3 @@
+C

[Lldb-commits] [PATCH] D145629: When a ValueObjectDynamicValue fails to update, return a not valid ValueObject so the static one is used instead

2023-03-10 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1462d14b1e4: Don't produce a dynamic value if there 
was an error creating it. (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145629

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectConstResult.cpp
  lldb/source/Core/ValueObjectDynamicValue.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  lldb/test/API/python_api/value/addr_of_void_star/Makefile
  
lldb/test/API/python_api/value/addr_of_void_star/TestValueAPIAddressOfVoidStar.py
  lldb/test/API/python_api/value/addr_of_void_star/main.c

Index: lldb/test/API/python_api/value/addr_of_void_star/main.c
===
--- /dev/null
+++ lldb/test/API/python_api/value/addr_of_void_star/main.c
@@ -0,0 +1,6 @@
+int main (int argc, char const *argv[]) {
+  char *char_ptr = "Some pointer here";
+  void *void_ptr = &char_ptr;
+  
+  return 0; // Break at this line
+}
Index: lldb/test/API/python_api/value/addr_of_void_star/TestValueAPIAddressOfVoidStar.py
===
--- /dev/null
+++ lldb/test/API/python_api/value/addr_of_void_star/TestValueAPIAddressOfVoidStar.py
@@ -0,0 +1,38 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class ValueAPIVoidStarTestCase(TestBase):
+
+def test(self):
+self.build()
+
+target, process, thread, _ = lldbutil.run_to_source_breakpoint(self,
+   "Break at this line",
+   lldb.SBFileSpec("main.c"))
+frame = thread.GetFrameAtIndex(0)
+
+# Verify that the expression result for a void * behaves the same way as the
+# variable value.
+
+var_val = frame.FindVariable("void_ptr")
+self.assertSuccess(var_val.GetError(), "Var version made correctly")
+
+expr_val = frame.EvaluateExpression("void_ptr")
+self.assertSuccess(expr_val.GetError(), "Expr version succeeds")
+
+# The pointer values should be equal:
+self.assertEqual(var_val.unsigned, expr_val.unsigned, "Values are equal")
+
+# Both versions should have valid AddressOf, and they should be the same.
+
+val_addr_of = var_val.AddressOf()
+self.assertNotEqual(val_addr_of, lldb.LLDB_INVALID_ADDRESS, "Var addr of right")
+
+expr_addr_of = expr_val.AddressOf()
+self.assertNotEqual(expr_addr_of, lldb.LLDB_INVALID_ADDRESS, "Expr addr of right")
+
+# The AddressOf values should also be equal.
+self.assertEqual(expr_addr_of.unsigned, val_addr_of.unsigned, "Addr of equal")
+
Index: lldb/test/API/python_api/value/addr_of_void_star/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/value/addr_of_void_star/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -583,7 +583,11 @@
   ValueObjectSP exception = ValueObject::CreateValueObjectFromData(
   "exception", exception_isw.GetAsData(m_process->GetByteOrder()), exe_ctx,
   voidstar);
-  exception = exception->GetDynamicValue(eDynamicDontRunTarget);
+  ValueObjectSP dyn_exception 
+  = exception->GetDynamicValue(eDynamicDontRunTarget);
+  // If we succeed in making a dynamic value, return that:
+  if (dyn_exception) 
+ return dyn_exception;
 
   return exception;
 }
Index: lldb/source/Core/ValueObjectDynamicValue.cpp
===
--- lldb/source/Core/ValueObjectDynamicValue.cpp
+++ lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -187,17 +187,19 @@
 m_type_impl.Clear();
   }
 
-  // If we don't have a dynamic type, then make ourselves just a echo of our
-  // parent. Or we could return false, and make ourselves an echo of our
-  // parent?
+  // If we don't have a dynamic type, set ourselves to be invalid and return
+  // false.  We used to try to produce a dynamic ValueObject that behaved "like"
+  // its parent, but that failed for ValueObjectConstResult, which is too 
+  // complex a beast to try to emulate.  If we return an invalid ValueObject,
+  // clients will end up getting the static value instead, which behaves
+  // correctly.
   if (!found_dynamic_type) {
 if (m_dynamic_type_info)
   Se

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:3036
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
-  AddDeallocation(DestroyPtr, Ptr);
+  auto DestroyPtr = [](void *V) { ((T *)V)->~T(); };
+  AddDeallocation(DestroyPtr, (void *)Ptr);

erichkeane wrote:
> bolshakov-a wrote:
> > erichkeane wrote:
> > > This change is weird... what is going on here?
> > Here is not very beautiful attempt to workaround const-ness of 
> > `TemplateArgument::V::Value` pointer passed here from the added 
> > `TemplateArgument` constructor. The change in this line isn't acually 
> > needed and made only for consistence with the next line, I think. 
> > Alternatively, I can
> > 1) refactor `addDestruction` and `AddDeallocation` to work with pointers to 
> > constants, or
> > 2) add `const_cast` to `AddDeallocation` call in the next line, or
> > 3) make `TemplateArgument::V::Value` pointer non-const.
> > 
> > I'm biased to the first variant.
> I'd lean towards #3, it ends up being consistent with the rest of the things 
> here.  #1 is interesting, but that results in these functions violating 
> const-correctness.
I understand that calling the destructor on a reference to `const` looks 
strange, but it is reasonable: even constants should be destroyed.



Comment at: clang/include/clang/AST/TemplateBase.h:88
+/// so cannot be dependent.
+UncommonValue,
+

shafik wrote:
> erichkeane wrote:
> > I definitely hate the name here... Just `Value` makes a bit more sense, but 
> > isn't perfectly accurate.  Perhaps `NonTypeValue`?  But that is a little 
> > redundant.  `Uncommon` here is just strange and not particularly 
> > descriptive. 
> This catch all `UncommonValue` feels artificial. Maybe we need a separate out 
> the cases into more granular cases like `Float` etc
@erichkeane, it looks strange, I agree. Even just `CommonValue` sounds better 
for me (but my English is far from fluent). Maybe, `ArbitraryValue`?

@shafik, your suggestion would move this PR far enough from the original 
Richard's commit. And I'd prefer to merge `Declaration`, `Integral`, and 
`NullPtr` kinds into that is currently called `UncommonValue` rather than to 
repeat here various `APValue` kinds.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:1670
+  case TemplateArgument::UncommonValue:
+if (ValueDecl *D = getAsArrayToPointerDecayedDecl(
+TA.getUncommonValueType(), TA.getAsUncommonValue())) {

erichkeane wrote:
> Has microsoft implemented this yet?  Can we see what they chose to do and 
> make sure we match them? 
Experimentally, I've made me sure that MSVC produces the same mangled names for 
the cases provided in the `mangle-ms-templates` test as in the test. But there 
are problems with references to subobjects: some cases are explicitly 
unsupported in `mangleTemplateArgValue`, and some cases produce a magled name 
different from what MSVC does. Should it be fixed in this PR, or may be delayed?



Comment at: clang/lib/AST/TemplateBase.cpp:619
+  case TemplateArgument::UncommonValue: {
+// FIXME: We're guessing at LangOptions!
+SmallString<32> Str;

erichkeane wrote:
> aaron.ballman wrote:
> > It's probably okay enough, but this is now the third instance of adding the 
> > same bug to this helper method -- maybe we should fix that instead?
> Agreed, seems to me we should do the work NOW to just wire in the lang-opts 
> to this function.
The problem here is because this function is called from a stream insertion 
operator, and there isn't obviously any way to pass 3rd parameter into it 
without switching it into an ordinary function.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

aaron.ballman wrote:
> Any particular reason this isn't being handled now?
I need some guidance here. Which characters are allowed in the USR? Could the 
mangling algorithm from `CXXNameMangler::mangleValueInTemplateArg` be moved 
into some common place and reused here?



Comment at: clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp:204
+#if __cplusplus == 201703L
+  // cxx17-error@-3 {{non-type template argument refers to subobject '(int 
*)1'}}
+#endif

shafik wrote:
> Shouldn't this be an error b/c it is a temporary? What is `(int*)1` a 
> subobject of?
This PR doesn't change C++17 mode diagnostics. Btw, in C++20 mode, this is 
acceptable template argument.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:12
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 

shafik wrote:
> I believe this is IFNDR the template-heads are functionally equivelent but 
> not equivelent: https://eel.is/c++draft/

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a added a comment.

I have some problems with Arcanist... It tries to open a new PR instead of 
updating this one. Probably because I've re-cloned my local repository.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504242.
bolshakov-a added a comment.

Rebased.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr<&n + 1>;
+using IPn = IntPtr<&n + 1>;
 
-using IP2 = IntPtr<&s.n[2]>; // FIXME expected-error {{refers to subobject}}
-using IP2 = IntPtr

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504247.
bolshakov-a added a comment.

Fix after rebase.


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

https://reviews.llvm.org/D140996

Files:
  clang/include/clang/AST/PropertiesBase.td


Index: clang/include/clang/AST/PropertiesBase.td
===
--- clang/include/clang/AST/PropertiesBase.td
+++ clang/include/clang/AST/PropertiesBase.td
@@ -798,8 +798,11 @@
   def : Property<"type", QualType> {
 let Read = [{ node.getUncommonValueType() }];
   }
+  def : Property<"isDefaulted", Bool> {
+let Read = [{ node.getIsDefaulted() }];
+  }
   def : Creator<[{
-return TemplateArgument(ctx, type, value);
+return TemplateArgument(ctx, type, value, isDefaulted);
   }]>;
 }
 let Class = PropertyTypeCase in {


Index: clang/include/clang/AST/PropertiesBase.td
===
--- clang/include/clang/AST/PropertiesBase.td
+++ clang/include/clang/AST/PropertiesBase.td
@@ -798,8 +798,11 @@
   def : Property<"type", QualType> {
 let Read = [{ node.getUncommonValueType() }];
   }
+  def : Property<"isDefaulted", Bool> {
+let Read = [{ node.getIsDefaulted() }];
+  }
   def : Creator<[{
-return TemplateArgument(ctx, type, value);
+return TemplateArgument(ctx, type, value, isDefaulted);
   }]>;
 }
 let Class = PropertyTypeCase in {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504248.
bolshakov-a added a comment.

Fix after rebase.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr<&n + 1>;
+using IPn = IntPtr<&n + 1>;
 
-using IP2 = IntPtr<&s.n[2]>; // FIXME expected-error {{refers to subobject}}
-using IP2

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504249.
bolshakov-a added a comment.

Refactor `TemplateArgument` constructors.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr<&n + 1>;
+using IPn = IntPtr<&n + 1>;
 
-using IP2 = IntPtr<&s.n[2]>; // FIXME expected-error {{refers t

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504250.
bolshakov-a added a comment.
Herald added a subscriber: ChuanqiXu.

Add `ODRHash` calculation for UncommonValue (and test it).


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504251.
bolshakov-a added a comment.

Add `ODRHash` calculation for `UncommonValue` (and test it).


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr<&n + 1>;
+using

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504253.
bolshakov-a added a comment.

Add some testcases.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,28 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr<&n + 1>;
+using IPn = IntPtr<&n + 1>;
 
-using IP2 = Int

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504254.
bolshakov-a added a comment.

Fix constness issue in `TemplateArgument` for `ASTContext`.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,28 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr<&n + 1>;
+using IPn = IntPtr<&n + 1>;
 
-using IP2 = In

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a updated this revision to Diff 504255.
bolshakov-a added a comment.

Add relnote and update C++ status.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 16 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrE

[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via lldb-commits
bolshakov-a added a comment.

@royjacobson, I've added some test cases for using the new NTTP arguments in 
clang modules. It uses serialization, in principle. Or more specialized tests 
are still needed?


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

https://reviews.llvm.org/D140996

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


[Lldb-commits] [PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Roy Jacobson via Phabricator via lldb-commits
royjacobson added a comment.

In D140996#4185795 , @bolshakov-a 
wrote:

> @royjacobson, I've added some test cases for using the new NTTP arguments in 
> clang modules. It uses serialization, in principle. Or more specialized tests 
> are still needed?

No, I think that's good. Thanks for adding them!


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

https://reviews.llvm.org/D140996

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


[Lldb-commits] [PATCH] D145832: [lldb][test] Add tests for clang::PreferredNameAttr formatting

2023-03-10 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add some tests to make sure we're formatting structures
with preferred names correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145832

Files:
  lldb/test/API/lang/cpp/preferred_name/Makefile
  lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
  lldb/test/API/lang/cpp/preferred_name/main.cpp


Index: lldb/test/API/lang/cpp/preferred_name/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/main.cpp
@@ -0,0 +1,25 @@
+template  struct Foo;
+
+typedef Foo BarInt;
+typedef Foo BarDouble;
+
+template  using Bar = Foo;
+
+template 
+struct [[clang::preferred_name(BarInt), clang::preferred_name(BarDouble),
+ clang::preferred_name(Bar), clang::preferred_name(Bar),
+ clang::preferred_name(Bar),
+ clang::preferred_name(Bar)]] Foo{};
+
+int main() {
+  BarInt barInt;
+  BarDouble barDouble;
+  Bar barShort;
+  Bar barChar;
+
+  Foo varInt;
+  Foo varDouble;
+  Foo varShort;
+  Foo varChar;
+  return 0;
+}
Index: lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
@@ -0,0 +1,40 @@
+"""
+Test formatting of types annotated with
+[[clang::preferred_name]] attributes.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+
+class TestPreferredName(TestBase):
+
+def test_frame_var(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", 
lldb.SBFileSpec("main.cpp"))
+
+self.expect("frame variable barInt", substrs=["BarInt"])
+self.expect("frame variable barDouble", substrs=["BarDouble"])
+self.expect("frame variable barShort", substrs=["Bar"])
+self.expect("frame variable barChar", substrs=["Bar"])
+
+self.expect("frame variable varInt", substrs=["BarInt"])
+self.expect("frame variable varDouble", substrs=["BarDouble"])
+self.expect("frame variable varShort", substrs=["Bar"])
+self.expect("frame variable varChar", substrs=["Bar"])
+
+def test_expr(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", 
lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("barInt", result_type="BarInt")
+self.expect_expr("barDouble", result_type="BarDouble")
+self.expect_expr("barShort", result_type="Bar")
+self.expect_expr("barChar", result_type="Bar")
+
+self.expect_expr("varInt", result_type="BarInt")
+self.expect_expr("varDouble", result_type="BarDouble")
+self.expect_expr("varShort", result_type="Bar")
+self.expect_expr("varChar", result_type="Bar")
Index: lldb/test/API/lang/cpp/preferred_name/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++20 -glldb
+include Makefile.rules


Index: lldb/test/API/lang/cpp/preferred_name/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/main.cpp
@@ -0,0 +1,25 @@
+template  struct Foo;
+
+typedef Foo BarInt;
+typedef Foo BarDouble;
+
+template  using Bar = Foo;
+
+template 
+struct [[clang::preferred_name(BarInt), clang::preferred_name(BarDouble),
+ clang::preferred_name(Bar), clang::preferred_name(Bar),
+ clang::preferred_name(Bar),
+ clang::preferred_name(Bar)]] Foo{};
+
+int main() {
+  BarInt barInt;
+  BarDouble barDouble;
+  Bar barShort;
+  Bar barChar;
+
+  Foo varInt;
+  Foo varDouble;
+  Foo varShort;
+  Foo varChar;
+  return 0;
+}
Index: lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
@@ -0,0 +1,40 @@
+"""
+Test formatting of types annotated with
+[[clang::preferred_name]] attributes.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+
+class TestPreferredName(TestBase):
+
+def test_frame_var(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
+
+self.expect("frame variable barInt", substrs=["BarInt"])
+self.expect("frame variable barDouble", substrs=["BarDouble"])
+self.expect("frame variable barShort", substrs=["Bar"])
+self.expect("frame variable barChar", substrs=["Bar"])
+
+self.expect("fr

[Lldb-commits] [PATCH] D145832: [lldb][test] Add tests for clang::PreferredNameAttr formatting

2023-03-10 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 504306.
Michael137 added a comment.

- Update testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145832

Files:
  lldb/test/API/lang/cpp/preferred_name/Makefile
  lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
  lldb/test/API/lang/cpp/preferred_name/main.cpp


Index: lldb/test/API/lang/cpp/preferred_name/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/main.cpp
@@ -0,0 +1,26 @@
+template  struct Foo;
+
+typedef Foo BarInt;
+typedef Foo BarDouble;
+
+template  using Bar = Foo;
+
+template 
+struct [[clang::preferred_name(BarInt), clang::preferred_name(BarDouble),
+ clang::preferred_name(Bar), clang::preferred_name(Bar),
+ clang::preferred_name(Bar),
+ clang::preferred_name(Bar)]] Foo{};
+
+int main() {
+  BarInt barInt;
+  BarDouble barDouble;
+  Bar barShort;
+  Bar barChar;
+
+  Foo varInt;
+  Foo varDouble;
+  Foo varShort;
+  Foo varChar;
+  Foo> varFooInt;
+  return 0;
+}
Index: lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
@@ -0,0 +1,42 @@
+"""
+Test formatting of types annotated with
+[[clang::preferred_name]] attributes.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+
+class TestPreferredName(TestBase):
+
+def test_frame_var(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", 
lldb.SBFileSpec("main.cpp"))
+
+self.expect("frame variable barInt", substrs=["BarInt"])
+self.expect("frame variable barDouble", substrs=["BarDouble"])
+self.expect("frame variable barShort", substrs=["Bar"])
+self.expect("frame variable barChar", substrs=["Bar"])
+
+self.expect("frame variable varInt", substrs=["BarInt"])
+self.expect("frame variable varDouble", substrs=["BarDouble"])
+self.expect("frame variable varShort", substrs=["Bar"])
+self.expect("frame variable varChar", substrs=["Bar"])
+self.expect("frame variable varFooInt", substrs=["Foo"])
+
+def test_expr(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", 
lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("barInt", result_type="BarInt")
+self.expect_expr("barDouble", result_type="BarDouble")
+self.expect_expr("barShort", result_type="Bar")
+self.expect_expr("barChar", result_type="Bar")
+
+self.expect_expr("varInt", result_type="BarInt")
+self.expect_expr("varDouble", result_type="BarDouble")
+self.expect_expr("varShort", result_type="Bar")
+self.expect_expr("varChar", result_type="Bar")
+self.expect_expr("varFooInt", result_type="Foo")
Index: lldb/test/API/lang/cpp/preferred_name/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++20 -glldb
+include Makefile.rules


Index: lldb/test/API/lang/cpp/preferred_name/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/main.cpp
@@ -0,0 +1,26 @@
+template  struct Foo;
+
+typedef Foo BarInt;
+typedef Foo BarDouble;
+
+template  using Bar = Foo;
+
+template 
+struct [[clang::preferred_name(BarInt), clang::preferred_name(BarDouble),
+ clang::preferred_name(Bar), clang::preferred_name(Bar),
+ clang::preferred_name(Bar),
+ clang::preferred_name(Bar)]] Foo{};
+
+int main() {
+  BarInt barInt;
+  BarDouble barDouble;
+  Bar barShort;
+  Bar barChar;
+
+  Foo varInt;
+  Foo varDouble;
+  Foo varShort;
+  Foo varChar;
+  Foo> varFooInt;
+  return 0;
+}
Index: lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/preferred_name/TestPreferredName.py
@@ -0,0 +1,42 @@
+"""
+Test formatting of types annotated with
+[[clang::preferred_name]] attributes.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+
+class TestPreferredName(TestBase):
+
+def test_frame_var(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
+
+self.expect("frame variable barInt", substrs=["BarInt"])
+self.expect("frame variable barDouble", substrs=["BarDouble"])
+self.expect("frame variable barShort", substrs=["Bar"])
+self.expect("frame variable barChar", substrs=["Bar"])
+
+ 

[Lldb-commits] [lldb] e508545 - [lldb][NFC] Use UnixSignal::CreateForHost in Process

2023-03-10 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-03-10T16:58:14-08:00
New Revision: e5085457ecc44418fab73de3b535961eac06c7a2

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

LOG: [lldb][NFC] Use UnixSignal::CreateForHost in Process

These do the same thing but we have a specific function for it.

Added: 


Modified: 
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 8bfebe3c8ff6a..77ee27687fefb 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -402,8 +402,7 @@ ConstString &Process::GetStaticBroadcasterClass() {
 }
 
 Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp)
-: Process(target_sp, listener_sp,
-  UnixSignals::Create(HostInfo::GetArchitecture())) {
+: Process(target_sp, listener_sp, UnixSignals::CreateForHost()) {
   // This constructor just delegates to the full Process constructor,
   // defaulting to using the Host's UnixSignals.
 }



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


[Lldb-commits] [lldb] 9aae408 - [NFC] fix typo `funciton` -> `function`

2023-03-10 Thread Yuanfang Chen via lldb-commits

Author: Yuanfang Chen
Date: 2023-03-10T18:05:25-08:00
New Revision: 9aae408d551083bbbac96ecc512d45c30358e4b9

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

LOG: [NFC] fix typo `funciton` -> `function`

credits to @jmagee

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/test/SemaCXX/coroutine-alloc-4.cpp
flang/lib/Evaluate/intrinsics-library.cpp
lldb/include/lldb/Target/TraceDumper.h
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
llvm/include/llvm/CodeGen/MIRPrinter.h
llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/Transforms/SampleProfile/inline-mergeprof-dup.ll
llvm/tools/llvm-xray/xray-account.cpp
llvm/tools/llvm-xray/xray-graph.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index d56aba34ac0a..866dca008381 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -65,7 +65,7 @@ def DeprecatedCoroutine :
 def AlwaysInlineCoroutine :
   DiagGroup<"always-inline-coroutine">;
 def CoroNonAlignedAllocationFunction :
-  DiagGroup<"coro-non-aligned-allocation-funciton">;
+  DiagGroup<"coro-non-aligned-allocation-function">;
 def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException, 
DeprecatedCoroutine,
 AlwaysInlineCoroutine, 
CoroNonAlignedAllocationFunction]>;
 def ObjCBoolConstantConversion : DiagGroup<"objc-bool-constant-conversion">;

diff  --git a/clang/test/SemaCXX/coroutine-alloc-4.cpp 
b/clang/test/SemaCXX/coroutine-alloc-4.cpp
index acad2779a254..262c163fb178 100644
--- a/clang/test/SemaCXX/coroutine-alloc-4.cpp
+++ b/clang/test/SemaCXX/coroutine-alloc-4.cpp
@@ -1,4 +1,4 @@
-// Tests that we'll find aligned allocation funciton properly.
+// Tests that we'll find aligned allocation function properly.
 // RUN: %clang_cc1 %s -std=c++20 %s -fsyntax-only -verify 
-fcoro-aligned-allocation
 
 #include "Inputs/std-coroutine.h"

diff  --git a/flang/lib/Evaluate/intrinsics-library.cpp 
b/flang/lib/Evaluate/intrinsics-library.cpp
index c333ffeac90c..3a6d28e4ab04 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -295,7 +295,7 @@ struct HostRuntimeLibrary, 
LibraryVersion::Libm> {
 /// Define libm extensions
 /// Bessel functions are defined in POSIX.1-2001.
 
-// Remove float bessel funcitons for AIX as they are not supported
+// Remove float bessel functions for AIX as they are not supported
 #ifndef _AIX
 template <> struct HostRuntimeLibrary {
   using F = FuncPointer;

diff  --git a/lldb/include/lldb/Target/TraceDumper.h 
b/lldb/include/lldb/Target/TraceDumper.h
index ca3bf2c08808..ca08dc254182 100644
--- a/lldb/include/lldb/Target/TraceDumper.h
+++ b/lldb/include/lldb/Target/TraceDumper.h
@@ -317,7 +317,7 @@ class TraceDumper {
 FunctionCall(const lldb::TraceCursorSP &cursor_sp,
  const SymbolInfo &symbol_info);
 
-/// Append a new traced segment to this funciton call.
+/// Append a new traced segment to this function call.
 ///
 /// \param[in] cursor_sp
 ///   A cursor pointing to the first instruction of the new segment.

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
index 617181a35d1d..1f7d8a1b8598 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -172,7 +172,7 @@ CPlusPlusNameParser::ParseFuncPtr(bool expect_return_type) {
   //
   // Consume inner function name. This will fail unless
   // we stripped all the pointers on the left hand side
-  // of the funciton name.
+  // of the function name.
   {
 Bookmark before_inner_function_pos = SetBookmark();
 auto maybe_inner_function_name = ParseFunctionImpl(false);

diff  --git a/llvm/include/llvm/CodeGen/MIRPrinter.h 
b/llvm/include/llvm/CodeGen/MIRPrinter.h
index 45e30686b642..5e94418d5fe0 100644
--- a/llvm/include/llvm/CodeGen/MIRPrinter.h
+++ b/llvm/include/llvm/CodeGen/MIRPrinter.h
@@ -34,7 +34,7 @@ void printMIR(raw_ostream &OS, const MachineFunction &MF);
 /// you the correct list of successor blocks in most cases except for things
 /// like jump tables where the basic block references can't easily be found.
 ///