[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private

2023-02-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks accepted this revision.
aeubanks added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/unittests/IR/ModuleTest.cpp:49
 EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare));
-M.getGlobalList().sort(compare);
-EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare));
+// I removed this because it is testing whether ilist.sort() works, which 
is
+// not Module-specific. This requires access to the full GlobalList for no

can just delete the commented out lines and add the reasoning behind deleting 
this either as a phabricator comment or in the commit description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144027

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


[Lldb-commits] [PATCH] D143958: [NFC][IR] Make Module::getAliasList() private

2023-02-13 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143958

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


[Lldb-commits] [PATCH] D143958: [NFC][IR] Make Module::getAliasList() private

2023-02-13 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: llvm/include/llvm/IR/Module.h:566
 
+  /// Detaches \p Alias from the list but does not delete it.
+  void removeAlias(GlobalAlias *Alias) { AliasList.remove(Alias); }

use the imperative `Detach` instead of `Detaches` (same below)



Comment at: llvm/include/llvm/IR/Module.h:573
+  /// Inserts \p Alias into the alias list before \p Where and takes ownership.
+  void insertAlias(AliasListType::iterator Where, GlobalAlias *Alias) {
+AliasList.insert(Where, Alias);

vporpo wrote:
> aeubanks wrote:
> > this isn't used outside tests, remove?
> Isn't it better to keep it for completeness? I don't feel strongly about it 
> though, either way is fine with me.
I think it's better to add it only if we actually use it. Besides, I don't 
think people generally care about the order of aliases.



Comment at: llvm/include/llvm/IR/Module.h:576
+  }
+  // Please use alias_size() to get the size of AliasList.
+  // Please use aliases() to get a range of all tha Alias objects in AliasList.

I'd drop the `Please`



Comment at: llvm/include/llvm/IR/Module.h:577
+  // Please use alias_size() to get the size of AliasList.
+  // Please use aliases() to get a range of all tha Alias objects in AliasList.
+




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143958

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


[Lldb-commits] [PATCH] D143958: [NFC][IR] Make Module::getAliasList() private

2023-02-13 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.
Herald added subscribers: Michael137, JDevlieghere.



Comment at: llvm/include/llvm/IR/Module.h:573
+  /// Inserts \p Alias into the alias list before \p Where and takes ownership.
+  void insertAlias(AliasListType::iterator Where, GlobalAlias *Alias) {
+AliasList.insert(Where, Alias);

this isn't used outside tests, remove?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143958

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


[Lldb-commits] [PATCH] D142413: [lldb] Don't create Clang AST nodes in GetDIEClassTemplateParams

2023-01-24 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5dd7c16c3dcf: [lldb] Dont create Clang AST nodes in 
GetDIEClassTemplateParams (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142413

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/API/lang/cpp/nested-template/Makefile
  lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
  lldb/test/API/lang/cpp/nested-template/main.cpp

Index: lldb/test/API/lang/cpp/nested-template/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/main.cpp
@@ -0,0 +1,10 @@
+struct Outer {
+  Outer() {}
+
+  template 
+  struct Inner {};
+};
+
+int main() {
+  Outer::Inner oi;
+}
Index: lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
@@ -0,0 +1,24 @@
+"""
+Test that a nested template parameter works with simple template names.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class NestedTemplateTestCase(TestBase):
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.expect("image lookup -A -t 'Inner'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/nested-template/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS = $(TEST_CFLAGS_EXTRAS) $(LIMIT_DEBUG_INFO_FLAGS)
+
+include Makefile.rules
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -1067,6 +1067,10 @@
 
   bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td);
 
+  /// Return the template parameters (including surrounding <>) in string form.
+  std::string
+  PrintTemplateParams(const TemplateParameterInfos _param_infos);
+
 private:
   /// Returns the PrintingPolicy used when generating the internal type names.
   /// These type names are mostly used for the formatter selection.
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1431,6 +1431,24 @@
   return template_param_list;
 }
 
+std::string TypeSystemClang::PrintTemplateParams(
+const TemplateParameterInfos _param_infos) {
+  llvm::SmallVector ignore;
+  clang::TemplateParameterList *template_param_list =
+  CreateTemplateParameterList(getASTContext(), template_param_infos,
+  ignore);
+  llvm::SmallVector args =
+  template_param_infos.args;
+  if (template_param_infos.hasParameterPack()) {
+args.append(template_param_infos.packed_args->args);
+  }
+  std::string str;
+  llvm::raw_string_ostream os(str);
+  clang::printTemplateArgumentList(os, args, GetTypePrintingPolicy(),
+   template_param_list);
+  return str;
+}
+
 clang::FunctionTemplateDecl *TypeSystemClang::CreateFunctionTemplateDecl(
 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
 clang::FunctionDecl *func_decl,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -95,11 +95,6 @@
   /// parameters from the DIE name and instead always adds template parameter
   /// children DIEs.
   ///
-  /// Currently this is only called in two places, when uniquing C++ classes and
-  /// when looking up the definition for a declaration (which is then cached).
-  /// If this is ever called more than twice per 

[Lldb-commits] [PATCH] D142413: [lldb] Don't create Clang AST nodes in GetDIEClassTemplateParams

2023-01-24 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

In D142413#4076749 , @Michael137 
wrote:

> In D142413#4075198 , @aeubanks 
> wrote:
>
>> there may be an alternate solution involving making some declarations into 
>> definitions (at all? earlier?), but I don't have that level of understanding 
>> of lldb
>
> One idea that came to mind is that instead of creating a dummy template decl 
> in `GetDIEClassTemplateParams`, you could perhaps construct a 
> `clang::TemplateArgumentList` from the `TemplateArgument`s stored in 
> `TemplateParameterInfos` and use the `clang::printTemplateArgumentList` to 
> stringify the template arguments, passing it the printing-policy which is 
> used in `TypeSystemClang` to print type-names in your current implementation.

this worked perfectly and simplified a lot of code, thanks!




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1533
 
+std::string
+DWARFASTParserClang::GetTemplateParametersString(const DWARFDIE ) {

Michael137 wrote:
> Michael137 wrote:
> > Ah the function was declared but not defined (presumably a leftover from 
> > https://reviews.llvm.org/D138834)
> > 
> > Can we elaborate in the function docstring how this differs from 
> > `GetTemplateParameters`?
> Meant to say `GetDIEClassTemplateParams`
yeah I forgot to remove the declaration in that patch :|



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h:101
+  /// per DIE, we need to start caching the results to prevent unbounded growth
+  /// of the created clang AST nodes.
   ///

Michael137 wrote:
> Btw, what's guaranteeing that we don't call this more than once per DIE? Is 
> there any way we could add a test that would notify us of that kind of 
> regression? Or perhaps an assert somewhere in the `DWARFASTParserClang`?
now we don't create a clang AST node



Comment at: lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py:13
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", 
lldb.SBFileSpec("main.cpp"))
+self.expect("image lookup -A -t 'Inner'", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])

Michael137 wrote:
> Nit: technically don't need to run the program to test `image lookup`?
last time I couldn't find the right thing to call to load the binary but not 
set a breakpoint, but perhaps this works?



Comment at: lldb/test/API/lang/cpp/nested-template/main.cpp:10
+  Outer::Inner oi;
+  // Set breakpoint here
+}

Michael137 wrote:
> Nit: we typically use `std::puts("Set breakpoint here")` or `return 0` for 
> source regex breakpoints. The rationale was that breaking on comments isn't 
> always reliable/future-proof.
obsolete now that we don't set a breakpoint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142413

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


[Lldb-commits] [PATCH] D142413: [lldb] Don't create Clang AST nodes in GetCPlusPlusQualifiedName

2023-01-24 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 491924.
aeubanks marked an inline comment as done.
aeubanks added a comment.

use suggested alternative


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142413

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/API/lang/cpp/nested-template/Makefile
  lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
  lldb/test/API/lang/cpp/nested-template/main.cpp

Index: lldb/test/API/lang/cpp/nested-template/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/main.cpp
@@ -0,0 +1,10 @@
+struct Outer {
+  Outer() {}
+
+  template 
+  struct Inner {};
+};
+
+int main() {
+  Outer::Inner oi;
+}
Index: lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
@@ -0,0 +1,24 @@
+"""
+Test that a nested template parameter works with simple template names.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class NestedTemplateTestCase(TestBase):
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.expect("image lookup -A -t 'Inner'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/nested-template/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS = $(TEST_CFLAGS_EXTRAS) $(LIMIT_DEBUG_INFO_FLAGS)
+
+include Makefile.rules
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -1067,6 +1067,10 @@
 
   bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td);
 
+  /// Return the template parameters (including surrounding <>) in string form.
+  std::string
+  PrintTemplateParams(const TemplateParameterInfos _param_infos);
+
 private:
   /// Returns the PrintingPolicy used when generating the internal type names.
   /// These type names are mostly used for the formatter selection.
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1431,6 +1431,24 @@
   return template_param_list;
 }
 
+std::string TypeSystemClang::PrintTemplateParams(
+const TemplateParameterInfos _param_infos) {
+  llvm::SmallVector ignore;
+  clang::TemplateParameterList *template_param_list =
+  CreateTemplateParameterList(getASTContext(), template_param_infos,
+  ignore);
+  llvm::SmallVector args =
+  template_param_infos.args;
+  if (template_param_infos.hasParameterPack()) {
+args.append(template_param_infos.packed_args->args);
+  }
+  std::string str;
+  llvm::raw_string_ostream os(str);
+  clang::printTemplateArgumentList(os, args, GetTypePrintingPolicy(),
+   template_param_list);
+  return str;
+}
+
 clang::FunctionTemplateDecl *TypeSystemClang::CreateFunctionTemplateDecl(
 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
 clang::FunctionDecl *func_decl,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -95,11 +95,6 @@
   /// parameters from the DIE name and instead always adds template parameter
   /// children DIEs.
   ///
-  /// Currently this is only called in two places, when uniquing C++ classes and
-  /// when looking up the definition for a declaration (which is then cached).
-  /// If this is ever called more than twice per DIE, we need to start caching
-  /// the results to 

[Lldb-commits] [PATCH] D142413: [lldb] Don't create Clang AST nodes in GetCPlusPlusQualifiedName

2023-01-23 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

there may be an alternate solution involving making some declarations into 
definitions (at all? earlier?), but I don't have that level of understanding of 
lldb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142413

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


[Lldb-commits] [PATCH] D142413: [lldb] Don't create Clang AST nodes in GetCPlusPlusQualifiedName

2023-01-23 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a reviewer: shafik.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Otherwise we may be inserting a decl into a DeclContext that's not fully 
defined yet.

GetCPlusPlusQualifiedName() doesn't care about exact spacing between '>', the 
names it gives just need to be unique. Places that use 
GetDIEClassTemplateParams() do care about exact spacing (at least until that 
issue is solved generally).

Reverts part of D138834 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142413

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/test/API/lang/cpp/nested-template/Makefile
  lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
  lldb/test/API/lang/cpp/nested-template/main.cpp

Index: lldb/test/API/lang/cpp/nested-template/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/main.cpp
@@ -0,0 +1,11 @@
+struct Outer {
+  Outer() {}
+
+  template 
+  struct Inner {};
+};
+
+int main() {
+  Outer::Inner oi;
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/TestNestedTemplate.py
@@ -0,0 +1,24 @@
+"""
+Test that a nested template parameter works with simple template names.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class NestedTemplateTestCase(TestBase):
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+self.expect("image lookup -A -t 'Inner'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/nested-template/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/nested-template/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS = $(TEST_CFLAGS_EXTRAS) $(LIMIT_DEBUG_INFO_FLAGS)
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -95,10 +95,10 @@
   /// parameters from the DIE name and instead always adds template parameter
   /// children DIEs.
   ///
-  /// Currently this is only called in two places, when uniquing C++ classes and
-  /// when looking up the definition for a declaration (which is then cached).
-  /// If this is ever called more than twice per DIE, we need to start caching
-  /// the results to prevent unbounded growth of the created clang AST nodes.
+  /// Currently this is only called when looking up the definition for a
+  /// declaration (which is then cached).  If this is ever called more than once
+  /// per DIE, we need to start caching the results to prevent unbounded growth
+  /// of the created clang AST nodes.
   ///
   /// \param die The struct/class DWARFDIE containing template parameters.
   /// \return A string, including surrounding '<>', of the template parameters.
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1530,6 +1530,41 @@
   return type_sp;
 }
 
+std::string
+DWARFASTParserClang::GetTemplateParametersString(const DWARFDIE ) {
+  if (llvm::StringRef(die.GetName()).contains("<"))
+return std::string();
+  TypeSystemClang::TemplateParameterInfos template_param_infos;
+  if (!ParseTemplateParameterInfos(die, template_param_infos))
+return std::string();
+  std::string all_template_names;
+  llvm::SmallVector args =
+  template_param_infos.args;
+  if (template_param_infos.hasParameterPack())
+args.append(template_param_infos.packed_args->args);
+  if (args.empty())
+return std::string();
+  for (auto  : args) {
+std::string template_name;
+llvm::raw_string_ostream os(template_name);
+

[Lldb-commits] [PATCH] D140240: [lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes

2022-12-20 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd483d488ca5d: [lldb] Prevent false positives with simple 
template names in SymbolFileDWARF… (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140240

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/source/Symbol/TypeSystem.cpp
  lldb/test/API/lang/cpp/unique-types4/Makefile
  lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
  lldb/test/API/lang/cpp/unique-types4/main.cpp

Index: lldb/test/API/lang/cpp/unique-types4/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/main.cpp
@@ -0,0 +1,23 @@
+namespace ns {
+
+template  struct Foo {
+  static T value;
+};
+
+template  using Bar = Foo;
+
+using FooInt = Foo;
+using FooDouble = Foo;
+
+} // namespace ns
+
+ns::Foo a;
+ns::Foo b;
+ns::Bar c;
+ns::Bar d;
+ns::FooInt e;
+ns::FooDouble f;
+
+int main() {
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
@@ -0,0 +1,31 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase4(TestBase):
+def do_test(self, debug_flags):
+"""Test that we display the correct template instantiation."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+# FIXME: these should successfully print the values
+self.expect("print ns::Foo::value", substrs=["no member named"], error=True)
+self.expect("print ns::Foo::value", substrs=["no member named"], error=True)
+self.expect("print ns::Bar::value", substrs=["no member named"], error=True)
+self.expect("print ns::Bar::value", substrs=["no member named"], error=True)
+self.expect("print ns::FooDouble::value", substrs=["Couldn't lookup symbols"], error=True)
+self.expect("print ns::FooInt::value", substrs=["Couldn't lookup symbols"], error=True)
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/unique-types4/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Symbol/TypeSystem.cpp
===
--- lldb/source/Symbol/TypeSystem.cpp
+++ lldb/source/Symbol/TypeSystem.cpp
@@ -116,6 +116,10 @@
   return CompilerType(weak_from_this(), type);
 }
 
+bool TypeSystem::IsTemplateType(lldb::opaque_compiler_type_t type) {
+  return false;
+}
+
 size_t TypeSystem::GetNumTemplateArguments(lldb::opaque_compiler_type_t type,
bool expand_pack) {
   return 0;
Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -393,6 +393,10 @@
   return GetForwardCompilerType().IsAggregateType();
 }
 
+bool Type::IsTemplateType() {
+  return GetForwardCompilerType().IsTemplateType();
+}
+
 lldb::TypeSP Type::GetTypedefType() {
   lldb::TypeSP type_sp;
   if (IsTypedef()) {
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -260,6 +260,13 @@
   return false;
 }
 
+bool CompilerType::IsTemplateType() const {
+  if (IsValid())
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->IsTemplateType(m_type);
+  return false;
+}
+
 bool CompilerType::IsTypedefType() const {
   if (IsValid())
 if (auto type_system_sp = GetTypeSystem())
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- 

[Lldb-commits] [PATCH] D140240: [lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes

2022-12-20 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2521
+if (name_bracket_index == llvm::StringRef::npos &&
+matching_type->IsTemplateType())
+  return true;

Michael137 wrote:
> You could consider using `CompilerType::GetTypeInfo` instead of introducing 
> `CompilerType::IsTemplateType`. Though that function looks a bit chunky
just tried this but it's recognizing the type as just a normal record instead 
of a template instantiation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140240

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


[Lldb-commits] [PATCH] D140240: [lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes

2022-12-19 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py:15
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", 
lldb.SBFileSpec("main.cpp"))
+# FIXME: these should successfully print the values
+self.expect("print ns::Foo::value", substrs=["no member 
named"], error=True)

this makes handling of -gsimple-template-names the same as the current handling 
of -gno-simple-template-names

I haven't dug too deep into the existing difference between 
`FooDouble`/`FooInt` vs the others

for the "no member named" errors, I believe clang is attempting to get the 
uninstantiated declarations of `Foo`/`Bar`, which the dwarf knows nothing about


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140240

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


[Lldb-commits] [PATCH] D140240: [lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes

2022-12-19 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 484077.
aeubanks added a comment.

check if type is template by looking at underlying clang Type, rather than 
looking for a '<'
properly handle typedefs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140240

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/source/Symbol/TypeSystem.cpp
  lldb/test/API/lang/cpp/unique-types4/Makefile
  lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
  lldb/test/API/lang/cpp/unique-types4/main.cpp

Index: lldb/test/API/lang/cpp/unique-types4/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/main.cpp
@@ -0,0 +1,23 @@
+namespace ns {
+
+template  struct Foo {
+  static T value;
+};
+
+template  using Bar = Foo;
+
+using FooInt = Foo;
+using FooDouble = Foo;
+
+} // namespace ns
+
+ns::Foo a;
+ns::Foo b;
+ns::Bar c;
+ns::Bar d;
+ns::FooInt e;
+ns::FooDouble f;
+
+int main() {
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
@@ -0,0 +1,31 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase4(TestBase):
+def do_test(self, debug_flags):
+"""Test that we display the correct template instantiation."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+# FIXME: these should successfully print the values
+self.expect("print ns::Foo::value", substrs=["no member named"], error=True)
+self.expect("print ns::Foo::value", substrs=["no member named"], error=True)
+self.expect("print ns::Bar::value", substrs=["no member named"], error=True)
+self.expect("print ns::Bar::value", substrs=["no member named"], error=True)
+self.expect("print ns::FooDouble::value", substrs=["Couldn't lookup symbols"], error=True)
+self.expect("print ns::FooInt::value", substrs=["Couldn't lookup symbols"], error=True)
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/unique-types4/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Symbol/TypeSystem.cpp
===
--- lldb/source/Symbol/TypeSystem.cpp
+++ lldb/source/Symbol/TypeSystem.cpp
@@ -116,6 +116,10 @@
   return CompilerType(weak_from_this(), type);
 }
 
+bool TypeSystem::IsTemplateType(lldb::opaque_compiler_type_t type) {
+  return false;
+}
+
 size_t TypeSystem::GetNumTemplateArguments(lldb::opaque_compiler_type_t type,
bool expand_pack) {
   return 0;
Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -393,6 +393,10 @@
   return GetForwardCompilerType().IsAggregateType();
 }
 
+bool Type::IsTemplateType() {
+  return GetForwardCompilerType().IsTemplateType();
+}
+
 lldb::TypeSP Type::GetTypedefType() {
   lldb::TypeSP type_sp;
   if (IsTypedef()) {
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -260,6 +260,13 @@
   return false;
 }
 
+bool CompilerType::IsTemplateType() const {
+  if (IsValid())
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->IsTemplateType(m_type);
+  return false;
+}
+
 bool CompilerType::IsTypedefType() const {
   if (IsValid())
 if (auto type_system_sp = GetTypeSystem())
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- 

[Lldb-commits] [PATCH] D140240: [lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes

2022-12-16 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2519
+GetTypeForDIE(die)->GetBaseName().AsCString();
+if (name_bracket_index == llvm::StringRef::npos && base_name.contains('<'))
+  return true;

I'm looking into whether or not this can be sped up by checking if the type is 
templated some other way


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140240

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


[Lldb-commits] [PATCH] D140240: [lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes

2022-12-16 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The provided test case was crashing because of confusion attempting to find 
types for `ns::Foo` under -gsimple-template-names. (This looks broken normally 
because it's attempting to find `ns::Foo` rather than `ns::Foo`)

Looking up types can't give false positives, as opposed to looking up functions 
as mentioned in https://reviews.llvm.org/D137098.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140240

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/lang/cpp/unique-types4/Makefile
  lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
  lldb/test/API/lang/cpp/unique-types4/main.cpp

Index: lldb/test/API/lang/cpp/unique-types4/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/main.cpp
@@ -0,0 +1,14 @@
+namespace ns {
+
+template  struct Foo {
+  static T value;
+};
+
+} // namespace ns
+
+ns::Foo a;
+ns::Foo b;
+
+int main() {
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
@@ -0,0 +1,27 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase4(TestBase):
+def do_test(self, debug_flags):
+"""Test that we display the correct template instantiation."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+# FIXME: thes should successfully print the values
+self.expect("print ns::Foo::value", "failed to parse", error=True)
+self.expect("print ns::Foo::value", "failed to parse", error=True)
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/unique-types4/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types4/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2501,6 +2501,8 @@
   if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
 return;
 
+  const llvm::StringRef name_ref = name.GetStringRef();
+  auto name_bracket_index = name_ref.find('<');
   m_index->GetTypes(name, [&](DWARFDIE die) {
 if (!DIEInDeclContext(parent_decl_ctx, die))
   return true; // The containing decl contexts don't match
@@ -2509,6 +2511,14 @@
 if (!matching_type)
   return true;
 
+// With -gsimple-template-names, a templated type's DW_AT_name will not
+// contain the template parameters. Make sure that if the original query
+// didn't contain a '<', we filter out entries with template parameters.
+const llvm::StringRef base_name =
+GetTypeForDIE(die)->GetBaseName().AsCString();
+if (name_bracket_index == llvm::StringRef::npos && base_name.contains('<'))
+  return true;
+
 // We found a type pointer, now find the shared pointer form our type
 // list
 types.InsertUnique(matching_type->shared_from_this());
@@ -2519,11 +2529,11 @@
   // contain the template parameters. Try again stripping '<' and anything
   // after, filtering out entries with template parameters that don't match.
   if (types.GetSize() < max_matches) {
-const llvm::StringRef name_ref = name.GetStringRef();
-auto it = name_ref.find('<');
-if (it != llvm::StringRef::npos) {
-  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
-  const llvm::StringRef template_params = name_ref.slice(it, name_ref.size());
+if (name_bracket_index != llvm::StringRef::npos) {
+  const llvm::StringRef name_no_template_params =
+  name_ref.slice(0, name_bracket_index);
+  const llvm::StringRef template_params =
+  name_ref.slice(name_bracket_index, name_ref.size());
   m_index->GetTypes(ConstString(name_no_template_params), [&](DWARFDIE die) {
 if (!DIEInDeclContext(parent_decl_ctx, die))
   return 

[Lldb-commits] [PATCH] D139649: [lldb] Make ParseTemplateParameterInfos return false if there are no template params

2022-12-12 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG81f1f6db40ab: [lldb] Make ParseTemplateParameterInfos return 
false if there are no template… (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139649

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


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -747,9 +747,7 @@
 
   clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, 
nullptr);
   TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos) &&
-  (!template_param_infos.args.empty() ||
-   template_param_infos.packed_args)) {
+  if (ParseTemplateParameterInfos(die, template_param_infos)) {
 // Most of the parameters here don't matter, but we make sure the base name
 // is empty so when we print the name we only get the template parameters.
 clang::ClassTemplateDecl *class_template_decl =
@@ -1787,9 +1785,7 @@
 metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
 
 TypeSystemClang::TemplateParameterInfos template_param_infos;
-if (ParseTemplateParameterInfos(die, template_param_infos) &&
-(!template_param_infos.args.empty() ||
- template_param_infos.packed_args)) {
+if (ParseTemplateParameterInfos(die, template_param_infos)) {
   clang::ClassTemplateDecl *class_template_decl =
   m_ast.ParseClassTemplateDecl(
   decl_ctx, GetOwningClangModule(die), attrs.accessibility,
@@ -2123,7 +2119,10 @@
   break;
 }
   }
-  return template_param_infos.args.size() == template_param_infos.names.size();
+  return template_param_infos.args.size() ==
+ template_param_infos.names.size() &&
+ (!template_param_infos.args.empty() ||
+  template_param_infos.packed_args);
 }
 
 bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE ,


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -747,9 +747,7 @@
 
   clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, nullptr);
   TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos) &&
-  (!template_param_infos.args.empty() ||
-   template_param_infos.packed_args)) {
+  if (ParseTemplateParameterInfos(die, template_param_infos)) {
 // Most of the parameters here don't matter, but we make sure the base name
 // is empty so when we print the name we only get the template parameters.
 clang::ClassTemplateDecl *class_template_decl =
@@ -1787,9 +1785,7 @@
 metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
 
 TypeSystemClang::TemplateParameterInfos template_param_infos;
-if (ParseTemplateParameterInfos(die, template_param_infos) &&
-(!template_param_infos.args.empty() ||
- template_param_infos.packed_args)) {
+if (ParseTemplateParameterInfos(die, template_param_infos)) {
   clang::ClassTemplateDecl *class_template_decl =
   m_ast.ParseClassTemplateDecl(
   decl_ctx, GetOwningClangModule(die), attrs.accessibility,
@@ -2123,7 +2119,10 @@
   break;
 }
   }
-  return template_param_infos.args.size() == template_param_infos.names.size();
+  return template_param_infos.args.size() ==
+ template_param_infos.names.size() &&
+ (!template_param_infos.args.empty() ||
+  template_param_infos.packed_args);
 }
 
 bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE ,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D139649: [lldb] Make ParseTemplateParameterInfos return false if there are no template params

2022-12-09 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 481711.
aeubanks added a comment.

revert one change to make this nfc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139649

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


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -747,9 +747,7 @@
 
   clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, 
nullptr);
   TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos) &&
-  (!template_param_infos.args.empty() ||
-   template_param_infos.packed_args)) {
+  if (ParseTemplateParameterInfos(die, template_param_infos)) {
 // Most of the parameters here don't matter, but we make sure the base name
 // is empty so when we print the name we only get the template parameters.
 clang::ClassTemplateDecl *class_template_decl =
@@ -1787,9 +1785,7 @@
 metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
 
 TypeSystemClang::TemplateParameterInfos template_param_infos;
-if (ParseTemplateParameterInfos(die, template_param_infos) &&
-(!template_param_infos.args.empty() ||
- template_param_infos.packed_args)) {
+if (ParseTemplateParameterInfos(die, template_param_infos)) {
   clang::ClassTemplateDecl *class_template_decl =
   m_ast.ParseClassTemplateDecl(
   decl_ctx, GetOwningClangModule(die), attrs.accessibility,
@@ -2123,7 +2119,10 @@
   break;
 }
   }
-  return template_param_infos.args.size() == template_param_infos.names.size();
+  return template_param_infos.args.size() ==
+ template_param_infos.names.size() &&
+ (!template_param_infos.args.empty() ||
+  template_param_infos.packed_args);
 }
 
 bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE ,


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -747,9 +747,7 @@
 
   clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, nullptr);
   TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos) &&
-  (!template_param_infos.args.empty() ||
-   template_param_infos.packed_args)) {
+  if (ParseTemplateParameterInfos(die, template_param_infos)) {
 // Most of the parameters here don't matter, but we make sure the base name
 // is empty so when we print the name we only get the template parameters.
 clang::ClassTemplateDecl *class_template_decl =
@@ -1787,9 +1785,7 @@
 metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
 
 TypeSystemClang::TemplateParameterInfos template_param_infos;
-if (ParseTemplateParameterInfos(die, template_param_infos) &&
-(!template_param_infos.args.empty() ||
- template_param_infos.packed_args)) {
+if (ParseTemplateParameterInfos(die, template_param_infos)) {
   clang::ClassTemplateDecl *class_template_decl =
   m_ast.ParseClassTemplateDecl(
   decl_ctx, GetOwningClangModule(die), attrs.accessibility,
@@ -2123,7 +2119,10 @@
   break;
 }
   }
-  return template_param_infos.args.size() == template_param_infos.names.size();
+  return template_param_infos.args.size() ==
+ template_param_infos.names.size() &&
+ (!template_param_infos.args.empty() ||
+  template_param_infos.packed_args);
 }
 
 bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE ,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D139649: [lldb] Make ParseTemplateParameterInfos return false if there are no template params

2022-12-08 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1251
+  if (has_template_params &&
+  ParseTemplateParameterInfos(die, template_param_infos)) {
+template_function_decl = m_ast.CreateFunctionDeclaration(

dblaikie wrote:
> This part changes behavior, yeah? (previously the code was only conditional 
> on `has_template_params` and is now conditional on both that and there 
> actually being template parameter DIEs) Was that intended? If so, is there 
> any testing that could be done to demonstrate the change in behavior?
presumably any visible change would only happen with broken debug info

`has_template_params` is true if there are any template parameter child DIEs, 
but now we do more checking that those DIEs are actually reasonable

I can revert this back if you want, but this seems better and I don't think I'm 
going to find time to add a test for broken debug info which may or may not 
actually hit this code path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139649

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


[Lldb-commits] [PATCH] D139649: [lldb] Make ParseTemplateParameterInfos return false if there are no template params

2022-12-08 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a reviewer: shafik.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This factors out the check from various callers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139649

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


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -747,9 +747,7 @@
 
   clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, 
nullptr);
   TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos) &&
-  (!template_param_infos.args.empty() ||
-   template_param_infos.packed_args)) {
+  if (ParseTemplateParameterInfos(die, template_param_infos)) {
 // Most of the parameters here don't matter, but we make sure the base name
 // is empty so when we print the name we only get the template parameters.
 clang::ClassTemplateDecl *class_template_decl =
@@ -1247,20 +1245,23 @@
 attrs.is_inline);
 std::free(name_buf);
 
-if (has_template_params) {
+{
   TypeSystemClang::TemplateParameterInfos template_param_infos;
-  ParseTemplateParameterInfos(die, template_param_infos);
-  template_function_decl = m_ast.CreateFunctionDeclaration(
-  ignore_containing_context ? m_ast.GetTranslationUnitDecl()
-: containing_decl_ctx,
-  GetOwningClangModule(die), attrs.name.GetStringRef(), clang_type,
-  attrs.storage, attrs.is_inline);
-  clang::FunctionTemplateDecl *func_template_decl =
-  m_ast.CreateFunctionTemplateDecl(
-  containing_decl_ctx, GetOwningClangModule(die),
-  template_function_decl, template_param_infos);
-  m_ast.CreateFunctionTemplateSpecializationInfo(
-  template_function_decl, func_template_decl, 
template_param_infos);
+  if (has_template_params &&
+  ParseTemplateParameterInfos(die, template_param_infos)) {
+template_function_decl = m_ast.CreateFunctionDeclaration(
+ignore_containing_context ? m_ast.GetTranslationUnitDecl()
+  : containing_decl_ctx,
+GetOwningClangModule(die), attrs.name.GetStringRef(),
+clang_type, attrs.storage, attrs.is_inline);
+clang::FunctionTemplateDecl *func_template_decl =
+m_ast.CreateFunctionTemplateDecl(
+containing_decl_ctx, GetOwningClangModule(die),
+template_function_decl, template_param_infos);
+m_ast.CreateFunctionTemplateSpecializationInfo(
+template_function_decl, func_template_decl,
+template_param_infos);
+  }
 }
 
 lldbassert(function_decl);
@@ -1787,9 +1788,7 @@
 metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
 
 TypeSystemClang::TemplateParameterInfos template_param_infos;
-if (ParseTemplateParameterInfos(die, template_param_infos) &&
-(!template_param_infos.args.empty() ||
- template_param_infos.packed_args)) {
+if (ParseTemplateParameterInfos(die, template_param_infos)) {
   clang::ClassTemplateDecl *class_template_decl =
   m_ast.ParseClassTemplateDecl(
   decl_ctx, GetOwningClangModule(die), attrs.accessibility,
@@ -2123,7 +2122,10 @@
   break;
 }
   }
-  return template_param_infos.args.size() == template_param_infos.names.size();
+  return template_param_infos.args.size() ==
+ template_param_infos.names.size() &&
+ (!template_param_infos.args.empty() ||
+  template_param_infos.packed_args);
 }
 
 bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE ,


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -747,9 +747,7 @@
 
   clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE(die, nullptr);
   TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos) &&
-  (!template_param_infos.args.empty() ||
-   template_param_infos.packed_args)) {
+  if (ParseTemplateParameterInfos(die, template_param_infos)) {
 // Most of the parameters here don't matter, but we make sure the base name
 // is empty so when we print the name we only get the template parameters.
 

[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-12-08 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc0ac25f1acc4: [lldb] Fix simple template names interaction 
with debug info declarations (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138834

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/lang/cpp/unique-types3/Makefile
  lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
  lldb/test/API/lang/cpp/unique-types3/a.cpp
  lldb/test/API/lang/cpp/unique-types3/a.h
  lldb/test/API/lang/cpp/unique-types3/main.cpp

Index: lldb/test/API/lang/cpp/unique-types3/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/main.cpp
@@ -0,0 +1,9 @@
+#include "a.h"
+
+S a1;
+S a2;
+S a3;
+
+void f(S &);
+
+int main() { f(a2); }
Index: lldb/test/API/lang/cpp/unique-types3/a.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.h
@@ -0,0 +1,3 @@
+template  struct S {
+  T t;
+};
Index: lldb/test/API/lang/cpp/unique-types3/a.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.cpp
@@ -0,0 +1,5 @@
+#include "a.h"
+
+void f(S ) {
+  (void)a; // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
@@ -0,0 +1,27 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase3(TestBase):
+def do_test(self, debug_flags):
+"""Test that we display the correct template instantiation."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("a.cpp"))
+self.expect_expr("a", result_type="S")
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+# Can't directly set CFLAGS_EXTRAS here because the Makefile can't
+# override an environment variable.
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/unique-types3/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp a.cpp
+
+CFLAGS_EXTRAS = $(TEST_CFLAGS_EXTRAS) $(LIMIT_DEBUG_INFO_FLAGS)
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2978,6 +2978,15 @@
   }
 }
 
+// See comments below about -gsimple-template-names for why we attempt to
+// compute missing template parameter names.
+ConstString template_params;
+if (type_system) {
+  DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+  if (dwarf_ast)
+template_params = dwarf_ast->GetDIEClassTemplateParams(die);
+}
+
 m_index->GetTypes(GetDWARFDeclContext(die), [&](DWARFDIE type_die) {
   // Make sure type_die's language matches the type system we are
   // looking for. We don't want to find a "Foo" type from Java if we
@@ -3049,6 +3058,27 @@
   if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
 return true;
 
+  // With -gsimple-template-names, the DIE name may not contain the template
+  // parameters. If the declaration has template parameters but doesn't
+  // contain '<', check that the child template parameters match.
+  if (template_params) {
+llvm::StringRef test_base_name =
+GetTypeForDIE(type_die)->GetBaseName().GetStringRef();
+auto i = test_base_name.find('<');
+
+// Full name from clang AST doesn't contain '<' so this type_die isn't
+// a template parameter, but we're expecting template parameters, so
+// bail.
+if (i == llvm::StringRef::npos)
+  return true;
+
+llvm::StringRef test_template_params =
+test_base_name.slice(i, test_base_name.size());
+   

[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-12-06 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:765
+m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
+return clang_type.GetTypeName(/*BaseOnly*/ true);
+  }

Michael137 wrote:
> aeubanks wrote:
> > Michael137 wrote:
> > > Michael137 wrote:
> > > > Ok so what we're doing is:
> > > > 1. Create a `ClassTemplateSpecializationDecl` with an empty basename
> > > > 2. Return the type-name and since the basename is empty we end up with 
> > > > just the template arguments
> > > > 
> > > > Why can't we just call `GetTemplateParametersString(die)` instead of 
> > > > creating this function?
> > > Can confirm that this works locally. Though required moving that function 
> > > out of the DWARFASTParserClang, which seems OK
> > `GetTemplateParametersString` is specifically only used for 
> > `GetCPlusPlusQualifiedName`, which is used below
> > ```
> >   // For C++, we rely solely upon the one definition rule that says
> >   // only one thing can exist at a given decl context. We ignore the
> >   // file and line that things are declared on.
> >   std::string qualified_name = GetCPlusPlusQualifiedName(die);
> > ```
> > so it doesn't have to match clang's printing. but for the simple template 
> > name stuff, we are comparing clang-generated names, so everything needs to 
> > go through clang.
> > 
> > I've replaced `GetTemplateParametersString` with this code that goes 
> > through clang as well
> But didn't `GetTemplateParametersString` go through Clang's type printer too? 
> Probably missing something.
> What would be an example of the difference in output that could arise between 
> the new vs. old method?
one thing that I was aware of even initially implementing 
`GetTemplateParametersString` was spacing between two `>`, clang will add a 
space (unless you tell it not to), whereas the naive implementation didn't


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138834

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


[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-12-02 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:765
+m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
+return clang_type.GetTypeName(/*BaseOnly*/ true);
+  }

Michael137 wrote:
> Michael137 wrote:
> > Ok so what we're doing is:
> > 1. Create a `ClassTemplateSpecializationDecl` with an empty basename
> > 2. Return the type-name and since the basename is empty we end up with just 
> > the template arguments
> > 
> > Why can't we just call `GetTemplateParametersString(die)` instead of 
> > creating this function?
> Can confirm that this works locally. Though required moving that function out 
> of the DWARFASTParserClang, which seems OK
`GetTemplateParametersString` is specifically only used for 
`GetCPlusPlusQualifiedName`, which is used below
```
  // For C++, we rely solely upon the one definition rule that says
  // only one thing can exist at a given decl context. We ignore the
  // file and line that things are declared on.
  std::string qualified_name = GetCPlusPlusQualifiedName(die);
```
so it doesn't have to match clang's printing. but for the simple template name 
stuff, we are comparing clang-generated names, so everything needs to go 
through clang.

I've replaced `GetTemplateParametersString` with this code that goes through 
clang as well



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2988
+template_params =
+dwarf_ast->GetForwardDeclarationDIETemplateParams(die);
+}

Michael137 wrote:
> So after this call we'll have an unnamed `ClassTemplateDecl` hanging off the 
> AST? Doing this inside `FindDefinitionTypeForDWARFDeclContext` instead of 
> `ParseStructureLikeDIE` feels a bit off. But will have to understand this 
> change a bit deeper to know whether there is something we can do about that.
> 
> As a side-note, we seem to be accumulating a lot of blocks around LLDB that 
> look like:
> ```
> // Do X because -gsimple-template-names
> if (name.contains('<')) {
>// Do something
> }
> ```
> Still wonder if there isn't some flag that can be set on, e.g., a CU, that 
> would tell us this.
the effect is not really per-CU but rather per-DIE because in some cases (where 
DWARF roundtripping is lossy, @dblaikie would know best) we still put template 
params in the name. so it needs to be checked per-DIE

I agree that it's weird to create clang AST nodes here and then forget about 
them, but clang uses a bump allocator and we can't easily delete it. As long as 
we call this at most once or twice per DIE, I don't think it's worth caching 
the results, but if we do end up using this more, we do need to cache the 
created AST nodes. I've added a comment to the docstring.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138834

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


[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-12-02 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 479759.
aeubanks marked 2 inline comments as done.
aeubanks added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138834

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/lang/cpp/unique-types3/Makefile
  lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
  lldb/test/API/lang/cpp/unique-types3/a.cpp
  lldb/test/API/lang/cpp/unique-types3/a.h
  lldb/test/API/lang/cpp/unique-types3/main.cpp

Index: lldb/test/API/lang/cpp/unique-types3/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/main.cpp
@@ -0,0 +1,9 @@
+#include "a.h"
+
+S a1;
+S a2;
+S a3;
+
+void f(S &);
+
+int main() { f(a2); }
Index: lldb/test/API/lang/cpp/unique-types3/a.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.h
@@ -0,0 +1,3 @@
+template  struct S {
+  T t;
+};
Index: lldb/test/API/lang/cpp/unique-types3/a.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.cpp
@@ -0,0 +1,5 @@
+#include "a.h"
+
+void f(S ) {
+  (void)a; // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
@@ -0,0 +1,27 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase3(TestBase):
+def do_test(self, debug_flags):
+"""Test that we display the correct template instantiation."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("a.cpp"))
+self.expect_expr("a", result_type="S")
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+# Can't directly set CFLAGS_EXTRAS here because the Makefile can't
+# override an environment variable.
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/unique-types3/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp a.cpp
+
+CFLAGS_EXTRAS = $(TEST_CFLAGS_EXTRAS) $(LIMIT_DEBUG_INFO_FLAGS)
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2978,6 +2978,15 @@
   }
 }
 
+// See comments below about -gsimple-template-names for why we attempt to
+// compute missing template parameter names.
+ConstString template_params;
+if (type_system) {
+  DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+  if (dwarf_ast)
+template_params = dwarf_ast->GetDIEClassTemplateParams(die);
+}
+
 m_index->GetTypes(GetDWARFDeclContext(die), [&](DWARFDIE type_die) {
   // Make sure type_die's language matches the type system we are
   // looking for. We don't want to find a "Foo" type from Java if we
@@ -3049,6 +3058,27 @@
   if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
 return true;
 
+  // With -gsimple-template-names, the DIE name may not contain the template
+  // parameters. If the declaration has template parameters but doesn't
+  // contain '<', check that the child template parameters match.
+  if (template_params) {
+llvm::StringRef test_base_name =
+GetTypeForDIE(type_die)->GetBaseName().GetStringRef();
+auto i = test_base_name.find('<');
+
+// Full name from clang AST doesn't contain '<' so this type_die isn't
+// a template parameter, but we're expecting template parameters, so
+// bail.
+if (i == llvm::StringRef::npos)
+  return true;
+
+llvm::StringRef test_template_params =
+test_base_name.slice(i, test_base_name.size());
+// Bail if template parameters don't match.
+if 

[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-11-30 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 479061.
aeubanks added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138834

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/lang/cpp/unique-types3/Makefile
  lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
  lldb/test/API/lang/cpp/unique-types3/a.cpp
  lldb/test/API/lang/cpp/unique-types3/a.h
  lldb/test/API/lang/cpp/unique-types3/main.cpp

Index: lldb/test/API/lang/cpp/unique-types3/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/main.cpp
@@ -0,0 +1,9 @@
+#include "a.h"
+
+S a1;
+S a2;
+S a3;
+
+void f(S &);
+
+int main() { f(a2); }
Index: lldb/test/API/lang/cpp/unique-types3/a.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.h
@@ -0,0 +1,3 @@
+template  struct S {
+  T t;
+};
Index: lldb/test/API/lang/cpp/unique-types3/a.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.cpp
@@ -0,0 +1,5 @@
+#include "a.h"
+
+void f(S ) {
+  (void)a; // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
@@ -0,0 +1,27 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase3(TestBase):
+def do_test(self, debug_flags):
+"""Test that we display the correct template instantiation."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("a.cpp"))
+self.expect_expr("a", result_type="S")
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+# Can't directly set CFLAGS_EXTRAS here because the Makefile can't
+# override an environment variable.
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/unique-types3/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp a.cpp
+
+CFLAGS_EXTRAS = $(TEST_CFLAGS_EXTRAS) $(LIMIT_DEBUG_INFO_FLAGS)
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2978,6 +2978,16 @@
   }
 }
 
+// See comments below about -gsimple-template-names for why we attempt to
+// compute missing template parameter names.
+ConstString template_params;
+if (type_system && !llvm::StringRef(die.GetName()).contains('<')) {
+  DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+  if (dwarf_ast)
+template_params =
+dwarf_ast->GetForwardDeclarationDIETemplateParams(die);
+}
+
 m_index->GetTypes(GetDWARFDeclContext(die), [&](DWARFDIE type_die) {
   // Make sure type_die's language matches the type system we are
   // looking for. We don't want to find a "Foo" type from Java if we
@@ -3049,6 +3059,27 @@
   if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
 return true;
 
+  // With -gsimple-template-names, the DIE name may not contain the template
+  // parameters. If we've the declaration has template parameters but
+  // doesn't contain '<', check that the child template parameters match.
+  if (template_params) {
+llvm::StringRef test_base_name =
+GetTypeForDIE(type_die)->GetBaseName().GetStringRef();
+auto i = test_base_name.find('<');
+
+// Full name from clang AST doesn't contain '<' so this type_die isn't
+// a template parameter, but we're expecting template parameters, so
+// bail.
+if (i == llvm::StringRef::npos)
+  return true;
+
+llvm::StringRef test_template_params =
+test_base_name.slice(i, test_base_name.size());
+// Bail if template parameters don't 

[Lldb-commits] [PATCH] D138612: [lldb] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-30 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61aed52c9ec0: [lldb] Change 
FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,112 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  if (die.GetName()) {
+const 

[Lldb-commits] [PATCH] D138612: [lldb] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-30 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

I borrowed a mac and verified that this patch fixes the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

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


[Lldb-commits] [PATCH] D138612: [lldb] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-30 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 479056.
aeubanks added a comment.

go back to calling m_index->GetTypes(DWARFDeclContext) instead of 
m_index->GetTypes(StringRef)

these have different codepaths, I mistakenly thought they were equivalent


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,112 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  if (die.GetName()) {
+const dw_tag_t tag = 

[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-11-28 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:747-749
+  if (ParseTemplateParameterInfos(die, template_param_infos) &&
+  (!template_param_infos.args.empty() ||
+   template_param_infos.packed_args)) {

dblaikie wrote:
> Could invert this condition and use an early `return ConstString();` to 
> reduce indentation - but I guess this looks more similar to the definition 
> handling case and so might be worth keeping in the same shape. (maybe 
> `ParseTemplateParameterInfos` should return true only if the result is !empty 
> or has packed args, so that test doesn't need to be repeated at multiple 
> callers?)
I'll clean this up after this patch lands



Comment at: lldb/test/API/lang/cpp/unique-types3/main.cpp:1-14
+#include 
+#include 
+
+std::atomic a1;
+std::atomic a2;
+std::atomic a3;
+

dblaikie wrote:
> maybe good to simplify this a bit - rather than using big/complex templates 
> like std::atomic and std::vector, instead using test-only, simpler templates 
> to keep the test a bit more focussed (less likely to fail for unrelated 
> reasons/other regressions)?
hmm I swear I tried that and it ended up passing, although that might have been 
before I figured out the Makefile env var vs normal var issue. done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138834

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


[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-11-28 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 478323.
aeubanks marked an inline comment as done.
aeubanks added a comment.

don't use stl in test
simplify some code a bit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138834

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/lang/cpp/unique-types3/Makefile
  lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
  lldb/test/API/lang/cpp/unique-types3/a.cpp
  lldb/test/API/lang/cpp/unique-types3/a.h
  lldb/test/API/lang/cpp/unique-types3/main.cpp

Index: lldb/test/API/lang/cpp/unique-types3/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/main.cpp
@@ -0,0 +1,9 @@
+#include "a.h"
+
+S a1;
+S a2;
+S a3;
+
+void f(S &);
+
+int main() { f(a2); }
Index: lldb/test/API/lang/cpp/unique-types3/a.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.h
@@ -0,0 +1,3 @@
+template  struct S {
+  T t;
+};
Index: lldb/test/API/lang/cpp/unique-types3/a.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.cpp
@@ -0,0 +1,5 @@
+#include "a.h"
+
+void f(S ) {
+  (void)a; // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
@@ -0,0 +1,27 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase3(TestBase):
+def do_test(self, debug_flags):
+"""Test that we display the correct template instantiation."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("a.cpp"))
+self.expect_expr("a", result_type="S")
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+# Can't directly set CFLAGS_EXTRAS here because the Makefile can't
+# override an environment variable.
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/unique-types3/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp a.cpp
+
+CFLAGS_EXTRAS = $(TEST_CFLAGS_EXTRAS) $(LIMIT_DEBUG_INFO_FLAGS)
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2979,6 +2979,16 @@
   }
 }
 
+// See comments below about -gsimple-template-names for why we attempt to
+// compute missing template parameter names.
+ConstString template_params;
+if (type_system && !type_name.GetStringRef().contains('<')) {
+  DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+  if (dwarf_ast)
+template_params =
+dwarf_ast->GetForwardDeclarationDIETemplateParams(die);
+}
+
 m_index->GetTypes(type_name, [&](DWARFDIE type_die) {
   // Make sure type_die's language matches the type system we are
   // looking for. We don't want to find a "Foo" type from Java if we
@@ -3050,6 +3060,27 @@
   if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
 return true;
 
+  // With -gsimple-template-names, the DIE name may not contain the template
+  // parameters. If we've the declaration has template parameters but
+  // doesn't contain '<', check that the child template parameters match.
+  if (template_params) {
+llvm::StringRef test_base_name =
+GetTypeForDIE(type_die)->GetBaseName().GetStringRef();
+auto i = test_base_name.find('<');
+
+// Full name from clang AST doesn't contain '<' so this type_die isn't
+// a template parameter, but we're expecting template parameters, so
+// bail.
+if (i == llvm::StringRef::npos)
+  return true;
+
+llvm::StringRef test_template_params =
+test_base_name.slice(i, 

[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-11-28 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

depends on D132624 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138834

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


[Lldb-commits] [PATCH] D138834: [lldb] Fix simple template names interaction with debug info declarations

2022-11-28 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a reviewer: shafik.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Without checking template parameters, we would sometimes lookup the
wrong type definition for a type declaration because different
instantiations of the same template class had the same debug info name.

The added GetForwardDeclarationDIETemplateParams() shouldn't need a
cache because we'll cache the results of the declaration -> definition
lookup anyway. (DWARFASTParserClang::ParseStructureLikeDIE()
is_forward_declaration branch)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138834

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/lang/cpp/unique-types3/Makefile
  lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
  lldb/test/API/lang/cpp/unique-types3/a.cpp
  lldb/test/API/lang/cpp/unique-types3/main.cpp

Index: lldb/test/API/lang/cpp/unique-types3/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+
+std::atomic a1;
+std::atomic a2;
+std::atomic a3;
+
+std::vector v1;
+std::vector v2;
+std::vector v3;
+
+void f(std::atomic &, std::vector &);
+
+int main() { f(a2, v2); }
Index: lldb/test/API/lang/cpp/unique-types3/a.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/a.cpp
@@ -0,0 +1,6 @@
+#include 
+#include 
+
+void f(std::atomic , std::vector ) {
+  (void)a; // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/TestUniqueTypes3.py
@@ -0,0 +1,28 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase3(TestBase):
+def do_test(self, debug_flags):
+"""Test that we display the correct template instantiation."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("a.cpp"))
+self.assertIn("int", self.frame().GetValueForVariablePath("a").GetDisplayTypeName())
+self.assertIn("int", self.frame().GetValueForVariablePath("v").GetDisplayTypeName())
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+# Can't directly set CFLAGS_EXTRAS here because the Makefile can't
+# override an environment variable.
+self.do_test(dict(TEST_CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
Index: lldb/test/API/lang/cpp/unique-types3/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types3/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp a.cpp
+
+CFLAGS_EXTRAS = $(TEST_CFLAGS_EXTRAS) $(LIMIT_DEBUG_INFO_FLAGS)
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2979,6 +2979,16 @@
   }
 }
 
+// See comments below about -gsimple-template-names for why we attempt to
+// compute missing template parameter names.
+ConstString template_params;
+if (type_system && !type_name.GetStringRef().contains('<')) {
+  DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+  if (dwarf_ast)
+template_params =
+dwarf_ast->GetForwardDeclarationDIETemplateParams(die);
+}
+
 m_index->GetTypes(type_name, [&](DWARFDIE type_die) {
   // Make sure type_die's language matches the type system we are
   // looking for. We don't want to find a "Foo" type from Java if we
@@ -3050,6 +3060,25 @@
   if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
 return true;
 
+  // With -gsimple-template-names, the DIE name may not contain the template
+  // parameters. If we've the declaration has template parameters but
+  // doesn't contain '<', check that the child template parameters match.
+  if (template_params) {
+llvm::StringRef test_base_name =
+

[Lldb-commits] [PATCH] D138612: [lldb] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-28 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

@jasonmolenda could you run check-lldb with this patch? I think this patch may 
fix the test by changing its expectations for logging.

(removed "NFC" from title because the logging changes actually mattered)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

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


[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-28 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 478272.
aeubanks added a comment.

potential test fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/test/API/lang/cpp/accelerator-table/TestCPPAccelerator.py
  lldb/test/API/lang/cpp/accelerator-table/a.cpp
  lldb/test/API/lang/cpp/accelerator-table/b.cpp
  lldb/test/API/lang/cpp/accelerator-table/c.cpp
  lldb/test/API/lang/cpp/accelerator-table/d.cpp
  lldb/test/API/lang/cpp/accelerator-table/e.cpp
  lldb/test/API/lang/cpp/accelerator-table/f.cpp
  lldb/test/API/lang/cpp/accelerator-table/g.cpp
  lldb/test/API/lang/cpp/accelerator-table/main.cpp

Index: lldb/test/API/lang/cpp/accelerator-table/main.cpp
===
--- lldb/test/API/lang/cpp/accelerator-table/main.cpp
+++ lldb/test/API/lang/cpp/accelerator-table/main.cpp
@@ -6,23 +6,23 @@
   };\
 NAME::Inner ##NAME();
 
-CLASS(A)
-CLASS(B)
-CLASS(C)
-CLASS(D)
-CLASS(E)
-CLASS(F)
-CLASS(G)
+CLASS(AFoo)
+CLASS(BFoo)
+CLASS(CFoo)
+CLASS(DFoo)
+CLASS(EFoo)
+CLASS(FFoo)
+CLASS(GFoo)
 
 int main()
 {
-  A::Inner _a = getInnerA();
-  B::Inner _b = getInnerB();
-  C::Inner _c = getInnerC();
-  D::Inner _d = getInnerD();
-  E::Inner _e = getInnerE();
-  F::Inner _f = getInnerF();
-  G::Inner _g = getInnerG();
+  AFoo::Inner _a = getInnerAFoo();
+  BFoo::Inner _b = getInnerBFoo();
+  CFoo::Inner _c = getInnerCFoo();
+  DFoo::Inner _d = getInnerDFoo();
+  EFoo::Inner _e = getInnerEFoo();
+  FFoo::Inner _f = getInnerFFoo();
+  GFoo::Inner _g = getInnerGFoo();
 
   return 0; // break here
 }
Index: lldb/test/API/lang/cpp/accelerator-table/g.cpp
===
--- lldb/test/API/lang/cpp/accelerator-table/g.cpp
+++ lldb/test/API/lang/cpp/accelerator-table/g.cpp
@@ -1,2 +1,2 @@
 #include "source.h"
-CLASS(G)
+CLASS(GFoo)
Index: lldb/test/API/lang/cpp/accelerator-table/f.cpp
===
--- lldb/test/API/lang/cpp/accelerator-table/f.cpp
+++ lldb/test/API/lang/cpp/accelerator-table/f.cpp
@@ -1,2 +1,2 @@
 #include "source.h"
-CLASS(F)
+CLASS(FFoo)
Index: lldb/test/API/lang/cpp/accelerator-table/e.cpp
===
--- lldb/test/API/lang/cpp/accelerator-table/e.cpp
+++ lldb/test/API/lang/cpp/accelerator-table/e.cpp
@@ -1,2 +1,2 @@
 #include "source.h"
-CLASS(E)
+CLASS(EFoo)
Index: lldb/test/API/lang/cpp/accelerator-table/d.cpp
===
--- lldb/test/API/lang/cpp/accelerator-table/d.cpp
+++ lldb/test/API/lang/cpp/accelerator-table/d.cpp
@@ -1,2 +1,2 @@
 #include "source.h"
-CLASS(D)
+CLASS(DFoo)
Index: lldb/test/API/lang/cpp/accelerator-table/c.cpp
===
--- lldb/test/API/lang/cpp/accelerator-table/c.cpp
+++ lldb/test/API/lang/cpp/accelerator-table/c.cpp
@@ -1,2 +1,2 @@
 #include "source.h"
-CLASS(C)
+CLASS(CFoo)
Index: lldb/test/API/lang/cpp/accelerator-table/b.cpp
===
--- lldb/test/API/lang/cpp/accelerator-table/b.cpp
+++ lldb/test/API/lang/cpp/accelerator-table/b.cpp
@@ -1,2 +1,2 @@
 #include "source.h"
-CLASS(B)
+CLASS(BFoo)
Index: lldb/test/API/lang/cpp/accelerator-table/a.cpp
===
--- lldb/test/API/lang/cpp/accelerator-table/a.cpp
+++ lldb/test/API/lang/cpp/accelerator-table/a.cpp
@@ -1,2 +1,2 @@
 #include "source.h"
-CLASS(A)
+CLASS(AFoo)
Index: lldb/test/API/lang/cpp/accelerator-table/TestCPPAccelerator.py
===
--- lldb/test/API/lang/cpp/accelerator-table/TestCPPAccelerator.py
+++ lldb/test/API/lang/cpp/accelerator-table/TestCPPAccelerator.py
@@ -25,8 +25,8 @@
 log = f.readlines()
 n = 0
 for line in log:
-if re.findall(r'[abcdefg]\.o: FindByNameAndTag\(\)', line):
-self.assertIn("d.o", line)
+if re.findall(r'[ABCDEFG]Foo: FindByNameAndTag\(\)', line):
+self.assertIn("DFoo", line)
 n += 1
 
 self.assertEqual(n, 1, "".join(log))
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- 

[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-26 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

> The bot has pretty good logs fwiw,

I don't have easy access to a mac, knowing what the logs are when the test is 
passing would be helpful with figuring out what's going wrong and relanding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

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


[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-24 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

In D138612#3949869 , @jasonmolenda 
wrote:

> Hi Arthur, this change is causing a testsuite failure on Darwin systems - see 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48671/ on the "LLDB 
> Incremental" bot - and I can reproduce this failure on my local mac.  Would 
> you like to revert this until you've had a chance to find the issue, or 
> should I?  It's a holiday weekend in the US & I would understand if you don't 
> see this message for a while, I'll revert later today unless you suggest an 
> alternative.  Thanks.

Feel free to revert, but could you post the log file that the test looks at 
with and without the change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

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


[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-24 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3c423b6cb2e: [lldb][NFC] Change 
FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,113 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  const ConstString 

[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-23 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 477611.
aeubanks added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,113 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  const ConstString type_name(die.GetName());
+  if (type_name) {
+const dw_tag_t tag = die.Tag();
 
-if (type_name) {
-  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
-  if (log) {
- 

[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-23 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 477608.
aeubanks added a comment.
Herald added a subscriber: JDevlieghere.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,113 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  const ConstString type_name(die.GetName());
+  if (type_name) {
+const dw_tag_t tag = die.Tag();
 
-if (type_name) {
-  Log *log = GetLog(DWARFLog::TypeCompletion 

[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-23 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a reviewer: shafik.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This simplifies an upcoming patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,113 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  const ConstString type_name(die.GetName());
+  if (type_name) {
+const dw_tag_t tag = die.Tag();
 
-if (type_name) {
-  Log *log = GetLog(DWARFLog::TypeCompletion | 

[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-21 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b80e8ee1fca: [lldb] Disable looking at pointee types to 
find synthetic value for non-ObjC (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137983

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
  lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
  lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
  lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp


Index: lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+void f(std::set );
+
+int main() {
+  std::set v;
+  f(v);
+}
Index: lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
@@ -0,0 +1,5 @@
+#include 
+
+void f(std::set ) {
+  // break here
+}
Index: lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
@@ -0,0 +1,18 @@
+"""
+Test situations where the debug info only has a declaration, no definition, for
+an STL container with a formatter.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestStlIncompleteTypes(TestBase):
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("f.cpp"))
+
+var = self.frame().GetValueForVariablePath("v")
+self.assertIn("set", var.GetDisplayTypeName())
Index: lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp f.cpp
+
+include Makefile.rules
+
+# Force main.cpp to be built with no debug information
+main.o: CFLAGS = $(CFLAGS_NO_DEBUG)
+
+# And force -flimit-debug-info on the rest.
+f.o: CFLAGS_EXTRAS += $(LIMIT_DEBUG_INFO_FLAGS)
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2673,7 +2673,10 @@
 // In case of incomplete child compiler type, use the pointee type and try
 // to recreate a new ValueObjectChild using it.
 if (!m_deref_valobj) {
-  if (HasSyntheticValue()) {
+  // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
+  // `std::vector &`). Remove ObjC restriction once that's resolved.
+  if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
+  HasSyntheticValue()) {
 child_compiler_type = compiler_type.GetPointeeType();
 
 if (child_compiler_type) {


Index: lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+void f(std::set );
+
+int main() {
+  std::set v;
+  f(v);
+}
Index: lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
@@ -0,0 +1,5 @@
+#include 
+
+void f(std::set ) {
+  // break here
+}
Index: lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
@@ -0,0 +1,18 @@
+"""
+Test situations where the debug info only has a declaration, no definition, for
+an STL container with a formatter.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestStlIncompleteTypes(TestBase):
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("f.cpp"))
+
+var = self.frame().GetValueForVariablePath("v")
+self.assertIn("set", var.GetDisplayTypeName())
Index: lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp f.cpp
+
+include Makefile.rules
+
+# Force main.cpp to be built with no debug information
+main.o: CFLAGS = $(CFLAGS_NO_DEBUG)
+
+# And force -flimit-debug-info on the rest.
+f.o: 

[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-18 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

would somebody be willing to lgtm the workaround while we investigate further 
since this is currently breaking a fairly typical debugging session?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137983

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


[Lldb-commits] [PATCH] D138315: [lldb] Introduce dwim-print command

2022-11-18 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Commands/CommandObjectDWIMPrint.h:1
+#include "lldb/Interpreter/CommandObject.h"
+

license?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138315

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


[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-17 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

In D137983#3930973 , @labath wrote:

> We have tests for shared libraries (grep for DYLIB_C(XX)_SOURCES)), but it's 
> easier to reproduce this problem by compiling one CU with -g0 -- see inline 
> comment. (If you are creating an "API" test for this, beware that their 
> default is to build everything with -fstandalone-debug, and you'll need to 
> explicitly change that (see LIMIT_DEBUG_INFO_FLAGS))

`lldb/test/API/lang/cpp/incomplete-types/` looks like exactly what I want, I've 
added a test based on that (and verified that lldb crashes in that test without 
the source change)

> This behavior (bug) is triggered by the `FrontEndWantsDereference` formatter 
> flag, which is why it manifests itself for (libc++) vector and friends. The 
> ObjC formatters don't set that flag so they should be safe. The libstdc++ 
> formatters don't set it either. Furthermore there doesn't seem to be a way to 
> set this flag by the user, so it is not possible to create a 
> libc++-independent reproducer (which is what I was going to suggest).
>
> I've been looking for a better way to fix this today (sorry about the delay), 
> but I haven't figured out anything better. There is this fundamental 
> recursion between the pretty printer (which wants to dereference a value) and 
> the dereferencing code (which wants to know if it has a pretty printer -- so 
> it can avoid dereferencing). Just removing the `HasSyntheticValue()`fixed the 
> bug for me -- but then we were able to "dereference" incomplete structs. It's 
> possible we may be able to allow the dereference to succeed here, but then 
> refuse to print the value somewhere down the line. I would like to hear what 
> @jingham things about all this.

Thanks for the investigation!
Actually some libstdc++ formatters do also set `FrontEndWantsDereference`, so 
this is reproable with

  $ cat /tmp/main.cc
  #include 
  
  void f(std::set& v);
  
  int main() {
  std::set v;
  f(v);
  }
  $ cat /tmp/a.cc
  #include 
  
  void f(std::set& v) {
  // break
  }
  $ bin/clang++ -g0 /tmp/main.cc -o /tmp/main.o  -c && bin/clang++ -g /tmp/a.cc 
-o /tmp/a.o  -c && bin/clang++ /tmp/a.o /tmp/main.o -o /tmp/a
  $ bin/lldb /tmp/a -b -o 'br set -n f'  -o run

with and without `-stdlib=libc++`

maybe a more targeted solution would be to change the added condition to when 
`FrontEndWantsDereference` is set, but that's more annoying to thread through 
the code. I think this should be ok as a temporary workaround if we don't have 
a proper fix soonish?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137983

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


[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-17 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 476199.
aeubanks added a comment.

add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137983

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
  lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
  lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
  lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp


Index: lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+void f(std::set );
+
+int main() {
+  std::set v;
+  f(v);
+}
Index: lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
@@ -0,0 +1,5 @@
+#include 
+
+void f(std::set ) {
+  // break here
+}
Index: lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
@@ -0,0 +1,18 @@
+"""
+Test situations where the debug info only has a declaration, no definition, for
+an STL container with a formatter.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestStlIncompleteTypes(TestBase):
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("f.cpp"))
+
+var = self.frame().GetValueForVariablePath("v")
+self.assertIn("set", var.GetDisplayTypeName())
Index: lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp f.cpp
+
+include Makefile.rules
+
+# Force main.cpp to be built with no debug information
+main.o: CFLAGS = $(CFLAGS_NO_DEBUG)
+
+# And force -flimit-debug-info on the rest.
+f.o: CFLAGS_EXTRAS += $(LIMIT_DEBUG_INFO_FLAGS)
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2673,7 +2673,10 @@
 // In case of incomplete child compiler type, use the pointee type and try
 // to recreate a new ValueObjectChild using it.
 if (!m_deref_valobj) {
-  if (HasSyntheticValue()) {
+  // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
+  // `std::vector &`). Remove ObjC restriction once that's resolved.
+  if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
+  HasSyntheticValue()) {
 child_compiler_type = compiler_type.GetPointeeType();
 
 if (child_compiler_type) {


Index: lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+void f(std::set );
+
+int main() {
+  std::set v;
+  f(v);
+}
Index: lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp
@@ -0,0 +1,5 @@
+#include 
+
+void f(std::set ) {
+  // break here
+}
Index: lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py
@@ -0,0 +1,18 @@
+"""
+Test situations where the debug info only has a declaration, no definition, for
+an STL container with a formatter.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestStlIncompleteTypes(TestBase):
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("f.cpp"))
+
+var = self.frame().GetValueForVariablePath("v")
+self.assertIn("set", var.GetDisplayTypeName())
Index: lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/incomplete-stl-types/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp f.cpp
+
+include Makefile.rules
+
+# Force main.cpp to be built with no debug information
+main.o: CFLAGS = $(CFLAGS_NO_DEBUG)
+
+# And force -flimit-debug-info on the rest.
+f.o: CFLAGS_EXTRAS += $(LIMIT_DEBUG_INFO_FLAGS)
Index: lldb/source/Core/ValueObject.cpp

[Lldb-commits] [PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-15 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb0ffa529a0f: [lldb] Fix simple template names and template 
params with scope qualifiers (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- lldb/test/API/lang/cpp/unique-types2/main.cpp
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -1,3 +1,7 @@
+namespace ns {
+struct Bar {};
+} // namespace ns
+
 template  struct Foo {
   T t;
   template  class Nested {
@@ -23,5 +27,6 @@
   FooPack p7;
 
   Foo::Nested n1;
+  Foo::Nested n2;
   // Set breakpoint here
 }
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
===
--- lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
@@ -36,6 +36,7 @@
 self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
 self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 
 self.expect_expr("t1", result_type="Foo")
 self.expect_expr("t1", result_type="Foo")
@@ -49,6 +50,7 @@
 self.expect_expr("p6", result_type="FooPack")
 self.expect_expr("p7", result_type="FooPack")
 self.expect_expr("n1", result_type="Foo::Nested")
+self.expect_expr("n2", result_type="Foo::Nested")
 
 @skipIf(compiler=no_match("clang"))
 @skipIf(compiler_version=["<", "15.0"])
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -644,7 +644,7 @@
   // Accessors
 
   ConstString GetTypeName(lldb::opaque_compiler_type_t type,
-  bool BaseOnly) override;
+  bool base_only) override;
 
   ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override;
 
@@ -1051,7 +1051,8 @@
   clang::PrintingPolicy GetTypePrintingPolicy();
   /// Returns the internal type name for the given NamedDecl using the
   /// type printing policy.
-  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl);
+  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl,
+ bool qualified = true);
 
   const clang::ClassTemplateSpecializationDecl *
   GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2131,11 +2131,12 @@
   return printing_policy;
 }
 
-std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl) {
+std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl,
+bool qualified) {
   clang::PrintingPolicy printing_policy = GetTypePrintingPolicy();
   std::string result;
   llvm::raw_string_ostream os(result);
-  named_decl->printQualifiedName(os, printing_policy);
+  named_decl->getNameForDiagnostic(os, printing_policy, qualified);
   return result;
 }
 
@@ -3768,7 +3769,7 @@
 }
 
 ConstString TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type,
- bool BaseOnly) {
+ bool base_only) {
   if (!type)
 return ConstString();
 
@@ -3790,9 +3791,13 @@
 return ConstString(GetTypeNameForDecl(typedef_decl));
   }
 
-  clang::PrintingPolicy printing_policy(GetTypePrintingPolicy());
-  printing_policy.SuppressScope = BaseOnly;
-  return ConstString(qual_type.getAsString(printing_policy));
+  // For consistency, this follows the same code path that clang uses to emit
+  // debug info. This also handles when we don't want any scopes preceding the
+  // name.
+  if (auto *named_decl = qual_type->getAsTagDecl())
+return ConstString(GetTypeNameForDecl(named_decl, !base_only));
+
+  return ConstString(qual_type.getAsString(GetTypePrintingPolicy()));
 }
 
 ConstString
___
lldb-commits mailing list

[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-15 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Core/ValueObject.cpp:2676-2677
 if (!m_deref_valobj) {
-  if (HasSyntheticValue()) {
+  // FIXME: C++ stdlib formatters break with incomplete types (e.g.
+  // `std::vector &`). Remove ObjC restriction once that's resolved.
+  if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&

dblaikie wrote:
> Maybe worth filing a bug and referencing it here?
> 
> Is this limitation still necessary if the incomplete type has template 
> parameter DIEs? (I guess probably yes, because it'll be missing member 
> descriptions, etc)
> 
> & does this path get hit if the type is declared in one CU but defined in 
> another? (& does the inf recurse/crash loop still get hit in that case, 
> without this patch?)
> Maybe worth filing a bug and referencing it here?
Filed https://github.com/llvm/llvm-project/issues/59012, added here

> Is this limitation still necessary if the incomplete type has template 
> parameter DIEs? (I guess probably yes, because it'll be missing member 
> descriptions, etc)
yes (I incorrectly mentioned in person that this works with 
`-gsimple-template-names`, it actually still infinite recurses)

> & does this path get hit if the type is declared in one CU but defined in 
> another? (& does the inf recurse/crash loop still get hit in that case, 
> without this patch?)
if the declaration is in a shared library and the main binary has the 
definition, we hit this
if we have two CUs, one with a declaration, one with a definition, but both 
linked into the same binary, we don't hit the issue
AFAICT lldb restricts looking up debug info to the binary/shared library, but 
otherwise prefers definitions over declarations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137983

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


[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-15 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 475627.
aeubanks added a comment.

add bug


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137983

Files:
  lldb/source/Core/ValueObject.cpp


Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2673,7 +2673,10 @@
 // In case of incomplete child compiler type, use the pointee type and try
 // to recreate a new ValueObjectChild using it.
 if (!m_deref_valobj) {
-  if (HasSyntheticValue()) {
+  // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
+  // `std::vector &`). Remove ObjC restriction once that's resolved.
+  if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
+  HasSyntheticValue()) {
 child_compiler_type = compiler_type.GetPointeeType();
 
 if (child_compiler_type) {


Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2673,7 +2673,10 @@
 // In case of incomplete child compiler type, use the pointee type and try
 // to recreate a new ValueObjectChild using it.
 if (!m_deref_valobj) {
-  if (HasSyntheticValue()) {
+  // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
+  // `std::vector &`). Remove ObjC restriction once that's resolved.
+  if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
+  HasSyntheticValue()) {
 child_compiler_type = compiler_type.GetPointeeType();
 
 if (child_compiler_type) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

also I'm don't understand how this code doesn't infinite recurse on ObjC and 
can't trace it because I don't have a mac

if anybody has an actual way of fixing this I'd be happy with that too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137983

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


[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.
Herald added a subscriber: JDevlieghere.

lldb crash repro

  $ cat /tmp/a.cc
  #include 
  
  void f(std::vector& v) {
  *(volatile int*) nullptr = 0;
  }
  $ cat /tmp/main.cc
  #include 
  
  void f(std::vector& v);
  
  int main() {
  std::vector v ;
  f(v);
  }
  $ ./build/bin/clang++ -g /tmp/a.cc -o /tmp/a.so -shared -stdlib=libc++ 
-fuse-ld=lld -Wl,-rpath,$PWD/build/rel/lib
  $ ./build/bin/clang++ -g /tmp/main.cc /tmp/a.so -o /tmp/a -stdlib=libc++ 
-fuse-ld=lld -Wl,-rpath,$PWD/build/rel/lib
  $ ./build/bin/lldb /tmp/a -b -o run
  # crash

any help with adding a test case for this would be appreciated, I'm not sure if 
there's any testing for shared libraries in lldb?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137983

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


[Lldb-commits] [PATCH] D137983: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC

2022-11-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

After D134378 , we started seeing crashes 
with incomplete types (in the
context of shared libraries).

When trying to print a `std::vector &` with only debug info for a
declaration, we now try to use the formatter after D134378 
. With an
incomplete type, this somehow goes into infinite recursion with the
frames

  lldb_private::ValueObject::Dereference
  lldb_private::ValueObjectSynthetic::CreateSynthFilter
  lldb_private::ValueObjectSynthetic::ValueObjectSynthetic
  lldb_private::ValueObject::CalculateSyntheticValue
  lldb_private::ValueObject::HasSyntheticValue

The reason this only started appearing after D134378 
 was because
previously with incomplete types, for names with `<`, lldb would attempt
to parse template parameter DIEs, which were empty, then create an empty
`ClassTemplateSpecializationDecl` which overrode the name used to lookup
a formatter in `FormattersMatchData()` to not include template
parameters (e.g. `std::vector<> &`). After D134378 
 we don't create a
`ClassTemplateSpecializationDecl` when there are no template parameters
and the name to lookup a formatter is the original name (e.g.
`std::vector &`).

The code to try harder with incomplete child compiler types was added in
D79554  for ObjC purposes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137983

Files:
  lldb/source/Core/ValueObject.cpp


Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2673,7 +2673,10 @@
 // In case of incomplete child compiler type, use the pointee type and try
 // to recreate a new ValueObjectChild using it.
 if (!m_deref_valobj) {
-  if (HasSyntheticValue()) {
+  // FIXME: C++ stdlib formatters break with incomplete types (e.g.
+  // `std::vector &`). Remove ObjC restriction once that's resolved.
+  if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
+  HasSyntheticValue()) {
 child_compiler_type = compiler_type.GetPointeeType();
 
 if (child_compiler_type) {


Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2673,7 +2673,10 @@
 // In case of incomplete child compiler type, use the pointee type and try
 // to recreate a new ValueObjectChild using it.
 if (!m_deref_valobj) {
-  if (HasSyntheticValue()) {
+  // FIXME: C++ stdlib formatters break with incomplete types (e.g.
+  // `std::vector &`). Remove ObjC restriction once that's resolved.
+  if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
+  HasSyntheticValue()) {
 child_compiler_type = compiler_type.GetPointeeType();
 
 if (child_compiler_type) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-11-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

I'll hold off on submitting this until that bug is figured out


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

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


[Lldb-commits] [PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-11-13 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 475017.
aeubanks added a comment.

I somehow missed the previous comments

rebased on top of fixing UB in tests changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Transforms/InstCombine/call-undef.ll
  llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll

Index: llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll
===
--- llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll
+++ llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll
@@ -6,7 +6,7 @@
 ; CHECK-LABEL: @test_out_of_bounds(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[AND1:%.*]] = and i32 [[A:%.*]], 3
-; CHECK-NEXT:tail call void @llvm.assume(i1 poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret i32 [[AND1]]
 ;
 entry:
@@ -20,7 +20,7 @@
 define i128 @test_non64bit(i128 %a) {
 ; CHECK-LABEL: @test_non64bit(
 ; CHECK-NEXT:[[AND1:%.*]] = and i128 [[A:%.*]], 3
-; CHECK-NEXT:tail call void @llvm.assume(i1 poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret i128 [[AND1]]
 ;
   %and1 = and i128 %a, 3
Index: llvm/test/Transforms/InstCombine/call-undef.ll
===
--- llvm/test/Transforms/InstCombine/call-undef.ll
+++ llvm/test/Transforms/InstCombine/call-undef.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+; RUN: opt < %s -passes=instcombine -S -instcombine-disable-optimize-passing-undef-ub | FileCheck %s --check-prefix=DISABLE
 
 declare void @c(i32 noundef)
 declare void @d(ptr dereferenceable(1))
@@ -8,8 +9,12 @@
 
 define void @test1() {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:call void @c(i32 undef)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test1(
+; DISABLE-NEXT:call void @c(i32 undef)
+; DISABLE-NEXT:ret void
 ;
   call void @c(i32 undef)
   ret void
@@ -17,8 +22,12 @@
 
 define void @test2() {
 ; CHECK-LABEL: @test2(
-; CHECK-NEXT:call void @c(i32 poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test2(
+; DISABLE-NEXT:call void @c(i32 poison)
+; DISABLE-NEXT:ret void
 ;
   call void @c(i32 poison)
   ret void
@@ -26,8 +35,12 @@
 
 define void @test3() {
 ; CHECK-LABEL: @test3(
-; CHECK-NEXT:call void @e(i32 noundef undef)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test3(
+; DISABLE-NEXT:call void @e(i32 noundef undef)
+; DISABLE-NEXT:ret void
 ;
   call void @e(i32 noundef undef)
   ret void
@@ -35,8 +48,12 @@
 
 define void @test4() {
 ; CHECK-LABEL: @test4(
-; CHECK-NEXT:call void @e(i32 noundef poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test4(
+; DISABLE-NEXT:call void @e(i32 noundef poison)
+; DISABLE-NEXT:ret void
 ;
   call void @e(i32 noundef poison)
   ret void
@@ -44,8 +61,12 @@
 
 define void @test5() {
 ; CHECK-LABEL: @test5(
-; CHECK-NEXT:call void @d(ptr undef)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test5(
+; DISABLE-NEXT:call void @d(ptr undef)
+; DISABLE-NEXT:ret void
 ;
   call void @d(ptr undef)
   ret void
@@ -53,8 +74,12 @@
 
 define void @test6() {
 ; CHECK-LABEL: @test6(
-; CHECK-NEXT:call void @d(ptr poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test6(
+; DISABLE-NEXT:call void @d(ptr poison)
+; DISABLE-NEXT:ret void
 ;
   call void @d(ptr poison)
   ret void
@@ -62,8 +87,12 @@
 
 define void @test7() {
 ; CHECK-LABEL: @test7(
-; CHECK-NEXT:call void @f(ptr dereferenceable(1) undef)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test7(
+; DISABLE-NEXT:call void @f(ptr dereferenceable(1) undef)
+; DISABLE-NEXT:ret void
 ;
   call void @f(ptr dereferenceable(1) undef)
   ret void
@@ -71,17 +100,38 @@
 
 define void @test8() {
 ; CHECK-LABEL: @test8(
-; CHECK-NEXT:call void @f(ptr dereferenceable(1) poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test8(
+; DISABLE-NEXT:call void @f(ptr dereferenceable(1) poison)
+; DISABLE-NEXT:ret void
 ;
   call void @f(ptr dereferenceable(1) poison)
   ret void
 }
 
+define void @test9() sanitize_memory {
+; CHECK-LABEL: @test9(
+; CHECK-NEXT:call void @c(i32 undef)
+; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test9(
+; DISABLE-NEXT:call void @c(i32 undef)
+; DISABLE-NEXT:ret void

[Lldb-commits] [PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-11 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

In D137583#3917735 , @dblaikie wrote:

> In D137583#3917706 , @aaron.ballman 
> wrote:
>
>>> ...we expect template params to be fully qualified when comparing them for 
>>> simple template names
>>
>> So lldb is not inspecting the AST, they're doing reflection (of a sort) on 
>> the pretty printed names? Or am I misunderstanding something?
>
> Not reflection as such - but building names for the user, but partly from the 
> AST - basically LLDB wants to be able to produce the same name that 
> CGDebugInfo produces - so, maybe it should produce it the same way as 
> CGDebugInfo, which isn't to use the pretty printer from scratch.
>
> @aeubanks would this work for lldb's use case? 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGDebugInfo.cpp#L5229
>  it'd be identical to the original debug info generation, and looks like it 
> doesn't require a printing policy change/feature. Sorry I didn't think of 
> that earlier. I guess since `Qualified` would be `false` for lldb's use case, 
> you could go down into the implementation and just call the unqualified side 
> directly: `NamedDecl::printName(OS, Policy);` should print it unqualified for 
> this name, but respect the qualified printing policy flag for any nested 
> names, parameters, etc.

much better, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

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


[Lldb-commits] [PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-11 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 474850.
aeubanks added a comment.

add comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- lldb/test/API/lang/cpp/unique-types2/main.cpp
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -1,3 +1,7 @@
+namespace ns {
+struct Bar {};
+} // namespace ns
+
 template  struct Foo {
   T t;
   template  class Nested {
@@ -23,5 +27,6 @@
   FooPack p7;
 
   Foo::Nested n1;
+  Foo::Nested n2;
   // Set breakpoint here
 }
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
===
--- lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
@@ -36,6 +36,7 @@
 self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
 self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 
 self.expect_expr("t1", result_type="Foo")
 self.expect_expr("t1", result_type="Foo")
@@ -49,6 +50,7 @@
 self.expect_expr("p6", result_type="FooPack")
 self.expect_expr("p7", result_type="FooPack")
 self.expect_expr("n1", result_type="Foo::Nested")
+self.expect_expr("n2", result_type="Foo::Nested")
 
 @skipIf(compiler=no_match("clang"))
 @skipIf(compiler_version=["<", "15.0"])
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -644,7 +644,7 @@
   // Accessors
 
   ConstString GetTypeName(lldb::opaque_compiler_type_t type,
-  bool BaseOnly) override;
+  bool base_only) override;
 
   ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override;
 
@@ -1051,7 +1051,8 @@
   clang::PrintingPolicy GetTypePrintingPolicy();
   /// Returns the internal type name for the given NamedDecl using the
   /// type printing policy.
-  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl);
+  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl,
+ bool qualified = true);
 
   const clang::ClassTemplateSpecializationDecl *
   GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2131,11 +2131,12 @@
   return printing_policy;
 }
 
-std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl) {
+std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl,
+bool qualified) {
   clang::PrintingPolicy printing_policy = GetTypePrintingPolicy();
   std::string result;
   llvm::raw_string_ostream os(result);
-  named_decl->printQualifiedName(os, printing_policy);
+  named_decl->getNameForDiagnostic(os, printing_policy, qualified);
   return result;
 }
 
@@ -3768,7 +3769,7 @@
 }
 
 ConstString TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type,
- bool BaseOnly) {
+ bool base_only) {
   if (!type)
 return ConstString();
 
@@ -3790,9 +3791,13 @@
 return ConstString(GetTypeNameForDecl(typedef_decl));
   }
 
-  clang::PrintingPolicy printing_policy(GetTypePrintingPolicy());
-  printing_policy.SuppressScope = BaseOnly;
-  return ConstString(qual_type.getAsString(printing_policy));
+  // For consistency, this follows the same code path that clang uses to emit
+  // debug info. This also handles when we don't want any scopes preceding the
+  // name.
+  if (auto *named_decl = qual_type->getAsTagDecl())
+return ConstString(GetTypeNameForDecl(named_decl, !base_only));
+
+  return ConstString(qual_type.getAsString(GetTypePrintingPolicy()));
 }
 
 ConstString
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-11 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 474848.
aeubanks added a comment.

use getNameForDiagnostics


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- lldb/test/API/lang/cpp/unique-types2/main.cpp
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -1,3 +1,7 @@
+namespace ns {
+struct Bar {};
+} // namespace ns
+
 template  struct Foo {
   T t;
   template  class Nested {
@@ -23,5 +27,6 @@
   FooPack p7;
 
   Foo::Nested n1;
+  Foo::Nested n2;
   // Set breakpoint here
 }
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
===
--- lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
@@ -36,6 +36,7 @@
 self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
 self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 
 self.expect_expr("t1", result_type="Foo")
 self.expect_expr("t1", result_type="Foo")
@@ -49,6 +50,7 @@
 self.expect_expr("p6", result_type="FooPack")
 self.expect_expr("p7", result_type="FooPack")
 self.expect_expr("n1", result_type="Foo::Nested")
+self.expect_expr("n2", result_type="Foo::Nested")
 
 @skipIf(compiler=no_match("clang"))
 @skipIf(compiler_version=["<", "15.0"])
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -644,7 +644,7 @@
   // Accessors
 
   ConstString GetTypeName(lldb::opaque_compiler_type_t type,
-  bool BaseOnly) override;
+  bool base_only) override;
 
   ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override;
 
@@ -1051,7 +1051,8 @@
   clang::PrintingPolicy GetTypePrintingPolicy();
   /// Returns the internal type name for the given NamedDecl using the
   /// type printing policy.
-  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl);
+  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl,
+ bool qualified = true);
 
   const clang::ClassTemplateSpecializationDecl *
   GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2131,11 +2131,12 @@
   return printing_policy;
 }
 
-std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl) {
+std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl,
+bool qualified) {
   clang::PrintingPolicy printing_policy = GetTypePrintingPolicy();
   std::string result;
   llvm::raw_string_ostream os(result);
-  named_decl->printQualifiedName(os, printing_policy);
+  named_decl->getNameForDiagnostic(os, printing_policy, qualified);
   return result;
 }
 
@@ -3768,7 +3769,7 @@
 }
 
 ConstString TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type,
- bool BaseOnly) {
+ bool base_only) {
   if (!type)
 return ConstString();
 
@@ -3790,9 +3791,9 @@
 return ConstString(GetTypeNameForDecl(typedef_decl));
   }
 
-  clang::PrintingPolicy printing_policy(GetTypePrintingPolicy());
-  printing_policy.SuppressScope = BaseOnly;
-  return ConstString(qual_type.getAsString(printing_policy));
+  if (auto *named_decl = qual_type->getAsTagDecl())
+return ConstString(GetTypeNameForDecl(named_decl, !base_only));
+  return ConstString(qual_type.getAsString(GetTypePrintingPolicy()));
 }
 
 ConstString
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137793: [lldb][test] TestConstStaticIntegralMember.py: fix for clang-{9, 11, 13}

2022-11-10 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

In D137793#3920253 , @Michael137 
wrote:

> In D137793#3920209 , @aeubanks 
> wrote:
>
>> add a FIXME?
>
> May be misunderstanding your suggestion, but the malformed DWARF got fixed 
> somewhere between clang-14/clang-15. This is only an issue with older clang 
> versions. I'm merely getting the old buildbots to pass

I guess my question is should lldb support the malformed dwarf generated by 
older clangs?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137793

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


[Lldb-commits] [PATCH] D137793: [lldb][test] TestConstStaticIntegralMember.py: fix for clang-{9, 11, 13}

2022-11-10 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

add a FIXME?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137793

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


[Lldb-commits] [PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-07 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Followup to D134378 .

With PrintingPolicy::SuppressScope, we'd also not print the scope in template 
params. The intention was only to skip the scope for the class because we 
expect template params to be fully qualified when comparing them for simple 
template names.

Add a PrintingPolicy::NoSuppressTemplateParamsScope which disables 
SuppressScope for template params.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137583

Files:
  clang/include/clang/AST/PrettyPrinter.h
  clang/lib/AST/TypePrinter.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- lldb/test/API/lang/cpp/unique-types2/main.cpp
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -1,3 +1,7 @@
+namespace ns {
+struct Bar {};
+} // namespace ns
+
 template  struct Foo {
   T t;
   template  class Nested {
@@ -23,5 +27,6 @@
   FooPack p7;
 
   Foo::Nested n1;
+  Foo::Nested n2;
   // Set breakpoint here
 }
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
===
--- lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
@@ -36,6 +36,7 @@
 self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
 self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 
 self.expect_expr("t1", result_type="Foo")
 self.expect_expr("t1", result_type="Foo")
@@ -49,6 +50,7 @@
 self.expect_expr("p6", result_type="FooPack")
 self.expect_expr("p7", result_type="FooPack")
 self.expect_expr("n1", result_type="Foo::Nested")
+self.expect_expr("n2", result_type="Foo::Nested")
 
 @skipIf(compiler=no_match("clang"))
 @skipIf(compiler_version=["<", "15.0"])
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3792,6 +3792,7 @@
 
   clang::PrintingPolicy printing_policy(GetTypePrintingPolicy());
   printing_policy.SuppressScope = BaseOnly;
+  printing_policy.NoSuppressTemplateParamsScope = BaseOnly;
   return ConstString(qual_type.getAsString(printing_policy));
 }
 
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -110,6 +110,23 @@
   }
 };
 
+class NoSuppressTemplateParamsScopeRAII {
+  PrintingPolicy 
+  bool OldSuppressScope;
+
+public:
+  explicit NoSuppressTemplateParamsScopeRAII(PrintingPolicy )
+  : Policy(Policy) {
+OldSuppressScope = Policy.SuppressScope;
+if (Policy.NoSuppressTemplateParamsScope)
+  Policy.SuppressScope = false;
+  }
+
+  ~NoSuppressTemplateParamsScopeRAII() {
+Policy.SuppressScope = OldSuppressScope;
+  }
+};
+
 class TypePrinter {
   PrintingPolicy Policy;
   unsigned Indentation;
@@ -1370,6 +1387,7 @@
   // If this is a class template specialization, print the template
   // arguments.
   if (const auto *Spec = dyn_cast(D)) {
+NoSuppressTemplateParamsScopeRAII SuppressScopeRAII(Policy);
 ArrayRef Args;
 TypeSourceInfo *TAW = Spec->getTypeAsWritten();
 if (!Policy.PrintCanonicalTypes && TAW) {
Index: clang/include/clang/AST/PrettyPrinter.h
===
--- clang/include/clang/AST/PrettyPrinter.h
+++ clang/include/clang/AST/PrettyPrinter.h
@@ -130,6 +130,9 @@
   /// Suppresses printing of scope specifiers.
   unsigned SuppressScope : 1;
 
+  /// When SuppressScope is true, do not apply it to template parameters.
+  unsigned NoSuppressTemplateParamsScope : 1;
+
   /// Suppress printing parts of scope specifiers that are never
   /// written, e.g., for anonymous namespaces.
   unsigned SuppressUnwrittenScope : 1;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137464: [NFC][lldb] Remove unnecessary branch in TypeSystemClang::DumpTypeDescription()

2022-11-07 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec1bd2546d34: [NFC][lldb] Remove unnecessary branch in 
TypeSystemClang::DumpTypeDescription() (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137464

Files:
  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
@@ -9221,14 +9221,8 @@
   if (level == eDescriptionLevelVerbose)
 record_decl->dump(llvm_ostrm);
   else {
-if (auto *cxx_record_decl =
-llvm::dyn_cast(record_decl))
-  cxx_record_decl->print(llvm_ostrm,
- getASTContext().getPrintingPolicy(),
- s->GetIndentLevel());
-else
-  record_decl->print(llvm_ostrm, getASTContext().getPrintingPolicy(),
- s->GetIndentLevel());
+record_decl->print(llvm_ostrm, getASTContext().getPrintingPolicy(),
+   s->GetIndentLevel());
   }
 } break;
 


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9221,14 +9221,8 @@
   if (level == eDescriptionLevelVerbose)
 record_decl->dump(llvm_ostrm);
   else {
-if (auto *cxx_record_decl =
-llvm::dyn_cast(record_decl))
-  cxx_record_decl->print(llvm_ostrm,
- getASTContext().getPrintingPolicy(),
- s->GetIndentLevel());
-else
-  record_decl->print(llvm_ostrm, getASTContext().getPrintingPolicy(),
- s->GetIndentLevel());
+record_decl->print(llvm_ostrm, getASTContext().getPrintingPolicy(),
+   s->GetIndentLevel());
   }
 } break;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137464: [NFC][lldb] Remove unnecessary branch in TypeSystemClang::DumpTypeDescription()

2022-11-04 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137464

Files:
  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
@@ -9221,14 +9221,8 @@
   if (level == eDescriptionLevelVerbose)
 record_decl->dump(llvm_ostrm);
   else {
-if (auto *cxx_record_decl =
-llvm::dyn_cast(record_decl))
-  cxx_record_decl->print(llvm_ostrm,
- getASTContext().getPrintingPolicy(),
- s->GetIndentLevel());
-else
-  record_decl->print(llvm_ostrm, getASTContext().getPrintingPolicy(),
- s->GetIndentLevel());
+record_decl->print(llvm_ostrm, getASTContext().getPrintingPolicy(),
+   s->GetIndentLevel());
   }
 } break;
 


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9221,14 +9221,8 @@
   if (level == eDescriptionLevelVerbose)
 record_decl->dump(llvm_ostrm);
   else {
-if (auto *cxx_record_decl =
-llvm::dyn_cast(record_decl))
-  cxx_record_decl->print(llvm_ostrm,
- getASTContext().getPrintingPolicy(),
- s->GetIndentLevel());
-else
-  record_decl->print(llvm_ostrm, getASTContext().getPrintingPolicy(),
- s->GetIndentLevel());
+record_decl->print(llvm_ostrm, getASTContext().getPrintingPolicy(),
+   s->GetIndentLevel());
   }
 } break;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names when looking up functions

2022-11-03 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d83a57721de: [lldb] Support simplified template names when 
looking up functions (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137098

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
  lldb/test/API/functionalities/breakpoint/cpp/main.cpp

Index: lldb/test/API/functionalities/breakpoint/cpp/main.cpp
===
--- lldb/test/API/functionalities/breakpoint/cpp/main.cpp
+++ lldb/test/API/functionalities/breakpoint/cpp/main.cpp
@@ -94,6 +94,8 @@
 
   template  void operator<<(T t) {}
 };
+
+template  void g() {}
 } // namespace ns
 
 int main (int argc, char const *argv[])
@@ -123,5 +125,8 @@
 f.operator<<(5);
 f.operator<< >({});
 
+ns::g();
+ns::g();
+
 return 0;
 }
Index: lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
===
--- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -12,7 +12,16 @@
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 def test(self):
-self.build()
+self.do_test(dict())
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
 self.breakpoint_id_tests()
 
 def verify_breakpoint_locations(self, target, bp_dict):
@@ -57,7 +66,11 @@
 
 # Template cases
 {'name': 'func', 'loc_names': []},
+{'name': 'Foo::func', 'loc_names': []},
+{'name': 'ns::Foo::func', 'loc_names': []},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'Foo::func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'ns::Foo::func', 'loc_names': ['auto ns::Foo::func()']},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()',
'auto ns::Foo::func>()']},
 
@@ -71,6 +84,15 @@
 {'name': 'operator<<', 'loc_names': ['void ns::Foo::operator<<(int)']},
 {'name': 'ns::Foo::operator<<', 'loc_names': ['void ns::Foo::operator<<(int)',
   'void ns::Foo::operator<<>(ns::Foo)']},
+
+{'name': 'g', 'loc_names': []},
+{'name': 'g', 'loc_names': ['void ns::g()']},
+{'name': 'g', 'loc_names': ['void ns::g()']},
+{'name': 'g', 'loc_names': ['void ns::g()', 'void ns::g()']},
+{'name': 'ns::g', 'loc_names': []},
+{'name': 'ns::g', 'loc_names': ['void ns::g()']},
+{'name': 'ns::g', 'loc_names': ['void ns::g()']},
+{'name': 'ns::g', 'loc_names': ['void ns::g()', 'void ns::g()']},
 ]
 
 for bp_dict in bp_dicts:
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2389,6 +2389,24 @@
   ResolveFunction(die, include_inlines, sc_list);
 return true;
   });
+  // With -gsimple-template-names, a templated type's DW_AT_name will not
+  // contain the template parameters. Try again stripping '<' and anything
+  // after, filtering out entries with template parameters that don't match.
+  {
+const llvm::StringRef name_ref = name.GetStringRef();
+auto it = name_ref.find('<');
+if (it != llvm::StringRef::npos) {
+  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
+
+  Module::LookupInfo no_tp_lookup_info(lookup_info);
+  no_tp_lookup_info.SetLookupName(ConstString(name_no_template_params));
+  m_index->GetFunctions(no_tp_lookup_info, *this, parent_decl_ctx, [&](DWARFDIE die) {
+if (resolved_dies.insert(die.GetDIE()).second)
+  ResolveFunction(die, include_inlines, sc_list);
+return true;
+  });
+}
+  }
 
   // Return the number of variable that were appended to the list
   const uint32_t num_matches = sc_list.GetSize() - original_size;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84974: Enable Launching the Debugee in VSCode Terminal

2022-11-02 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.
Herald added a project: All.

the added test `TestVSCode_runInTerminal` consistently fails for me locally with

  Failed to attach to the target process. Timed out trying to get messages from 
the runInTerminal launcher

I've asked other people and they've also reported consistent (or flaky) 
failures of this test. Any idea of what could be going wrong?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84974

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


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

2022-11-02 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

In D137098#3902140 , @labath wrote:

> Why is it that the other indexes don't need an equivalent fix? Could it be 
> that you just haven't tried those code paths?
>
> If they do need it, then it'd be good if we could make the fix in a single 
> place. Possibly by putting the retry logic at a higher level?

Other indexes as in the other manual index indexes? Or as in other higher level 
indexes?




Comment at: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp:450
   }
   if (name_type_mask & eFunctionNameTypeBase) {
 if (!m_set.function_basenames.Find(

labath wrote:
> Are you sure this doesn't need to be repeated for `eFunctionNameTypeBase`? 
> that's where non-member functions end up...
you're right, but I've moved this up into SymbolFileDWARF


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137098

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


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

2022-11-02 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 472770.
aeubanks added a comment.

move retry into SymbolFileDWARF
add tests for non-member functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137098

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
  lldb/test/API/functionalities/breakpoint/cpp/main.cpp

Index: lldb/test/API/functionalities/breakpoint/cpp/main.cpp
===
--- lldb/test/API/functionalities/breakpoint/cpp/main.cpp
+++ lldb/test/API/functionalities/breakpoint/cpp/main.cpp
@@ -94,6 +94,8 @@
 
   template  void operator<<(T t) {}
 };
+
+template  void g() {}
 } // namespace ns
 
 int main (int argc, char const *argv[])
@@ -123,5 +125,8 @@
 f.operator<<(5);
 f.operator<< >({});
 
+ns::g();
+ns::g();
+
 return 0;
 }
Index: lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
===
--- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -12,7 +12,16 @@
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 def test(self):
-self.build()
+self.do_test(dict())
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
 self.breakpoint_id_tests()
 
 def verify_breakpoint_locations(self, target, bp_dict):
@@ -57,7 +66,11 @@
 
 # Template cases
 {'name': 'func', 'loc_names': []},
+{'name': 'Foo::func', 'loc_names': []},
+{'name': 'ns::Foo::func', 'loc_names': []},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'Foo::func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'ns::Foo::func', 'loc_names': ['auto ns::Foo::func()']},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()',
'auto ns::Foo::func>()']},
 
@@ -71,6 +84,15 @@
 {'name': 'operator<<', 'loc_names': ['void ns::Foo::operator<<(int)']},
 {'name': 'ns::Foo::operator<<', 'loc_names': ['void ns::Foo::operator<<(int)',
   'void ns::Foo::operator<<>(ns::Foo)']},
+
+{'name': 'g', 'loc_names': []},
+{'name': 'g', 'loc_names': ['void ns::g()']},
+{'name': 'g', 'loc_names': ['void ns::g()']},
+{'name': 'g', 'loc_names': ['void ns::g()', 'void ns::g()']},
+{'name': 'ns::g', 'loc_names': []},
+{'name': 'ns::g', 'loc_names': ['void ns::g()']},
+{'name': 'ns::g', 'loc_names': ['void ns::g()']},
+{'name': 'ns::g', 'loc_names': ['void ns::g()', 'void ns::g()']},
 ]
 
 for bp_dict in bp_dicts:
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2389,6 +2389,24 @@
   ResolveFunction(die, include_inlines, sc_list);
 return true;
   });
+  // With -gsimple-template-names, a templated type's DW_AT_name will not
+  // contain the template parameters. Try again stripping '<' and anything
+  // after, filtering out entries with template parameters that don't match.
+  {
+const llvm::StringRef name_ref = name.GetStringRef();
+auto it = name_ref.find('<');
+if (it != llvm::StringRef::npos) {
+  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
+
+  Module::LookupInfo no_tp_lookup_info(lookup_info);
+  no_tp_lookup_info.SetLookupName(ConstString(name_no_template_params));
+  m_index->GetFunctions(no_tp_lookup_info, *this, parent_decl_ctx, [&](DWARFDIE die) {
+if (resolved_dies.insert(die.GetDIE()).second)
+  ResolveFunction(die, include_inlines, sc_list);
+return true;
+  });
+}
+  }
 
   // Return the number of variable that were appended to the list
   const uint32_t num_matches = sc_list.GetSize() - original_size;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-11-01 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa715b1bde910: [lldb] Dont crash when printing static 
enum members with bool as underlying… (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137045

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -154,12 +154,6 @@
   return IsIntegerType(is_signed) || IsEnumerationType(is_signed);
 }
 
-bool CompilerType::IsBooleanType() const {
-  if (IsValid())
-return m_type_system->IsBooleanType(m_type);
-  return false;
-}
-
 bool CompilerType::IsPointerType(CompilerType *pointee_type) const {
   if (IsValid()) {
 return m_type_system->IsPointerType(m_type, pointee_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -592,8 +592,6 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool _signed) override;
 
-  bool IsBooleanType(lldb::opaque_compiler_type_t type) override;
-
   bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
 
   static bool IsObjCClassType(const CompilerType );
@@ -863,8 +861,6 @@
   static void SetIntegerInitializerForVariable(clang::VarDecl *var,
const llvm::APInt _value);
 
-  static void SetBoolInitializerForVariable(clang::VarDecl *var, bool value);
-
   /// Initializes a variable with a floating point value.
   /// \param var The variable to initialize. Must not already have an
   ///initializer and must have a floating point type.
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3226,20 +3226,6 @@
   return false;
 }
 
-bool TypeSystemClang::IsBooleanType(lldb::opaque_compiler_type_t type) {
-  if (!type)
-return false;
-
-  clang::QualType qual_type(GetCanonicalQualType(type));
-  const clang::BuiltinType *builtin_type =
-  llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
-
-  if (!builtin_type)
-return false;
-
-  return builtin_type->isBooleanType();
-}
-
 bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 bool _signed) {
   if (type) {
@@ -7593,18 +7579,6 @@
   return var_decl;
 }
 
-void TypeSystemClang::SetBoolInitializerForVariable(VarDecl *var, bool value) {
-  assert(!var->hasInit() && "variable already initialized");
-

[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

updated description with why this doesn't produce false positives with 
breakpoints

this doesn't support regex function name lookup, not sure if we care enough 
about the interaction between regexes/function names under simple template 
names. if we do, we could instead add template parameters to the names we put 
in the manual index. I did take a quick look at doing that but it'd require 
more work


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137098

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


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.
Herald added a subscriber: JDevlieghere.

(I don't understand why this works yet, it should be giving us false positives?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137098

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


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a subscriber: arphaman.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This makes setting breakpoints work with -gsimple-template-names.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137098

Files:
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py


Index: 
lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
===
--- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -12,7 +12,16 @@
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 def test(self):
-self.build()
+self.do_test(dict())
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
 self.breakpoint_id_tests()
 
 def verify_breakpoint_locations(self, target, bp_dict):
@@ -57,7 +66,11 @@
 
 # Template cases
 {'name': 'func', 'loc_names': []},
+{'name': 'Foo::func', 'loc_names': []},
+{'name': 'ns::Foo::func', 'loc_names': []},
 {'name': 'func', 'loc_names': ['auto 
ns::Foo::func()']},
+{'name': 'Foo::func', 'loc_names': ['auto 
ns::Foo::func()']},
+{'name': 'ns::Foo::func', 'loc_names': ['auto 
ns::Foo::func()']},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()',
'auto 
ns::Foo::func>()']},
 
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -464,6 +464,17 @@
 if (!m_set.function_methods.Find(
 name, DIERefCallback(callback, name.GetStringRef(
   return;
+// With -gsimple-template-names, the die name may not contain template
+// parameters. Try stripping the template parameters and try again.
+const llvm::StringRef name_ref = name.AsCString();
+auto it = name_ref.find('<');
+if (it != llvm::StringRef::npos) {
+  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
+  if (!m_set.function_methods.Find(
+  ConstString(name_no_template_params),
+  DIERefCallback(callback, name_no_template_params)))
+return;
+}
   }
 
   if (name_type_mask & eFunctionNameTypeSelector &&


Index: lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
===
--- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -12,7 +12,16 @@
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 def test(self):
-self.build()
+self.do_test(dict())
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
 self.breakpoint_id_tests()
 
 def verify_breakpoint_locations(self, target, bp_dict):
@@ -57,7 +66,11 @@
 
 # Template cases
 {'name': 'func', 'loc_names': []},
+{'name': 'Foo::func', 'loc_names': []},
+{'name': 'ns::Foo::func', 'loc_names': []},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'Foo::func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'ns::Foo::func', 'loc_names': ['auto ns::Foo::func()']},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()',
'auto ns::Foo::func>()']},
 
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -464,6 +464,17 @@
 if (!m_set.function_methods.Find(
 name, DIERefCallback(callback, name.GetStringRef(
   return;
+// With -gsimple-template-names, the die name may not contain 

[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 472061.
aeubanks added a comment.

capitalize comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137045

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -154,12 +154,6 @@
   return IsIntegerType(is_signed) || IsEnumerationType(is_signed);
 }
 
-bool CompilerType::IsBooleanType() const {
-  if (IsValid())
-return m_type_system->IsBooleanType(m_type);
-  return false;
-}
-
 bool CompilerType::IsPointerType(CompilerType *pointee_type) const {
   if (IsValid()) {
 return m_type_system->IsPointerType(m_type, pointee_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -592,8 +592,6 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool _signed) override;
 
-  bool IsBooleanType(lldb::opaque_compiler_type_t type) override;
-
   bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
 
   static bool IsObjCClassType(const CompilerType );
@@ -863,8 +861,6 @@
   static void SetIntegerInitializerForVariable(clang::VarDecl *var,
const llvm::APInt _value);
 
-  static void SetBoolInitializerForVariable(clang::VarDecl *var, bool value);
-
   /// Initializes a variable with a floating point value.
   /// \param var The variable to initialize. Must not already have an
   ///initializer and must have a floating point type.
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3226,20 +3226,6 @@
   return false;
 }
 
-bool TypeSystemClang::IsBooleanType(lldb::opaque_compiler_type_t type) {
-  if (!type)
-return false;
-
-  clang::QualType qual_type(GetCanonicalQualType(type));
-  const clang::BuiltinType *builtin_type =
-  llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
-
-  if (!builtin_type)
-return false;
-
-  return builtin_type->isBooleanType();
-}
-
 bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 bool _signed) {
   if (type) {
@@ -7593,18 +7579,6 @@
   return var_decl;
 }
 
-void TypeSystemClang::SetBoolInitializerForVariable(VarDecl *var, bool value) {
-  assert(!var->hasInit() && "variable already initialized");
-
-  QualType qt = var->getType();
-  assert(qt->isSpecificBuiltinType(BuiltinType::Bool) &&
- "only boolean 

[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:7612
+  ->getIntegerType()
+  ->isSpecificBuiltinType(BuiltinType::Bool)) &&
  "only boolean supported");

DavidSpickett wrote:
> Can you call `TypeSystemClang::IsBooleanType` from here instead?
better?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137045

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


[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 472053.
aeubanks added a comment.
Herald added a reviewer: shafik.

undo a lot of code added in D135169 . it 
seems a little overengineered when we can just check if the type is bool when 
setting the initializer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137045

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -154,12 +154,6 @@
   return IsIntegerType(is_signed) || IsEnumerationType(is_signed);
 }
 
-bool CompilerType::IsBooleanType() const {
-  if (IsValid())
-return m_type_system->IsBooleanType(m_type);
-  return false;
-}
-
 bool CompilerType::IsPointerType(CompilerType *pointee_type) const {
   if (IsValid()) {
 return m_type_system->IsPointerType(m_type, pointee_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -592,8 +592,6 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool _signed) override;
 
-  bool IsBooleanType(lldb::opaque_compiler_type_t type) override;
-
   bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
 
   static bool IsObjCClassType(const CompilerType );
@@ -863,8 +861,6 @@
   static void SetIntegerInitializerForVariable(clang::VarDecl *var,
const llvm::APInt _value);
 
-  static void SetBoolInitializerForVariable(clang::VarDecl *var, bool value);
-
   /// Initializes a variable with a floating point value.
   /// \param var The variable to initialize. Must not already have an
   ///initializer and must have a floating point type.
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3226,20 +3226,6 @@
   return false;
 }
 
-bool TypeSystemClang::IsBooleanType(lldb::opaque_compiler_type_t type) {
-  if (!type)
-return false;
-
-  clang::QualType qual_type(GetCanonicalQualType(type));
-  const clang::BuiltinType *builtin_type =
-  llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
-
-  if (!builtin_type)
-return false;
-
-  return builtin_type->isBooleanType();
-}
-
 bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 bool _signed) {
   if (type) {
@@ -7593,18 +7579,6 @@
   return var_decl;
 }
 
-void TypeSystemClang::SetBoolInitializerForVariable(VarDecl *var, 

[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-30 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Extends D135169  to work with enums with bool 
as the underlying type.

Fixes #58383.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137045

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp


Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = 
static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", 
result_value="scoped_enum_case2")
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3234,6 +3234,14 @@
   const clang::BuiltinType *builtin_type =
   
llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
 
+  if (!builtin_type) {
+if (const clang::EnumType *enum_type = llvm::dyn_cast(
+qual_type->getCanonicalTypeInternal())) {
+  builtin_type = llvm::dyn_cast(
+  enum_type->getDecl()->getIntegerType());
+}
+  }
+
   if (!builtin_type)
 return false;
 
@@ -7597,7 +7605,11 @@
   assert(!var->hasInit() && "variable already initialized");
 
   QualType qt = var->getType();
-  assert(qt->isSpecificBuiltinType(BuiltinType::Bool) &&
+  assert((qt->isSpecificBuiltinType(BuiltinType::Bool) ||
+  cast(qt)
+  ->getDecl()
+  ->getIntegerType()
+  ->isSpecificBuiltinType(BuiltinType::Bool)) &&
  "only boolean supported");
 
   clang::ASTContext  = var->getASTContext();


Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-28 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa842f7405679: [lldb] Support simplified template names 
(authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
  lldb/test/API/lang/cpp/unique-types2/Makefile
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -0,0 +1,27 @@
+template  struct Foo {
+  T t;
+  template  class Nested {
+U u;
+  };
+};
+
+template  class FooPack {
+  T t;
+};
+
+int main() {
+  Foo t1;
+  Foo t2;
+  Foo> t3;
+
+  FooPack p1;
+  FooPack p2;
+  FooPack> p3;
+  FooPack p4;
+  FooPack p5;
+  FooPack p6;
+  FooPack p7;
+
+  Foo::Nested n1;
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
@@ -0,0 +1,61 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+def do_test(self, debug_flags):
+"""Test that we only display the requested Foo instantiation, not all Foo instantiations."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t '::Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t '::FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t '::Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect_expr("t1", result_type="Foo")
+self.expect_expr("t1", result_type="Foo")
+self.expect_expr("t2", result_type="Foo")
+self.expect_expr("t3", result_type="Foo >")
+self.expect_expr("p1", result_type="FooPack")
+self.expect_expr("p2", result_type="FooPack")
+self.expect_expr("p3", result_type="FooPack >")
+

[Lldb-commits] [PATCH] D136959: clang: Improve errors for DiagnosticInfoResourceLimit

2022-10-28 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

see https://reviews.llvm.org/D110665 for how we get line/col from a function. 
basically, we have a map from function name hashes to source location available 
in clang

if we don't have clang source information for functions available, there's not 
much more we can do other than rely on debug info, which is what the default 
LLVM handlers use when possible. that's why lld doesn't have its own handler

> Backend errors are not observed with -save-temps and -fno-gpu-rdc or -flto, 
> and the compile incorrectly succeeds.

not sure why this would be happening




Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:42
+def note_fe_backend_resource_limit: Note<"%0 (%1) exceeds limit (%2) in 
'%3'">, BackendInfo;
+
+

ultra nit: extra blank line


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

https://reviews.llvm.org/D136959

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


[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-28 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 471585.
aeubanks added a comment.

rename variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
  lldb/test/API/lang/cpp/unique-types2/Makefile
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -0,0 +1,27 @@
+template  struct Foo {
+  T t;
+  template  class Nested {
+U u;
+  };
+};
+
+template  class FooPack {
+  T t;
+};
+
+int main() {
+  Foo t1;
+  Foo t2;
+  Foo> t3;
+
+  FooPack p1;
+  FooPack p2;
+  FooPack> p3;
+  FooPack p4;
+  FooPack p5;
+  FooPack p6;
+  FooPack p7;
+
+  Foo::Nested n1;
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
@@ -0,0 +1,61 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+def do_test(self, debug_flags):
+"""Test that we only display the requested Foo instantiation, not all Foo instantiations."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t '::Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t '::FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t '::Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect_expr("t1", result_type="Foo")
+self.expect_expr("t1", result_type="Foo")
+self.expect_expr("t2", result_type="Foo")
+self.expect_expr("t3", result_type="Foo >")
+self.expect_expr("p1", result_type="FooPack")
+self.expect_expr("p2", result_type="FooPack")
+self.expect_expr("p3", result_type="FooPack >")
+self.expect_expr("p4", result_type="FooPack")
+self.expect_expr("p5", 

[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-27 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3809
 
+ConstString TypeSystemClang::GetBaseName(lldb::opaque_compiler_type_t type) {
+  if (!type)

this was mostly copied from `GetTypeName` above, not sure if these two should 
be factored out?



Comment at: lldb/test/API/lang/cpp/unique-types2/main.cpp:20
+  FooPack t6;
+  FooPack t7;
+  // Set breakpoint here

Michael137 wrote:
> aeubanks wrote:
> > labath wrote:
> > > Would it be interesting to test nested types as well (`Foo::Bar`) ?
> > yes, and that caught a bug, thanks for the suggestion
> > 
> > I've added a `Type::GetBaseName()`, could you take a look at that?
> Out of curiosity, what was the issue with using the qualified name?
`GetQualifiedName` returns the name including any scopes, so in this case it 
gave `Foo::Nested` rather than `Nested` and the `'<'` string 
logic ended up comparing `::Nested` to ``


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

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


[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-27 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 471375.
aeubanks marked an inline comment as done.
aeubanks added a comment.

combine GetBaseName into GetTypeName


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
  lldb/test/API/lang/cpp/unique-types2/Makefile
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -0,0 +1,27 @@
+template  struct Foo {
+  T t;
+  template  class Nested {
+U u;
+  };
+};
+
+template  class FooPack {
+  T t;
+};
+
+int main() {
+  Foo t1;
+  Foo t2;
+  Foo> t3;
+
+  FooPack p1;
+  FooPack p2;
+  FooPack> p3;
+  FooPack p4;
+  FooPack p5;
+  FooPack p6;
+  FooPack p7;
+
+  Foo::Nested n1;
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
@@ -0,0 +1,61 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+def do_test(self, debug_flags):
+"""Test that we only display the requested Foo instantiation, not all Foo instantiations."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t '::Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t '::FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t '::Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect_expr("t1", result_type="Foo")
+self.expect_expr("t1", result_type="Foo")
+self.expect_expr("t2", result_type="Foo")
+self.expect_expr("t3", result_type="Foo >")
+self.expect_expr("p1", result_type="FooPack")
+self.expect_expr("p2", result_type="FooPack")
+self.expect_expr("p3", result_type="FooPack >")
+self.expect_expr("p4", 

[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-27 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

regarding the failure in TestCPPBreakpointLocations.py (added recently in 
https://reviews.llvm.org/D135921, seems like it's catching real issues with 
this patch), it looks like the manual dwarf index needs a similar fix to this

In D134378#3888462 , @labath wrote:

> I can't say I fully understand all of this code, but I also don't know who 
> would, so I guess I'll just say it "looks good" :)
>
> I am wondering about the testing situation though. If I understand correctly, 
> you've run the test suite with hardcoded simplified names, and it all passed 
> (?)

yes, that was true until https://reviews.llvm.org/D135921, which catches some 
missing functionality in this patch around breakpoints (I'd still like to defer 
that to a separate patch)

> I am definitely not suggesting we add a new test suite mode for that, but 
> maybe we could extend this one test case with extra check that look at the 
> type names in other contexts than in name lookup (e.g. expression evaluation, 
> backtraces, ???) -- just to make sure that something doesn't break there in 
> the future. WDYT?

I've added expression evaluation to the test. do you have examples of backtrace 
tests?




Comment at: lldb/test/API/lang/cpp/unique-types2/main.cpp:20
+  FooPack t6;
+  FooPack t7;
+  // Set breakpoint here

labath wrote:
> Would it be interesting to test nested types as well (`Foo::Bar`) ?
yes, and that caught a bug, thanks for the suggestion

I've added a `Type::GetBaseName()`, could you take a look at that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

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


[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-27 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 471330.
aeubanks added a comment.

fix nested types by introducing Type::GetBaseName()
add expr eval tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
  lldb/test/API/lang/cpp/unique-types2/Makefile
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -0,0 +1,27 @@
+template  struct Foo {
+  T t;
+  template  class Nested {
+U u;
+  };
+};
+
+template  class FooPack {
+  T t;
+};
+
+int main() {
+  Foo t1;
+  Foo t2;
+  Foo> t3;
+
+  FooPack p1;
+  FooPack p2;
+  FooPack> p3;
+  FooPack p4;
+  FooPack p5;
+  FooPack p6;
+  FooPack p7;
+
+  Foo::Nested n1;
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
@@ -0,0 +1,61 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+def do_test(self, debug_flags):
+"""Test that we only display the requested Foo instantiation, not all Foo instantiations."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t '::Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t '::FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t '::Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect_expr("t1", result_type="Foo")
+self.expect_expr("t1", result_type="Foo")
+self.expect_expr("t2", result_type="Foo")
+self.expect_expr("t3", result_type="Foo >")
+self.expect_expr("p1", result_type="FooPack")
+self.expect_expr("p2", result_type="FooPack")
+self.expect_expr("p3", result_type="FooPack >")
+self.expect_expr("p4", 

[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-25 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 470617.
aeubanks added a comment.

revert breakpoint test change
we can leave that to a later change, so I think this change is ready to go


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
  lldb/test/API/lang/cpp/unique-types2/Makefile
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -0,0 +1,22 @@
+template  class Foo {
+  T t;
+};
+
+template  class FooPack {
+  T t;
+};
+
+int main() {
+  Foo t1;
+  Foo t2;
+  Foo> t3;
+
+  FooPack p1;
+  FooPack p2;
+  FooPack> p3;
+  FooPack t4;
+  FooPack t5;
+  FooPack t6;
+  FooPack t7;
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
@@ -0,0 +1,40 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+def do_test(self, debug_flags):
+"""Test that we only display the requested Foo instantiation, not all Foo instantiations."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_name(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_name(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
+
Index: lldb/test/API/lang/cpp/unique-types2/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
===
--- lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
+++ lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
@@ -51,7 +51,7 @@
 # Record types without a defining declaration are not complete.
 self.assertPointeeIncomplete("FwdClass *", "fwd_class")
 self.assertPointeeIncomplete("FwdClassTypedef *", "fwd_class_typedef")
-self.assertPointeeIncomplete("FwdTemplateClass<> *", "fwd_template_class")
+self.assertPointeeIncomplete("FwdTemplateClass *", "fwd_template_class")
 
 # A pointer type is complete even when it points to an incomplete type.
 fwd_class_ptr = self.expect_expr("fwd_class", result_type="FwdClass *")
Index: 

[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-24 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1551
+}
+if (!all_template_names.empty()) {
+  all_template_names.append(">");

labath wrote:
> When can this be empty? Should we still include the `<>` in those cases?
it was empty when we're working with a non-templated die, so a lot of cases. 
I've added an early exit and changed this to an assert



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2500
+const llvm::StringRef nameRef = name.GetStringRef();
+auto it = nameRef.find('<');
+if (it != llvm::StringRef::npos) {

labath wrote:
> Michael137 wrote:
> > Is there some other way to determine whether the debug-info was generated 
> > from `-gsimple-template-names`? Then we wouldn't have to check the 
> > existence of a `<` in the name in multiple places and wouldn't have to do 
> > this lookup speculatively. With this change, if we fail to find a template 
> > type in the index, we would do the lookup all over again, only to not find 
> > it again. Could that get expensive? Just trying to figure out if we can 
> > avoid doing this `GetTypes` call twice.
> > 
> > There have been [talks](https://github.com/llvm/llvm-project/issues/58362) 
> > about doing a base-name search by default followed by fuzzy matching on 
> > template parameters (though in the context of function names). The 
> > `simple-template-names` came up as a good motivator/facilitator for doing 
> > so. But for that idea to work here we'd have to be able to retrieve from 
> > the index by basename, so perhaps out of the scope of what we're trying to 
> > do here
> > 
> > tagging people involved in that discussion: @dblaikie @aprantl @jingham 
> > @labath
> > 
> > Other than this, generally LGTM
> Negative matches should be fast, and since typically only one of the branches 
> will produce any results, I think this should be fine. Filtering matches in 
> the simplified case would be slower, since you'd have build the full name of 
> all potential candidates (and that could be thousands of instantiations), but 
> I don't know how slow. But that's the price we pay for better filtering 
> (which we don't do right now, but we could start doing afterwards).
Done.

I believe the only difference with `-gsimple-template-names` is that the name 
doesn't contain the template parameters, so I don't think there's any other way 
of determining if the debug info was generated from `-gsimple-template-names`.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2577
 
   ConstString name = pattern.back().name;
 

labath wrote:
> Do we need to do something similar in this FindTypes overload as well?
I was wondering when this code path is even taken, turns out it's only called 
from lldb-test, and only in two tests:
```
  lldb-shell :: SymbolFile/DWARF/x86/compilercontext.ll
  lldb-shell :: SymbolFile/DWARF/x86/module-ownership.mm
```
so probably doesn't need to be updated?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

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


[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-24 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 470321.
aeubanks marked 3 inline comments as done.
aeubanks added a comment.

address comments

rebasing to ToT, TestCPPBreakpointsLocations.py is failing when using 
-gsimple-template-names. still working on that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
  lldb/test/API/lang/cpp/unique-types2/Makefile
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -0,0 +1,22 @@
+template  class Foo {
+  T t;
+};
+
+template  class FooPack {
+  T t;
+};
+
+int main() {
+  Foo t1;
+  Foo t2;
+  Foo> t3;
+
+  FooPack p1;
+  FooPack p2;
+  FooPack> p3;
+  FooPack t4;
+  FooPack t5;
+  FooPack t6;
+  FooPack t7;
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
@@ -0,0 +1,40 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+def do_test(self, debug_flags):
+"""Test that we only display the requested Foo instantiation, not all Foo instantiations."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_name(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_name(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
+
Index: lldb/test/API/lang/cpp/unique-types2/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
===
--- lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
+++ lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
@@ -51,7 +51,7 @@
 # Record types without a defining declaration are not complete.
 self.assertPointeeIncomplete("FwdClass *", "fwd_class")
 self.assertPointeeIncomplete("FwdClassTypedef *", "fwd_class_typedef")
-self.assertPointeeIncomplete("FwdTemplateClass<> *", "fwd_template_class")
+self.assertPointeeIncomplete("FwdTemplateClass *", "fwd_template_class")
 
 # A pointer type is complete even when it points to an 

[Lldb-commits] [PATCH] D136011: [lldb] Don't check environment default char signedness when creating clang type for "char"

2022-10-20 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGba8ded6820fa: [lldb] Dont check environment default 
char signedness when creating clang type… (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136011

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/commands/expression/char/TestExprsChar.py
  lldb/test/API/commands/expression/char/main.cpp


Index: lldb/test/API/commands/expression/char/main.cpp
===
--- lldb/test/API/commands/expression/char/main.cpp
+++ lldb/test/API/commands/expression/char/main.cpp
@@ -1,5 +1,9 @@
 #include 
 
+char g = 0;
+signed char gs = 0;
+unsigned char gu = 0;
+
 int foo(char c) { return 1; }
 int foo(signed char c) { return 2; }
 int foo(unsigned char c) { return 3; }
Index: lldb/test/API/commands/expression/char/TestExprsChar.py
===
--- lldb/test/API/commands/expression/char/TestExprsChar.py
+++ lldb/test/API/commands/expression/char/TestExprsChar.py
@@ -14,30 +14,15 @@
 self.expect_expr("foo(c)", result_value="1")
 self.expect_expr("foo(sc)", result_value="2")
 self.expect_expr("foo(uc)", result_value="3")
+self.expect_expr("g", result_type="char")
+self.expect_expr("gs", result_type="signed char")
+self.expect_expr("gu", result_type="unsigned char")
 
 def test_default_char(self):
 self.do_test()
 
-@skipIf(oslist=["linux"], archs=["aarch64", "arm"], 
bugnumber="llvm.org/pr23069")
-@expectedFailureAll(
-archs=[
-"powerpc64le",
-"s390x"],
-bugnumber="llvm.org/pr23069")
 def test_signed_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
 
-@expectedFailureAll(
-archs=[
-"i[3-6]86",
-"x86_64",
-"arm64",
-'arm64e',
-'armv7',
-'armv7k',
-'arm64_32'],
-bugnumber="llvm.org/pr23069, ")
-@expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
-@expectedFailureAll(oslist=['windows'], archs=['aarch64'], 
bugnumber="llvm.org/pr23069")
 def test_unsigned_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'})
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1063,7 +1063,7 @@
 break;
 
   case DW_ATE_signed_char:
-if (ast.getLangOpts().CharIsSigned && type_name == "char") {
+if (type_name == "char") {
   if (QualTypeMatchesBitSize(bit_size, ast, ast.CharTy))
 return GetType(ast.CharTy);
 }
@@ -1115,7 +1115,7 @@
 break;
 
   case DW_ATE_unsigned_char:
-if (!ast.getLangOpts().CharIsSigned && type_name == "char") {
+if (type_name == "char") {
   if (QualTypeMatchesBitSize(bit_size, ast, ast.CharTy))
 return GetType(ast.CharTy);
 }


Index: lldb/test/API/commands/expression/char/main.cpp
===
--- lldb/test/API/commands/expression/char/main.cpp
+++ lldb/test/API/commands/expression/char/main.cpp
@@ -1,5 +1,9 @@
 #include 
 
+char g = 0;
+signed char gs = 0;
+unsigned char gu = 0;
+
 int foo(char c) { return 1; }
 int foo(signed char c) { return 2; }
 int foo(unsigned char c) { return 3; }
Index: lldb/test/API/commands/expression/char/TestExprsChar.py
===
--- lldb/test/API/commands/expression/char/TestExprsChar.py
+++ lldb/test/API/commands/expression/char/TestExprsChar.py
@@ -14,30 +14,15 @@
 self.expect_expr("foo(c)", result_value="1")
 self.expect_expr("foo(sc)", result_value="2")
 self.expect_expr("foo(uc)", result_value="3")
+self.expect_expr("g", result_type="char")
+self.expect_expr("gs", result_type="signed char")
+self.expect_expr("gu", result_type="unsigned char")
 
 def test_default_char(self):
 self.do_test()
 
-@skipIf(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr23069")
-@expectedFailureAll(
-archs=[
-"powerpc64le",
-"s390x"],
-bugnumber="llvm.org/pr23069")
 def test_signed_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
 
-@expectedFailureAll(
-archs=[
-"i[3-6]86",
-"x86_64",
-"arm64",
-'arm64e',
-'armv7',
-'armv7k',
-'arm64_32'],
-bugnumber="llvm.org/pr23069, ")
-@expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
-  

[Lldb-commits] [PATCH] D136011: [lldb] Don't check environment default char signedness when creating clang type for "char"

2022-10-18 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

In D136011#3862150 , @labath wrote:

> In D136011#3860637 , @dblaikie 
> wrote:
>
>> I think the place where this will go wrong is in terms of how lldb renders 
>> `char` values on non-default-char-signedness programs (it'll render them as 
>> the default-char-signedness, which might be confusing to a user - since 
>> they'll be looking at literals, etc, that are the other signedness) and how 
>> lldb will interpret char literals (though that'll already be wrong - since 
>> the literals are already being parsed with the default-char-signedness, I 
>> think).
>
> Yes, I'm pretty sure that will happen. OTOH, I don't think there's any value 
> to fix this in a completely satisfactory way. Like, if the whole program was 
> consistently with the non-default signedness, we could try to detect it and 
> then configure the internal AST defaults accordingly. But that's hard to 
> detect, and I'd be surprised if most programs are completely homogeneous like 
> this.
>
> So, overall, I quite like this fix.

Maybe looking for a "char" entry and setting `ast.getLangOpts().CharIsSigned` 
from it would probably work in most cases, but not sure that it's worth the 
effort. Rendering the wrong signedness for chars doesn't seem like the worst 
thing, and this patch improves things (as the removed `expectedFailureAll` 
show, plus this helps with some testing of lldb I've been doing). I can add a 
TODO if you'd like.

>> I'm curious why there were all those expected failures re: PR23069. Were 
>> they not using the default char signedness? Or is the test using explicit 
>> signedness, and so whatever platforms happen not to have the explicit value 
>> sa their default are/were failing?
>
> Yes, I'm pretty sure that's the case.
>
> In D136011#3861792 , @DavidSpickett 
> wrote:
>
>>> With -f(un)signed-char, the die corresponding to "char" may be the wrong 
>>> DW_ATE_(un)signed_char.
>>
>> As the producer of the DWARF (so, clang for example) is this correct by the 
>> existing rules?
>
> Yes, because DWARF never expected people will be round-tripping the debug 
> info back into C(++). As far as it is concerned, it has correctly given you 
> the signedness of the type.

"wrong" is inaccurate, I've updated the summary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136011

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


[Lldb-commits] [PATCH] D135827: [lldb] Print newline between found types

2022-10-17 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG569be95a4089: [lldb] Print newline between found types 
(authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135827

Files:
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
  lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
  lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp


Index: lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
@@ -0,0 +1,13 @@
+namespace a {
+struct Foo {};
+} // namespace a
+
+namespace b {
+struct Foo {};
+} // namespace b
+
+int main() {
+  a::Foo a;
+  b::Foo b;
+  return 0; // Set breakpoint here
+}
Index: 
lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
@@ -0,0 +1,16 @@
+"""
+Test that we properly print multiple types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestTypeLookupDuplicate(TestBase):
+
+def test_namespace_only(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", 
lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t Foo", DATA_TYPES_DISPLAYED_CORRECTLY, 
substrs=["2 matches found", "\nid =", "\nid ="])
Index: lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1663,8 +1663,8 @@
 typedef_type_sp = typedefed_type_sp;
 typedefed_type_sp = typedef_type_sp->GetTypedefType();
   }
+  strm.EOL();
 }
-strm.EOL();
   }
   return type_list.GetSize();
 }


Index: lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
@@ -0,0 +1,13 @@
+namespace a {
+struct Foo {};
+} // namespace a
+
+namespace b {
+struct Foo {};
+} // namespace b
+
+int main() {
+  a::Foo a;
+  b::Foo b;
+  return 0; // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
@@ -0,0 +1,16 @@
+"""
+Test that we properly print multiple types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestTypeLookupDuplicate(TestBase):
+
+def test_namespace_only(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t Foo", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["2 matches found", "\nid =", "\nid ="])
Index: lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1663,8 +1663,8 @@
 typedef_type_sp = typedefed_type_sp;
 typedefed_type_sp = typedef_type_sp->GetTypedefType();
   }
+  strm.EOL();
 }
-strm.EOL();
   }
   return type_list.GetSize();
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D136011: [lldb] Don't check environment default char signedness when creating clang type for "char"

2022-10-16 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 468118.
aeubanks added a comment.

update test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136011

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/commands/expression/char/TestExprsChar.py
  lldb/test/API/commands/expression/char/main.cpp


Index: lldb/test/API/commands/expression/char/main.cpp
===
--- lldb/test/API/commands/expression/char/main.cpp
+++ lldb/test/API/commands/expression/char/main.cpp
@@ -1,5 +1,9 @@
 #include 
 
+char g = 0;
+signed char gs = 0;
+unsigned char gu = 0;
+
 int foo(char c) { return 1; }
 int foo(signed char c) { return 2; }
 int foo(unsigned char c) { return 3; }
Index: lldb/test/API/commands/expression/char/TestExprsChar.py
===
--- lldb/test/API/commands/expression/char/TestExprsChar.py
+++ lldb/test/API/commands/expression/char/TestExprsChar.py
@@ -14,30 +14,15 @@
 self.expect_expr("foo(c)", result_value="1")
 self.expect_expr("foo(sc)", result_value="2")
 self.expect_expr("foo(uc)", result_value="3")
+self.expect_expr("g", result_type="char")
+self.expect_expr("gs", result_type="signed char")
+self.expect_expr("gu", result_type="unsigned char")
 
 def test_default_char(self):
 self.do_test()
 
-@skipIf(oslist=["linux"], archs=["aarch64", "arm"], 
bugnumber="llvm.org/pr23069")
-@expectedFailureAll(
-archs=[
-"powerpc64le",
-"s390x"],
-bugnumber="llvm.org/pr23069")
 def test_signed_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
 
-@expectedFailureAll(
-archs=[
-"i[3-6]86",
-"x86_64",
-"arm64",
-'arm64e',
-'armv7',
-'armv7k',
-'arm64_32'],
-bugnumber="llvm.org/pr23069, ")
-@expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
-@expectedFailureAll(oslist=['windows'], archs=['aarch64'], 
bugnumber="llvm.org/pr23069")
 def test_unsigned_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'})
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1063,7 +1063,7 @@
 break;
 
   case DW_ATE_signed_char:
-if (ast.getLangOpts().CharIsSigned && type_name == "char") {
+if (type_name == "char") {
   if (QualTypeMatchesBitSize(bit_size, ast, ast.CharTy))
 return GetType(ast.CharTy);
 }
@@ -1115,7 +1115,7 @@
 break;
 
   case DW_ATE_unsigned_char:
-if (!ast.getLangOpts().CharIsSigned && type_name == "char") {
+if (type_name == "char") {
   if (QualTypeMatchesBitSize(bit_size, ast, ast.CharTy))
 return GetType(ast.CharTy);
 }


Index: lldb/test/API/commands/expression/char/main.cpp
===
--- lldb/test/API/commands/expression/char/main.cpp
+++ lldb/test/API/commands/expression/char/main.cpp
@@ -1,5 +1,9 @@
 #include 
 
+char g = 0;
+signed char gs = 0;
+unsigned char gu = 0;
+
 int foo(char c) { return 1; }
 int foo(signed char c) { return 2; }
 int foo(unsigned char c) { return 3; }
Index: lldb/test/API/commands/expression/char/TestExprsChar.py
===
--- lldb/test/API/commands/expression/char/TestExprsChar.py
+++ lldb/test/API/commands/expression/char/TestExprsChar.py
@@ -14,30 +14,15 @@
 self.expect_expr("foo(c)", result_value="1")
 self.expect_expr("foo(sc)", result_value="2")
 self.expect_expr("foo(uc)", result_value="3")
+self.expect_expr("g", result_type="char")
+self.expect_expr("gs", result_type="signed char")
+self.expect_expr("gu", result_type="unsigned char")
 
 def test_default_char(self):
 self.do_test()
 
-@skipIf(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr23069")
-@expectedFailureAll(
-archs=[
-"powerpc64le",
-"s390x"],
-bugnumber="llvm.org/pr23069")
 def test_signed_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
 
-@expectedFailureAll(
-archs=[
-"i[3-6]86",
-"x86_64",
-"arm64",
-'arm64e',
-'armv7',
-'armv7k',
-'arm64_32'],
-bugnumber="llvm.org/pr23069, ")
-@expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
-@expectedFailureAll(oslist=['windows'], archs=['aarch64'], bugnumber="llvm.org/pr23069")
 def 

[Lldb-commits] [PATCH] D136011: [lldb] Don't check environment default char signedness when creating clang type for "char"

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

not 100% sure this is the right fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136011

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


[Lldb-commits] [PATCH] D136011: [lldb] Don't check environment default char signedness when creating clang type for "char"

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

With -f(un)signed-char, the die corresponding to "char" may be the wrong 
DW_ATE_(un)signed_char. Ultimately we can determine whether a type is the 
unspecified signedness char by looking if its name is "char" (as opposed to 
"signed char"/"unsigned char").

Fixes #23443


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136011

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/commands/expression/char/TestExprsChar.py
  lldb/test/API/commands/expression/char/main.cpp


Index: lldb/test/API/commands/expression/char/main.cpp
===
--- lldb/test/API/commands/expression/char/main.cpp
+++ lldb/test/API/commands/expression/char/main.cpp
@@ -1,5 +1,7 @@
 #include 
 
+char g = 0;
+
 int foo(char c) { return 1; }
 int foo(signed char c) { return 2; }
 int foo(unsigned char c) { return 3; }
Index: lldb/test/API/commands/expression/char/TestExprsChar.py
===
--- lldb/test/API/commands/expression/char/TestExprsChar.py
+++ lldb/test/API/commands/expression/char/TestExprsChar.py
@@ -14,30 +14,13 @@
 self.expect_expr("foo(c)", result_value="1")
 self.expect_expr("foo(sc)", result_value="2")
 self.expect_expr("foo(uc)", result_value="3")
+self.expect_expr("g", result_type="char")
 
 def test_default_char(self):
 self.do_test()
 
-@skipIf(oslist=["linux"], archs=["aarch64", "arm"], 
bugnumber="llvm.org/pr23069")
-@expectedFailureAll(
-archs=[
-"powerpc64le",
-"s390x"],
-bugnumber="llvm.org/pr23069")
 def test_signed_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
 
-@expectedFailureAll(
-archs=[
-"i[3-6]86",
-"x86_64",
-"arm64",
-'arm64e',
-'armv7',
-'armv7k',
-'arm64_32'],
-bugnumber="llvm.org/pr23069, ")
-@expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
-@expectedFailureAll(oslist=['windows'], archs=['aarch64'], 
bugnumber="llvm.org/pr23069")
 def test_unsigned_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'})
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1063,7 +1063,7 @@
 break;
 
   case DW_ATE_signed_char:
-if (ast.getLangOpts().CharIsSigned && type_name == "char") {
+if (type_name == "char") {
   if (QualTypeMatchesBitSize(bit_size, ast, ast.CharTy))
 return GetType(ast.CharTy);
 }
@@ -1115,7 +1115,7 @@
 break;
 
   case DW_ATE_unsigned_char:
-if (!ast.getLangOpts().CharIsSigned && type_name == "char") {
+if (type_name == "char") {
   if (QualTypeMatchesBitSize(bit_size, ast, ast.CharTy))
 return GetType(ast.CharTy);
 }


Index: lldb/test/API/commands/expression/char/main.cpp
===
--- lldb/test/API/commands/expression/char/main.cpp
+++ lldb/test/API/commands/expression/char/main.cpp
@@ -1,5 +1,7 @@
 #include 
 
+char g = 0;
+
 int foo(char c) { return 1; }
 int foo(signed char c) { return 2; }
 int foo(unsigned char c) { return 3; }
Index: lldb/test/API/commands/expression/char/TestExprsChar.py
===
--- lldb/test/API/commands/expression/char/TestExprsChar.py
+++ lldb/test/API/commands/expression/char/TestExprsChar.py
@@ -14,30 +14,13 @@
 self.expect_expr("foo(c)", result_value="1")
 self.expect_expr("foo(sc)", result_value="2")
 self.expect_expr("foo(uc)", result_value="3")
+self.expect_expr("g", result_type="char")
 
 def test_default_char(self):
 self.do_test()
 
-@skipIf(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr23069")
-@expectedFailureAll(
-archs=[
-"powerpc64le",
-"s390x"],
-bugnumber="llvm.org/pr23069")
 def test_signed_char(self):
 self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
 
-@expectedFailureAll(
-archs=[
-"i[3-6]86",
-"x86_64",
-"arm64",
-'arm64e',
-'armv7',
-'armv7k',
-'arm64_32'],
-bugnumber="llvm.org/pr23069, ")
-@expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
-@expectedFailureAll(oslist=['windows'], archs=['aarch64'], bugnumber="llvm.org/pr23069")
 def test_unsigned_char(self):
 

[Lldb-commits] [PATCH] D135979: [lldb][NFCish] Move DWARFDebugInfoEntry::GetQualifiedName() into DWARFASTParserClang

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1534
+  std::string qualified_name;
+  DWARFDIE parent_decl_ctx_die = die.GetParentDeclContextDIE();
+  // TODO: change this to get the correct decl context parent

shafik wrote:
> So it looks like you can do `SymbolFileDWARF::GetDWARFDeclContext(...)`  and 
> `DWARFDeclContext` has `GetQualifiedName()` which I think is doing what you 
> are doing below and maybe handles more cases. 
`DWARFDeclContext` doesn't have access to the clang AST, which in D134378 we 
will use to reconstruct template parameters (I hope I'm understanding your 
suggestion correctly, still new to lldb)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135979

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


[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 467946.
aeubanks added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
  lldb/test/API/lang/cpp/unique-types2/Makefile
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -0,0 +1,22 @@
+template  class Foo {
+  T t;
+};
+
+template  class FooPack {
+  T t;
+};
+
+int main() {
+  Foo t1;
+  Foo t2;
+  Foo> t3;
+
+  FooPack p1;
+  FooPack p2;
+  FooPack> p3;
+  FooPack t4;
+  FooPack t5;
+  FooPack t6;
+  FooPack t7;
+  // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes.py
@@ -0,0 +1,40 @@
+"""
+Test that we return only the requested template instantiation.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+def do_test(self, debug_flags):
+"""Test that we only display the requested Foo instantiation, not all Foo instantiations."""
+self.build(dictionary=debug_flags)
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'Foo'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack >'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'FooPack'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_name(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_no_simple_template_name(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gno-simple-template-names"))
+
Index: lldb/test/API/lang/cpp/unique-types2/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/unique-types2/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
===
--- lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
+++ lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
@@ -51,7 +51,7 @@
 # Record types without a defining declaration are not complete.
 self.assertPointeeIncomplete("FwdClass *", "fwd_class")
 self.assertPointeeIncomplete("FwdClassTypedef *", "fwd_class_typedef")
-self.assertPointeeIncomplete("FwdTemplateClass<> *", "fwd_template_class")
+self.assertPointeeIncomplete("FwdTemplateClass *", "fwd_template_class")
 
 # A pointer type is complete even when it points to an incomplete type.
 fwd_class_ptr = self.expect_expr("fwd_class", result_type="FwdClass *")
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- 

[Lldb-commits] [PATCH] D135979: [lldb][NFCish] Move DWARFDebugInfoEntry::GetQualifiedName() into DWARFASTParserClang

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8a98287f255b: [lldb][NFCish] Move 
DWARFDebugInfoEntry::GetQualifiedName() into… (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135979

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2960,8 +2960,6 @@
 
 if (!try_resolving_type) {
   if (log) {
-std::string qualified_name;
-type_die.GetQualifiedName(qualified_name);
 GetObjectFile()->GetModule()->LogMessage(
 log,
 "SymbolFileDWARF::"
@@ -2969,7 +2967,7 @@
 "qualified-name='%s') ignoring die=0x%8.8x (%s)",
 DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
 dwarf_decl_ctx.GetQualifiedName(), type_die.GetOffset(),
-qualified_name.c_str());
+type_die.GetName());
   }
   return true;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -99,11 +99,6 @@
 
   const char *GetPubname(const DWARFUnit *cu) const;
 
-  const char *GetQualifiedName(DWARFUnit *cu, std::string ) const;
-
-  const char *GetQualifiedName(DWARFUnit *cu, const DWARFAttributes ,
-   std::string ) const;
-
   bool GetDIENamesAndRanges(
   DWARFUnit *cu, const char *, const char *,
   DWARFRangeList , int _file, int _line,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -798,66 +798,6 @@
   return DWARFDIE();
 }
 
-const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
-  std::string ) const {
-  DWARFAttributes attributes;
-  GetAttributes(cu, attributes, Recurse::yes);
-  return GetQualifiedName(cu, attributes, storage);
-}
-
-const char *
-DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
-  const DWARFAttributes ,
-  std::string ) const {
-
-  const char *name = GetName(cu);
-
-  if (name) {
-DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
-storage.clear();
-// TODO: change this to get the correct decl context parent
-while (parent_decl_ctx_die) {
-  const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
-  switch (parent_tag) {
-  case DW_TAG_namespace: {
-const char *namespace_name = parent_decl_ctx_die.GetName();
-if (namespace_name) {
-  storage.insert(0, "::");
-  storage.insert(0, namespace_name);
-} else {
-  storage.insert(0, "(anonymous namespace)::");
-}
-parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
-  } break;
-
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-  case DW_TAG_union_type: {
-const char *class_union_struct_name = parent_decl_ctx_die.GetName();
-
-if (class_union_struct_name) {
-  storage.insert(0, "::");
-  storage.insert(0, class_union_struct_name);
-}
-parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
-  } break;
-
-  default:
-parent_decl_ctx_die.Clear();
-break;
-  }
-}
-
-if (storage.empty())
-  storage.append("::");
-
-storage.append(name);
-  }
-  if (storage.empty())
-return nullptr;
-  return storage.c_str();
-}
-
 lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const {
   return GetOffset() + llvm::getULEB128Size(m_abbr_idx);
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -30,8 +30,6 @@
 
   const char *GetPubname() const;
 
-  const char *GetQualifiedName(std::string ) const;
-
   using 

[Lldb-commits] [PATCH] D135979: [lldb][NFCish] Move DWARFDebugInfoEntry::GetQualifiedName() into DWARFASTParserClang

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 467916.
aeubanks added a comment.

check if string is empty before assigning to unique_typename


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135979

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2960,8 +2960,6 @@
 
 if (!try_resolving_type) {
   if (log) {
-std::string qualified_name;
-type_die.GetQualifiedName(qualified_name);
 GetObjectFile()->GetModule()->LogMessage(
 log,
 "SymbolFileDWARF::"
@@ -2969,7 +2967,7 @@
 "qualified-name='%s') ignoring die=0x%8.8x (%s)",
 DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
 dwarf_decl_ctx.GetQualifiedName(), type_die.GetOffset(),
-qualified_name.c_str());
+type_die.GetName());
   }
   return true;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -99,11 +99,6 @@
 
   const char *GetPubname(const DWARFUnit *cu) const;
 
-  const char *GetQualifiedName(DWARFUnit *cu, std::string ) const;
-
-  const char *GetQualifiedName(DWARFUnit *cu, const DWARFAttributes ,
-   std::string ) const;
-
   bool GetDIENamesAndRanges(
   DWARFUnit *cu, const char *, const char *,
   DWARFRangeList , int _file, int _line,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -798,66 +798,6 @@
   return DWARFDIE();
 }
 
-const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
-  std::string ) const {
-  DWARFAttributes attributes;
-  GetAttributes(cu, attributes, Recurse::yes);
-  return GetQualifiedName(cu, attributes, storage);
-}
-
-const char *
-DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
-  const DWARFAttributes ,
-  std::string ) const {
-
-  const char *name = GetName(cu);
-
-  if (name) {
-DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
-storage.clear();
-// TODO: change this to get the correct decl context parent
-while (parent_decl_ctx_die) {
-  const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
-  switch (parent_tag) {
-  case DW_TAG_namespace: {
-const char *namespace_name = parent_decl_ctx_die.GetName();
-if (namespace_name) {
-  storage.insert(0, "::");
-  storage.insert(0, namespace_name);
-} else {
-  storage.insert(0, "(anonymous namespace)::");
-}
-parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
-  } break;
-
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-  case DW_TAG_union_type: {
-const char *class_union_struct_name = parent_decl_ctx_die.GetName();
-
-if (class_union_struct_name) {
-  storage.insert(0, "::");
-  storage.insert(0, class_union_struct_name);
-}
-parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
-  } break;
-
-  default:
-parent_decl_ctx_die.Clear();
-break;
-  }
-}
-
-if (storage.empty())
-  storage.append("::");
-
-storage.append(name);
-  }
-  if (storage.empty())
-return nullptr;
-  return storage.c_str();
-}
-
 lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const {
   return GetOffset() + llvm::getULEB128Size(m_abbr_idx);
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -30,8 +30,6 @@
 
   const char *GetPubname() const;
 
-  const char *GetQualifiedName(std::string ) const;
-
   using DWARFBaseDIE::GetName;
   void GetName(lldb_private::Stream ) const;
 
Index: 

[Lldb-commits] [PATCH] D134378: [lldb] Support simplified template names

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1561
+std::string
+DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE ) {
+  if (!die.IsValid())

dblaikie wrote:
> Sorry, when I gave feedback on some pieces of this that were just moved 
> around rather than new code written in this review - I don't mind the code 
> moving around without changes (and optionally before/after the move making 
> improvements, but not necessary).
> 
> If possible, might simplify the code review to move the code first/separately 
> from this change, if the move isn't too meaningless independent of the rest 
> of the changes?
https://reviews.llvm.org/D135979


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134378

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


[Lldb-commits] [PATCH] D135979: [lldb][NFCish] Move DWARFDebugInfoEntry::GetQualifiedName() into DWARFASTParserClang

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 467868.
aeubanks added a comment.
Herald added a subscriber: JDevlieghere.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135979

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2960,8 +2960,6 @@
 
 if (!try_resolving_type) {
   if (log) {
-std::string qualified_name;
-type_die.GetQualifiedName(qualified_name);
 GetObjectFile()->GetModule()->LogMessage(
 log,
 "SymbolFileDWARF::"
@@ -2969,7 +2967,7 @@
 "qualified-name='%s') ignoring die=0x%8.8x (%s)",
 DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
 dwarf_decl_ctx.GetQualifiedName(), type_die.GetOffset(),
-qualified_name.c_str());
+type_die.GetName());
   }
   return true;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -99,11 +99,6 @@
 
   const char *GetPubname(const DWARFUnit *cu) const;
 
-  const char *GetQualifiedName(DWARFUnit *cu, std::string ) const;
-
-  const char *GetQualifiedName(DWARFUnit *cu, const DWARFAttributes ,
-   std::string ) const;
-
   bool GetDIENamesAndRanges(
   DWARFUnit *cu, const char *, const char *,
   DWARFRangeList , int _file, int _line,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -798,66 +798,6 @@
   return DWARFDIE();
 }
 
-const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
-  std::string ) const {
-  DWARFAttributes attributes;
-  GetAttributes(cu, attributes, Recurse::yes);
-  return GetQualifiedName(cu, attributes, storage);
-}
-
-const char *
-DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
-  const DWARFAttributes ,
-  std::string ) const {
-
-  const char *name = GetName(cu);
-
-  if (name) {
-DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
-storage.clear();
-// TODO: change this to get the correct decl context parent
-while (parent_decl_ctx_die) {
-  const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
-  switch (parent_tag) {
-  case DW_TAG_namespace: {
-const char *namespace_name = parent_decl_ctx_die.GetName();
-if (namespace_name) {
-  storage.insert(0, "::");
-  storage.insert(0, namespace_name);
-} else {
-  storage.insert(0, "(anonymous namespace)::");
-}
-parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
-  } break;
-
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-  case DW_TAG_union_type: {
-const char *class_union_struct_name = parent_decl_ctx_die.GetName();
-
-if (class_union_struct_name) {
-  storage.insert(0, "::");
-  storage.insert(0, class_union_struct_name);
-}
-parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
-  } break;
-
-  default:
-parent_decl_ctx_die.Clear();
-break;
-  }
-}
-
-if (storage.empty())
-  storage.append("::");
-
-storage.append(name);
-  }
-  if (storage.empty())
-return nullptr;
-  return storage.c_str();
-}
-
 lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const {
   return GetOffset() + llvm::getULEB128Size(m_abbr_idx);
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -30,8 +30,6 @@
 
   const char *GetPubname() const;
 
-  const char *GetQualifiedName(std::string ) const;
-
   using DWARFBaseDIE::GetName;
   void GetName(lldb_private::Stream ) const;
 
Index: 

[Lldb-commits] [PATCH] D135979: [lldb][NFCish] Move DWARFDebugInfoEntry::GetQualifiedName() into DWARFASTParserClang

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a reviewer: shafik.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

In D134378 , we'll need the clang AST to be 
able to construct the qualified in some cases.

This makes logging in one place slightly less informative.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135979

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2960,8 +2960,6 @@
 
 if (!try_resolving_type) {
   if (log) {
-std::string qualified_name;
-type_die.GetQualifiedName(qualified_name);
 GetObjectFile()->GetModule()->LogMessage(
 log,
 "SymbolFileDWARF::"
@@ -2969,7 +2967,7 @@
 "qualified-name='%s') ignoring die=0x%8.8x (%s)",
 DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
 dwarf_decl_ctx.GetQualifiedName(), type_die.GetOffset(),
-qualified_name.c_str());
+type_die.GetName());
   }
   return true;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -99,11 +99,6 @@
 
   const char *GetPubname(const DWARFUnit *cu) const;
 
-  const char *GetQualifiedName(DWARFUnit *cu, std::string ) const;
-
-  const char *GetQualifiedName(DWARFUnit *cu, const DWARFAttributes ,
-   std::string ) const;
-
   bool GetDIENamesAndRanges(
   DWARFUnit *cu, const char *, const char *,
   DWARFRangeList , int _file, int _line,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -798,66 +798,6 @@
   return DWARFDIE();
 }
 
-const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
-  std::string ) const {
-  DWARFAttributes attributes;
-  GetAttributes(cu, attributes, Recurse::yes);
-  return GetQualifiedName(cu, attributes, storage);
-}
-
-const char *
-DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
-  const DWARFAttributes ,
-  std::string ) const {
-
-  const char *name = GetName(cu);
-
-  if (name) {
-DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
-storage.clear();
-// TODO: change this to get the correct decl context parent
-while (parent_decl_ctx_die) {
-  const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
-  switch (parent_tag) {
-  case DW_TAG_namespace: {
-const char *namespace_name = parent_decl_ctx_die.GetName();
-if (namespace_name) {
-  storage.insert(0, "::");
-  storage.insert(0, namespace_name);
-} else {
-  storage.insert(0, "(anonymous namespace)::");
-}
-parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
-  } break;
-
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-  case DW_TAG_union_type: {
-const char *class_union_struct_name = parent_decl_ctx_die.GetName();
-
-if (class_union_struct_name) {
-  storage.insert(0, "::");
-  storage.insert(0, class_union_struct_name);
-}
-parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
-  } break;
-
-  default:
-parent_decl_ctx_die.Clear();
-break;
-  }
-}
-
-if (storage.empty())
-  storage.append("::");
-
-storage.append(name);
-  }
-  if (storage.empty())
-return nullptr;
-  return storage.c_str();
-}
-
 lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const {
   return GetOffset() + llvm::getULEB128Size(m_abbr_idx);
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ 

[Lldb-commits] [PATCH] D135827: [lldb] Print newline between found types

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: 
lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py:16
+
+self.expect("image lookup -A -t Foo", DATA_TYPES_DISPLAYED_CORRECTLY, 
substrs=["2 matches found", "\nid =", "\nid ="])

DavidSpickett wrote:
> Could you match the whole string here? A bit easier to see at a glance that 
> way. Unless the output is not stable?
it's
```
(lldb) im loo -t Foo
2 matches found in 
/home/aeubanks/repos/llvm-project/build/cmake/lldb-test-build.noindex/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.test_namespace_only_dwarf/a.out:
id = {0x004f}, name = "Foo", qualified = "a::Foo", byte-size = 1, decl = 
main.cpp:2, compiler_type = "struct Foo {
}"
id = {0x0058}, name = "Foo", qualified = "b::Foo", byte-size = 1, decl = 
main.cpp:6, compiler_type = "struct Foo {
}"
```

I'd rather not depend so much on the exact output since that doesn't 
necessarily look stable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135827

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


[Lldb-commits] [PATCH] D135826: [lldb] Start from end of previous substr when checking ordered substrs

2022-10-14 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG021a3d5a3f73: [lldb] Start from end of previous substr when 
checking ordered substrs (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135826

Files:
  lldb/packages/Python/lldbsuite/test/concurrent_base.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -116,7 +116,7 @@
 substrs=[
 '(char *) $',
 ' = ptr = ',
-' 
"1234567890123456789012345678901234567890123456789012345678901234ABC"'])
+
'"1234567890123456789012345678901234567890123456789012345678901234ABC"'])
 
 self.runCmd("type summary add -c TestPoint")
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2358,7 +2358,7 @@
 start = 0
 for substr in substrs:
 index = output[start:].find(substr)
-start = start + index if ordered and matching else 0
+start = start + index + len(substr) if ordered and matching 
else 0
 matched = index != -1
 log_lines.append("{} sub string: \"{}\" ({})".format(
 expecting_str, substr, found_str(matched)))
Index: lldb/packages/Python/lldbsuite/test/concurrent_base.py
===
--- lldb/packages/Python/lldbsuite/test/concurrent_base.py
+++ lldb/packages/Python/lldbsuite/test/concurrent_base.py
@@ -74,9 +74,7 @@
 bpno = lldbutil.run_break_set_by_file_and_line(
 self, self.filename, line, num_expected_locations=-1)
 bp = self.inferior_target.FindBreakpointByID(bpno)
-descriptions.append(
-": file = 'main.cpp', line = %d" %
-self.finish_breakpoint_line)
+descriptions.append(": file = 'main.cpp', line = %d" % line)
 return bp
 
 def inferior_done(self):


Index: lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -116,7 +116,7 @@
 substrs=[
 '(char *) $',
 ' = ptr = ',
-' "1234567890123456789012345678901234567890123456789012345678901234ABC"'])
+'"1234567890123456789012345678901234567890123456789012345678901234ABC"'])
 
 self.runCmd("type summary add -c TestPoint")
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2358,7 +2358,7 @@
 start = 0
 for substr in substrs:
 index = output[start:].find(substr)
-start = start + index if ordered and matching else 0
+start = start + index + len(substr) if ordered and matching else 0
 matched = index != -1
 log_lines.append("{} sub string: \"{}\" ({})".format(
 expecting_str, substr, found_str(matched)))
Index: lldb/packages/Python/lldbsuite/test/concurrent_base.py
===
--- lldb/packages/Python/lldbsuite/test/concurrent_base.py
+++ lldb/packages/Python/lldbsuite/test/concurrent_base.py
@@ -74,9 +74,7 @@
 bpno = lldbutil.run_break_set_by_file_and_line(
 self, self.filename, line, num_expected_locations=-1)
 bp = self.inferior_target.FindBreakpointByID(bpno)
-descriptions.append(
-": file = 'main.cpp', line = %d" %
-self.finish_breakpoint_line)
+descriptions.append(": file = 'main.cpp', line = %d" % line)
 return bp
 
 def inferior_done(self):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D135827: [lldb] Print newline between found types

2022-10-12 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.
Herald added a subscriber: JDevlieghere.

(depends on https://reviews.llvm.org/D135826 for the test to be meaningful)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135827

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


[Lldb-commits] [PATCH] D135827: [lldb] Print newline between found types

2022-10-12 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Or else multiple entries end up overlapping on the same line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135827

Files:
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
  lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
  lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp


Index: lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
@@ -0,0 +1,13 @@
+namespace a {
+struct Foo {};
+} // namespace a
+
+namespace b {
+struct Foo {};
+} // namespace b
+
+int main() {
+  a::Foo a;
+  b::Foo b;
+  return 0; // Set breakpoint here
+}
Index: 
lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
@@ -0,0 +1,16 @@
+"""
+Test that we properly print multiple types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestTypeLookupDuplicate(TestBase):
+
+def test_namespace_only(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", 
lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t Foo", DATA_TYPES_DISPLAYED_CORRECTLY, 
substrs=["2 matches found", "\nid =", "\nid ="])
Index: lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1663,8 +1663,8 @@
 typedef_type_sp = typedefed_type_sp;
 typedefed_type_sp = typedef_type_sp->GetTypedefType();
   }
+  strm.EOL();
 }
-strm.EOL();
   }
   return type_list.GetSize();
 }


Index: lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
@@ -0,0 +1,13 @@
+namespace a {
+struct Foo {};
+} // namespace a
+
+namespace b {
+struct Foo {};
+} // namespace b
+
+int main() {
+  a::Foo a;
+  b::Foo b;
+  return 0; // Set breakpoint here
+}
Index: lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
@@ -0,0 +1,16 @@
+"""
+Test that we properly print multiple types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestTypeLookupDuplicate(TestBase):
+
+def test_namespace_only(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+self.expect("image lookup -A -t Foo", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["2 matches found", "\nid =", "\nid ="])
Index: lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1663,8 +1663,8 @@
 typedef_type_sp = typedefed_type_sp;
 typedefed_type_sp = typedef_type_sp->GetTypedefType();
   }
+  strm.EOL();
 }
-strm.EOL();
   }
   return type_list.GetSize();
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D135826: [lldb] Start from end of previous substr when checking ordered substrs

2022-10-12 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I'm trying to add a test which tests that the same substr occurs twice in a 
row, but it matches even if only one of the substr occurs.

This found a bug in concurrent_base.py.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135826

Files:
  lldb/packages/Python/lldbsuite/test/concurrent_base.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -116,7 +116,7 @@
 substrs=[
 '(char *) $',
 ' = ptr = ',
-' 
"1234567890123456789012345678901234567890123456789012345678901234ABC"'])
+
'"1234567890123456789012345678901234567890123456789012345678901234ABC"'])
 
 self.runCmd("type summary add -c TestPoint")
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2358,7 +2358,7 @@
 start = 0
 for substr in substrs:
 index = output[start:].find(substr)
-start = start + index if ordered and matching else 0
+start = start + index + len(substr) if ordered and matching 
else 0
 matched = index != -1
 log_lines.append("{} sub string: \"{}\" ({})".format(
 expecting_str, substr, found_str(matched)))
Index: lldb/packages/Python/lldbsuite/test/concurrent_base.py
===
--- lldb/packages/Python/lldbsuite/test/concurrent_base.py
+++ lldb/packages/Python/lldbsuite/test/concurrent_base.py
@@ -74,9 +74,7 @@
 bpno = lldbutil.run_break_set_by_file_and_line(
 self, self.filename, line, num_expected_locations=-1)
 bp = self.inferior_target.FindBreakpointByID(bpno)
-descriptions.append(
-": file = 'main.cpp', line = %d" %
-self.finish_breakpoint_line)
+descriptions.append(": file = 'main.cpp', line = %d" % line)
 return bp
 
 def inferior_done(self):


Index: lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -116,7 +116,7 @@
 substrs=[
 '(char *) $',
 ' = ptr = ',
-' "1234567890123456789012345678901234567890123456789012345678901234ABC"'])
+'"1234567890123456789012345678901234567890123456789012345678901234ABC"'])
 
 self.runCmd("type summary add -c TestPoint")
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2358,7 +2358,7 @@
 start = 0
 for substr in substrs:
 index = output[start:].find(substr)
-start = start + index if ordered and matching else 0
+start = start + index + len(substr) if ordered and matching else 0
 matched = index != -1
 log_lines.append("{} sub string: \"{}\" ({})".format(
 expecting_str, substr, found_str(matched)))
Index: lldb/packages/Python/lldbsuite/test/concurrent_base.py
===
--- lldb/packages/Python/lldbsuite/test/concurrent_base.py
+++ lldb/packages/Python/lldbsuite/test/concurrent_base.py
@@ -74,9 +74,7 @@
 bpno = lldbutil.run_break_set_by_file_and_line(
 self, self.filename, line, num_expected_locations=-1)
 bp = self.inferior_target.FindBreakpointByID(bpno)
-descriptions.append(
-": file = 'main.cpp', line = %d" %
-self.finish_breakpoint_line)
+descriptions.append(": file = 'main.cpp', line = %d" % line)
 return bp
 
 def inferior_done(self):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   >