[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/68705

>From ca4d1bbdeb4ea541199e3db3518b35eb2d5a8cad Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 10 Oct 2023 15:07:56 +0300
Subject: [PATCH 01/14] [lldb] Add SBType::FindNestedType() function

---
 lldb/bindings/interface/SBTypeDocstrings.i  |  7 +++
 lldb/include/lldb/API/SBType.h  |  2 ++
 lldb/include/lldb/Symbol/Type.h |  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h   |  4 
 lldb/source/API/SBType.cpp  |  9 +
 .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp|  4 
 .../Plugins/TypeSystem/Clang/TypeSystemClang.h  |  2 ++
 lldb/source/Symbol/Type.cpp | 13 +
 lldb/source/Symbol/TypeSystem.cpp   |  4 
 9 files changed, 47 insertions(+)

diff --git a/lldb/bindings/interface/SBTypeDocstrings.i 
b/lldb/bindings/interface/SBTypeDocstrings.i
index 96421a6aa20104b..b4ec67da957c7d4 100644
--- a/lldb/bindings/interface/SBTypeDocstrings.i
+++ b/lldb/bindings/interface/SBTypeDocstrings.i
@@ -720,6 +720,13 @@ SBType supports the eq/ne operator. For example,::
 "
 ) lldb::SBType::GetTypeFlags;
 
+%feature("docstring",
+"Searches for a nested type that has provided name.
+
+Returns the type if it was found.
+Returns invalid type if nothing was found."
+) lldb::SBType::FindNestedType;
+
 %feature("docstring",
 "Represents a list of :py:class:`SBType` s.
 
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 5962f0c50dee14f..fa02197ff8f3940 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -215,6 +215,8 @@ class SBType {
   bool GetDescription(lldb::SBStream &description,
   lldb::DescriptionLevel description_level);
 
+  lldb::SBType FindNestedType(const char *name);
+
   lldb::SBType &operator=(const lldb::SBType &rhs);
 
   bool operator==(lldb::SBType &rhs);
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 046501931d211a7..6da4aaba401fe14 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -313,6 +313,8 @@ class TypeImpl {
   bool GetDescription(lldb_private::Stream &strm,
   lldb::DescriptionLevel description_level);
 
+  CompilerType FindNestedType(ConstString name);
+
 private:
   bool CheckModule(lldb::ModuleSP &module_sp) const;
   bool CheckExeModule(lldb::ModuleSP &module_sp) const;
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index eb6e453e1aec0d0..b503b66eb528c68 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -135,6 +135,10 @@ class TypeSystem : public PluginInterface,
 
   virtual lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) = 0;
 
+  // CompilerType functions
+
+  virtual CompilerDeclContext GetCompilerDeclContextForType(const 
CompilerType& type);
+
   // Tests
 #ifndef NDEBUG
   /// Verify the integrity of the type to catch CompilerTypes that mix
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index ee5b6447428098e..7fe1836ea5d670b 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -586,6 +586,15 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+SBType SBType::FindNestedType(const char *name) {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (!IsValid())
+return SBType();
+  auto ret = SBType(m_opaque_sp->FindNestedType(ConstString(name)));
+  return ret;
+}
+
 SBTypeList::SBTypeList() : m_opaque_up(new TypeListImpl()) {
   LLDB_INSTRUMENT_VA(this);
 }
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 69cff0f35ae4ab2..b4bf3d3fdb20c1e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2636,6 +2636,10 @@ TypeSystemClang::GetDeclContextForType(const 
CompilerType &type) {
   return GetDeclContextForType(ClangUtil::GetQualType(type));
 }
 
+CompilerDeclContext TypeSystemClang::GetCompilerDeclContextForType(const 
CompilerType& type) {
+  return CreateDeclContext(GetDeclContextForType(type));
+}
+
 /// Aggressively desugar the provided type, skipping past various kinds of
 /// syntactic sugar and other constructs one typically wants to ignore.
 /// The \p mask argument allows one to skip certain kinds of simplifications,
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 0544de3cd33befb..806ff64ef0af76b 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -219,6 +219,8 @@ class TypeSystemClang : public TypeSystem 

[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits


@@ -313,6 +313,8 @@ class TypeImpl {
   bool GetDescription(lldb_private::Stream &strm,
   lldb::DescriptionLevel description_level);
 
+  CompilerType FindNestedType(ConstString name);

Endilll wrote:

I followed @Michael137 suggestion that `TypeImpl::FindDirectNestedType` should 
accept `llvm::StringRef` instead. This should be addressed now.

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits


@@ -586,6 +586,15 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+SBType SBType::FindNestedType(const char *name) {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (!IsValid())
+return SBType();
+  auto ret = SBType(m_opaque_sp->FindNestedType(ConstString(name)));

Endilll wrote:

Done!

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Jonas Devlieghere via lldb-commits


@@ -720,6 +720,14 @@ SBType supports the eq/ne operator. For example,::
 "
 ) lldb::SBType::GetTypeFlags;
 
+%feature("docstring",
+"Searches for a directly nested type that has provided name.

JDevlieghere wrote:

`s/has provided name/has the provided name/`

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Jonas Devlieghere via lldb-commits


@@ -135,6 +135,12 @@ class TypeSystem : public PluginInterface,
 
   virtual lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) = 0;
 
+  // CompilerType functions

JDevlieghere wrote:

I know you're just being consistent with the surrounding code but these 
comments add little to no value so we're trying to organically remove them (and 
not add new ones). 

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Jonas Devlieghere via lldb-commits


@@ -586,6 +586,15 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+SBType SBType::FindDirectNestedType(const char *name) {
+  LLDB_INSTRUMENT_VA(this, name);
+
+  if (!IsValid())
+return SBType();
+  auto ret = SBType(m_opaque_sp->FindDirectNestedType(name));
+  return ret;

JDevlieghere wrote:

Can you `return SBType(m_opaque_sp->FindDirectNestedType(name));`?

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Jonas Devlieghere via lldb-commits

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

LGTM with some small nits.

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/68705

>From ca4d1bbdeb4ea541199e3db3518b35eb2d5a8cad Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 10 Oct 2023 15:07:56 +0300
Subject: [PATCH 01/15] [lldb] Add SBType::FindNestedType() function

---
 lldb/bindings/interface/SBTypeDocstrings.i  |  7 +++
 lldb/include/lldb/API/SBType.h  |  2 ++
 lldb/include/lldb/Symbol/Type.h |  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h   |  4 
 lldb/source/API/SBType.cpp  |  9 +
 .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp|  4 
 .../Plugins/TypeSystem/Clang/TypeSystemClang.h  |  2 ++
 lldb/source/Symbol/Type.cpp | 13 +
 lldb/source/Symbol/TypeSystem.cpp   |  4 
 9 files changed, 47 insertions(+)

diff --git a/lldb/bindings/interface/SBTypeDocstrings.i 
b/lldb/bindings/interface/SBTypeDocstrings.i
index 96421a6aa20104b..b4ec67da957c7d4 100644
--- a/lldb/bindings/interface/SBTypeDocstrings.i
+++ b/lldb/bindings/interface/SBTypeDocstrings.i
@@ -720,6 +720,13 @@ SBType supports the eq/ne operator. For example,::
 "
 ) lldb::SBType::GetTypeFlags;
 
+%feature("docstring",
+"Searches for a nested type that has provided name.
+
+Returns the type if it was found.
+Returns invalid type if nothing was found."
+) lldb::SBType::FindNestedType;
+
 %feature("docstring",
 "Represents a list of :py:class:`SBType` s.
 
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 5962f0c50dee14f..fa02197ff8f3940 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -215,6 +215,8 @@ class SBType {
   bool GetDescription(lldb::SBStream &description,
   lldb::DescriptionLevel description_level);
 
+  lldb::SBType FindNestedType(const char *name);
+
   lldb::SBType &operator=(const lldb::SBType &rhs);
 
   bool operator==(lldb::SBType &rhs);
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 046501931d211a7..6da4aaba401fe14 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -313,6 +313,8 @@ class TypeImpl {
   bool GetDescription(lldb_private::Stream &strm,
   lldb::DescriptionLevel description_level);
 
+  CompilerType FindNestedType(ConstString name);
+
 private:
   bool CheckModule(lldb::ModuleSP &module_sp) const;
   bool CheckExeModule(lldb::ModuleSP &module_sp) const;
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index eb6e453e1aec0d0..b503b66eb528c68 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -135,6 +135,10 @@ class TypeSystem : public PluginInterface,
 
   virtual lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) = 0;
 
+  // CompilerType functions
+
+  virtual CompilerDeclContext GetCompilerDeclContextForType(const 
CompilerType& type);
+
   // Tests
 #ifndef NDEBUG
   /// Verify the integrity of the type to catch CompilerTypes that mix
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index ee5b6447428098e..7fe1836ea5d670b 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -586,6 +586,15 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+SBType SBType::FindNestedType(const char *name) {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (!IsValid())
+return SBType();
+  auto ret = SBType(m_opaque_sp->FindNestedType(ConstString(name)));
+  return ret;
+}
+
 SBTypeList::SBTypeList() : m_opaque_up(new TypeListImpl()) {
   LLDB_INSTRUMENT_VA(this);
 }
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 69cff0f35ae4ab2..b4bf3d3fdb20c1e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2636,6 +2636,10 @@ TypeSystemClang::GetDeclContextForType(const 
CompilerType &type) {
   return GetDeclContextForType(ClangUtil::GetQualType(type));
 }
 
+CompilerDeclContext TypeSystemClang::GetCompilerDeclContextForType(const 
CompilerType& type) {
+  return CreateDeclContext(GetDeclContextForType(type));
+}
+
 /// Aggressively desugar the provided type, skipping past various kinds of
 /// syntactic sugar and other constructs one typically wants to ignore.
 /// The \p mask argument allows one to skip certain kinds of simplifications,
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 0544de3cd33befb..806ff64ef0af76b 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -219,6 +219,8 @@ class TypeSystemClang : public TypeSystem 

[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits


@@ -586,6 +586,15 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+SBType SBType::FindDirectNestedType(const char *name) {
+  LLDB_INSTRUMENT_VA(this, name);
+
+  if (!IsValid())
+return SBType();
+  auto ret = SBType(m_opaque_sp->FindDirectNestedType(name));
+  return ret;

Endilll wrote:

Sure. It was a leftover from debugging.

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits


@@ -720,6 +720,14 @@ SBType supports the eq/ne operator. For example,::
 "
 ) lldb::SBType::GetTypeFlags;
 
+%feature("docstring",
+"Searches for a directly nested type that has provided name.

Endilll wrote:

Done

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Jonas Devlieghere via lldb-commits

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

Thanks! LGTM.

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


[Lldb-commits] [lldb] [lldb] Add SBType::FindDirectNestedType() function (PR #68705)

2023-10-13 Thread Vlad Serebrennikov via lldb-commits

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