[Lldb-commits] [lldb] [lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (PR #96985)

2024-06-28 Thread Vlad Serebrennikov via lldb-commits


@@ -106,10 +106,13 @@ ScriptInterpreter::GetOpaqueTypeFromSBEvent(const 
lldb::SBEvent &event) const {
   return event.m_opaque_ptr;
 }
 
-Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream(
+lldb::StreamSP ScriptInterpreter::GetOpaqueTypeFromSBStream(
 const lldb::SBStream &stream) const {
-  if (stream.m_opaque_up)
-return const_cast(stream).m_opaque_up.get();
+  if (stream.m_opaque_up) {
+lldb::StreamSP s = std::make_shared();
+*s << const_cast(stream).GetData();

Endilll wrote:

I think this is what broke my linux build with the following linker error:
```
mold: error: undefined symbol: lldb::SBStream::GetData()
>>> referenced by ScriptInterpreter.cpp
>>>   
>>> lib/liblldbInterpreter.a(ScriptInterpreter.cpp.o):(lldb_private::ScriptInterpreter::GetOpaqueTypeFromSBStream(lldb::SBStream
>>>  const&) const)
```
lld complains in the same way.

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-21 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/92953

This patch remove 36 checks for compiler flags that are done via invoking the 
compiler across LLVM, Clang, and LLDB. It's was made possible by raising the 
bar for supported compilers that has been happening over the years since the 
checks were added.

This is going to improve CMake configuration times. This topic was highlighted 
in 
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.

>From 66e05ac24613435dbe774d49684d8ff9d119c4c3 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 21 May 2024 21:41:24 +0300
Subject: [PATCH] Remove some `try_compile` CMake checks for compiler flags

This patch remove 36 checks for compiler flags that are done via invoking the 
compiler across LLVM, Clang, and LLDB. It's was made possible by raising the 
bar for supported compilers that has been happening over the years since the 
checks were added.

This is going to improve CMake configuration times. This topic was highlighted 
in 
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.
---
 clang/CMakeLists.txt  |   5 +-
 .../tests/functional/exec/CMakeLists.txt  |   6 +-
 lldb/cmake/modules/LLDBConfig.cmake   |  20 +--
 llvm/cmake/config-ix.cmake|  19 +--
 llvm/cmake/modules/AddLLVM.cmake  |   4 +-
 llvm/cmake/modules/HandleLLVMOptions.cmake| 142 --
 third-party/unittest/CMakeLists.txt   |   4 +-
 7 files changed, 80 insertions(+), 120 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c20ce47a12abb..a6bcb853a464c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
   endif ()
 
-  check_cxx_compiler_flag("-Werror -Wnested-anon-types" 
CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
-  if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
-  endif()
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
 endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.
diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt 
b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
index 95c6fdb610e0f..cb6ebda183725 100644
--- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
+++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
@@ -2,11 +2,7 @@ project(exec C)
 
 cmake_minimum_required(VERSION 3.20.0)
 
-include(CheckCCompilerFlag)
-check_c_compiler_flag("-std=c99" C99_SUPPORTED)
-if (C99_SUPPORTED)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
-endif()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
 
 include(CheckFunctionExists)
 include(CheckSymbolExists)
diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 3c6223b015bb1..6458f2e174643 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -187,24 +187,18 @@ 
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
 # form -W, and if supported, add the corresponding -Wno- option.
 
 # Disable GCC warnings
-check_cxx_compiler_flag("-Wdeprecated-declarations" 
CXX_SUPPORTS_DEPRECATED_DECLARATIONS)
-append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS)
-append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING)
-append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
+append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS)
+append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
+append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
 
 check_cxx_compiler_flag("-Wstringop-truncation" 
CXX_SUPPORTS_STRINGOP_TRUNCATION)
 append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" 
CMAKE_CXX_FLAGS)
 
 # Disable Clang warnings
-check_cxx_compiler_flag("-Wdeprecated-register" 
CXX_SUPPORTS_DEPRECATED_REGISTER)
-append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION)
-append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  append("-Wno-deprecated-register" CMAKE_CXX_FLAGS)
+  append("-Wno-vla-extension" CMAKE_CXX_FLAGS)
+endif()
 
 # Disable MSVC warnings
 if( MSVC )
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index bf1b110245bb2..0900e1107076e 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC )
   set(ENABLE_PIC 1)
 else()
   set(ENABLE_P

[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-21 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

On my setup, this patch improves CMake configuration times (from a clean state) 
from 51 seconds down to 46 seconds (average of 3 measurements).

My setup: ancient x86 hardware, Debian Sid, nightly Clang, build directory on a 
RAM disk. CMake invocation:
`cmake -DLLVM_ENABLE_PROJECTS="clang;lldb" 
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxx;libcxxabi" -DCMAKE_BUILD_TYPE=Debug 
-DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_TARGETS_TO_BUILD="X86" 
-DLLVM_ENABLE_DOXYGEN=ON -DLLVM_ENABLE_LIBCXX=ON -DBUILD_SHARED_LIBS=ON 
-DLLDB_ENABLE_PYTHON=ON ~/endill/llvm-project/llvm`.

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-21 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

Here are CE links with the set of minimum required compilers that should cover 
almost all the changes I made:
https://godbolt.org/z/j98xzhrGa
https://godbolt.org/z/errv4WhfP
https://godbolt.org/z/vnoh8YqEP
Windows-targeted flags were tested both on MSVC on CE, and on clang-cl 5.0 
locally.

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-22 Thread Vlad Serebrennikov via lldb-commits

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

>From 66e05ac24613435dbe774d49684d8ff9d119c4c3 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 21 May 2024 21:41:24 +0300
Subject: [PATCH 1/2] Remove some `try_compile` CMake checks for compiler flags

This patch remove 36 checks for compiler flags that are done via invoking the 
compiler across LLVM, Clang, and LLDB. It's was made possible by raising the 
bar for supported compilers that has been happening over the years since the 
checks were added.

This is going to improve CMake configuration times. This topic was highlighted 
in 
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.
---
 clang/CMakeLists.txt  |   5 +-
 .../tests/functional/exec/CMakeLists.txt  |   6 +-
 lldb/cmake/modules/LLDBConfig.cmake   |  20 +--
 llvm/cmake/config-ix.cmake|  19 +--
 llvm/cmake/modules/AddLLVM.cmake  |   4 +-
 llvm/cmake/modules/HandleLLVMOptions.cmake| 142 --
 third-party/unittest/CMakeLists.txt   |   4 +-
 7 files changed, 80 insertions(+), 120 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c20ce47a12abb..a6bcb853a464c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
   endif ()
 
-  check_cxx_compiler_flag("-Werror -Wnested-anon-types" 
CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
-  if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
-  endif()
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
 endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.
diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt 
b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
index 95c6fdb610e0f..cb6ebda183725 100644
--- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
+++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
@@ -2,11 +2,7 @@ project(exec C)
 
 cmake_minimum_required(VERSION 3.20.0)
 
-include(CheckCCompilerFlag)
-check_c_compiler_flag("-std=c99" C99_SUPPORTED)
-if (C99_SUPPORTED)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
-endif()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
 
 include(CheckFunctionExists)
 include(CheckSymbolExists)
diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 3c6223b015bb1..6458f2e174643 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -187,24 +187,18 @@ 
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
 # form -W, and if supported, add the corresponding -Wno- option.
 
 # Disable GCC warnings
-check_cxx_compiler_flag("-Wdeprecated-declarations" 
CXX_SUPPORTS_DEPRECATED_DECLARATIONS)
-append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS)
-append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING)
-append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
+append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS)
+append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
+append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
 
 check_cxx_compiler_flag("-Wstringop-truncation" 
CXX_SUPPORTS_STRINGOP_TRUNCATION)
 append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" 
CMAKE_CXX_FLAGS)
 
 # Disable Clang warnings
-check_cxx_compiler_flag("-Wdeprecated-register" 
CXX_SUPPORTS_DEPRECATED_REGISTER)
-append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION)
-append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  append("-Wno-deprecated-register" CMAKE_CXX_FLAGS)
+  append("-Wno-vla-extension" CMAKE_CXX_FLAGS)
+endif()
 
 # Disable MSVC warnings
 if( MSVC )
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index bf1b110245bb2..0900e1107076e 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC )
   set(ENABLE_PIC 1)
 else()
   set(ENABLE_PIC 0)
-  check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG)
-  if(SUPPORTS_NO_PIE_FLAG)
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
-  endif()
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
 endif()
 
-check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG)
-check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments"
-SUPPORTS_GNU_ZERO_VA

[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-22 Thread Vlad Serebrennikov via lldb-commits

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

>From 66e05ac24613435dbe774d49684d8ff9d119c4c3 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 21 May 2024 21:41:24 +0300
Subject: [PATCH 1/3] Remove some `try_compile` CMake checks for compiler flags

This patch remove 36 checks for compiler flags that are done via invoking the 
compiler across LLVM, Clang, and LLDB. It's was made possible by raising the 
bar for supported compilers that has been happening over the years since the 
checks were added.

This is going to improve CMake configuration times. This topic was highlighted 
in 
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.
---
 clang/CMakeLists.txt  |   5 +-
 .../tests/functional/exec/CMakeLists.txt  |   6 +-
 lldb/cmake/modules/LLDBConfig.cmake   |  20 +--
 llvm/cmake/config-ix.cmake|  19 +--
 llvm/cmake/modules/AddLLVM.cmake  |   4 +-
 llvm/cmake/modules/HandleLLVMOptions.cmake| 142 --
 third-party/unittest/CMakeLists.txt   |   4 +-
 7 files changed, 80 insertions(+), 120 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c20ce47a12abb..a6bcb853a464c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
   endif ()
 
-  check_cxx_compiler_flag("-Werror -Wnested-anon-types" 
CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
-  if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
-  endif()
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
 endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.
diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt 
b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
index 95c6fdb610e0f..cb6ebda183725 100644
--- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
+++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
@@ -2,11 +2,7 @@ project(exec C)
 
 cmake_minimum_required(VERSION 3.20.0)
 
-include(CheckCCompilerFlag)
-check_c_compiler_flag("-std=c99" C99_SUPPORTED)
-if (C99_SUPPORTED)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
-endif()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
 
 include(CheckFunctionExists)
 include(CheckSymbolExists)
diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 3c6223b015bb1..6458f2e174643 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -187,24 +187,18 @@ 
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
 # form -W, and if supported, add the corresponding -Wno- option.
 
 # Disable GCC warnings
-check_cxx_compiler_flag("-Wdeprecated-declarations" 
CXX_SUPPORTS_DEPRECATED_DECLARATIONS)
-append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS)
-append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING)
-append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
+append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS)
+append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
+append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
 
 check_cxx_compiler_flag("-Wstringop-truncation" 
CXX_SUPPORTS_STRINGOP_TRUNCATION)
 append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" 
CMAKE_CXX_FLAGS)
 
 # Disable Clang warnings
-check_cxx_compiler_flag("-Wdeprecated-register" 
CXX_SUPPORTS_DEPRECATED_REGISTER)
-append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION)
-append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  append("-Wno-deprecated-register" CMAKE_CXX_FLAGS)
+  append("-Wno-vla-extension" CMAKE_CXX_FLAGS)
+endif()
 
 # Disable MSVC warnings
 if( MSVC )
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index bf1b110245bb2..0900e1107076e 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC )
   set(ENABLE_PIC 1)
 else()
   set(ENABLE_PIC 0)
-  check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG)
-  if(SUPPORTS_NO_PIE_FLAG)
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
-  endif()
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
 endif()
 
-check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG)
-check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments"
-SUPPORTS_GNU_ZERO_VA

[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-23 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-23 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

Quite expectedly, I see buildbot failures. Working on them.
https://lab.llvm.org/buildbot/#/builders/36/builds/45836
https://lab.llvm.org/buildbot/#/builders/57/builds/35200

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-23 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

> FYI this causes a minor compile-time improvement in stage1 builds using gcc: 
> https://llvm-compile-time-tracker.com/compare.php?from=32c3561d44aa792ef08d72b5a4c342c9965bc4c2&to=4feae05c6abda364a9295aecfa600d7d4e7dfeb6&stat=instructions:u
>  While that's nice, it does suggest that the flags are not the same as before.

@nikic Can you elaborate on those numbers? Do you say that Clang (compiled with 
GCC) which compiles those tests works faster now?

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-30 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

I think the issue is that we no longer passed `-fno-lifetime-dse` to GCC due to 
incorrect condition (my fault), which caused some downstream LTO crashes as 
reported by @mveriksson in 
https://github.com/llvm/llvm-project/commit/4feae05c6abda364a9295aecfa600d7d4e7dfeb6#r142466703
 (thank you very much!). Regressions from fixing it align with the unexpected 
improvements reporter earlier
https://llvm-compile-time-tracker.com/compare.php?from=4bce270157f9a81bd7e38dc589a2970a445d1e96&to=b7f95171c8bf8e5a12a9e185c063ed85cd9dc8ee&stat=instructions:u

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


[Lldb-commits] [lldb] cd676e5 - [lldb] Guard some GCC-style flags from MSVC

2024-06-01 Thread Vlad Serebrennikov via lldb-commits

Author: Vlad Serebrennikov
Date: 2024-06-01T12:48:12+03:00
New Revision: cd676e5b27cb985697deac052c797057f5a33c06

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

LOG: [lldb] Guard some GCC-style flags from MSVC

A follow up to #92953. Suggested in 
https://github.com/llvm/llvm-project/pull/92953#issuecomment-2143274065

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index f2afced7403bd..a60921990cf77 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -186,13 +186,15 @@ 
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
 # printed. Therefore, check for whether the compiler supports options in the
 # form -W, and if supported, add the corresponding -Wno- option.
 
-# Disable GCC warnings
-append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS)
-append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
-append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wstringop-truncation" 
CXX_SUPPORTS_STRINGOP_TRUNCATION)
-append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" 
CMAKE_CXX_FLAGS)
+if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
+  # Disable GCC warnings
+  append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS)
+  append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
+  append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
+
+  check_cxx_compiler_flag("-Wstringop-truncation" 
CXX_SUPPORTS_STRINGOP_TRUNCATION)
+  append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" 
CMAKE_CXX_FLAGS)
+endif()
 
 # Disable Clang warnings
 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")



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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-06-01 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

@vvereschaka Thank you for letting me know! I wonder how this got past our pre- 
and post-commit CI, because we do build lldb with MSVC there. You fix makes 
total sense, so I applied it.

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


[Lldb-commits] [lldb] [lldb] Add Python requirements.txt for test suite (PR #94220)

2024-06-03 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

> I've not been able to find what versioning scheme these 2 packages use, so 
> I'm not sure what versions to put here if any.
> 
> Currently Linaro has: psutil==5.9.4 on Windows psutil == 5.9.8 on Linux 
> pexpect==4.9.0 on Linux
> 
> I don't think it needs to be `==`, but maybe pinning to a version that won't 
> break API? If the projects have such a thing of course.
> 
> This is initially for Github CI, so we could just use the Linux versions.

I think you can list them as minimal required versions for now.

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


[Lldb-commits] [lldb] [lldb] Add Python requirements.txt for test suite (PR #94220)

2024-06-03 Thread Vlad Serebrennikov via lldb-commits

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


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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-06-03 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

Yes, some try_compile checks where replaced with a check for 
`CMAKE_CXX_COMPILER_ID`, so it's crucial for it to reflect the reality.

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


[Lldb-commits] [lldb] [lldb][test] Disable MD5 test for old versions of Visual Studio (PR #94325)

2024-06-04 Thread Vlad Serebrennikov via lldb-commits

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


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


[Lldb-commits] [lldb] Fix single thread stepping timeout race condition (PR #104195)

2024-08-15 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

FYI there was a Linux pre-commit CI build recently that timed out on 
`functionalities/single-thread-step/TestSingleThreadStepTimeout.py`: 
https://buildkite.com/llvm-project/github-pull-requests/builds/91810
Relevant part of the log: 
https://gist.github.com/Endilll/a15335f75f2aa4b211c0b2181b25ff8f


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


[Lldb-commits] [lldb] [llvm] [clang] [clang-tools-extra] [libc] [flang] [libcxx] [compiler-rt] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)

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

Endilll wrote:

There has been multiple discussion in different places about behavior of `-E`, 
`-M`, and friends (the most notable starts 
[here](https://discord.com/channels/636084430946959380/636732781086638081/1175241241710055424)),
 so I thought it would be a good idea to raise awareness among commonly used 
tools. `ccache`, `sccache`, and `distcc` are the ones I know that might be 
directly impacted by this.

https://github.com/ccache/ccache/discussions/1366
https://github.com/mozilla/sccache/discussions/1990
https://github.com/distcc/distcc/issues/494

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


[Lldb-commits] [compiler-rt] [llvm] [lldb] [libcxx] [flang] [libc] [clang-tools-extra] [clang] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)

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

Endilll wrote:

@AaronBallman Can you describe your current plan how driver options are going 
to behave in the light of `#embed`?

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


[Lldb-commits] [clang-tools-extra] [libc] [libcxx] [compiler-rt] [flang] [llvm] [clang] [lldb] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)

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

Endilll wrote:

I'd also like to highlight the use case of diagnostic for compiler crashes. 
IIRC preprocessed source to attach to an issue is produced with 
`-frewrite-includes`, so we might want to change its behavior for `#embed`. 
This might be a good use case for `#embed_base64`.

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


[Lldb-commits] [libc] [compiler-rt] [lldb] [llvm] [flang] [libcxx] [clang] [clang-tools-extra] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)

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

Endilll wrote:

Your reasoning works until we have a crash that relies on `#embed` and/or its 
contents.

>From what I saw triaging old crashes, crash submitters are conscious if they 
>work with proprietary code they can't share even a fragment of, and not so 
>rarely reduce crash by themselves. I'm not fond of the idea on giving up on 
>every embed-related crash, because there is a risk (which I'm not estimating 
>high), that submitter forgot to check their otherwise open code for sensitive 
>information. This doesn't help us ironing out bugs in `#embed` implementation 
>in the long run.

One might say that additional back-and-forth with crash submitter is not too 
big of a deal, and it would be, if we haven't had ever-growing backlog of 
issues, some dating back more than a decade. Our existing workflow that allows 
people to drop attachments on us and forget about it has proven itself useful 
in the very long run. So I'd like us to keep this.

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


[Lldb-commits] [flang] [libcxx] [compiler-rt] [clang] [llvm] [lldb] [clang-tools-extra] [libc] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)

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

Endilll wrote:

> The human-readability of a big list of integers is not better than embedded 
> base64 -- and actually, seems more of a pain to decode.

I agree that the entirety of the data is not too comprehensible, but I can 
imagine users being interested in the first and last N bytes when they tweak 
offset and length of the embed. In this case list of integers is a clear winner.

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


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

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

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


[Lldb-commits] [flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)

2023-12-01 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/74061

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.

>From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Fri, 1 Dec 2023 13:35:23 +0300
Subject: [PATCH 1/2] [clang][NFC] Fill in historical data on when C++ DRs
 100-199 were fixed

---
 clang/test/CXX/drs/dr1xx.cpp | 20 ++--
 clang/www/cxx_dr_status.html | 20 ++--
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp
index 60e80a4c0e1c4f9..50236eb7c9499d4 100644
--- a/clang/test/CXX/drs/dr1xx.cpp
+++ b/clang/test/CXX/drs/dr1xx.cpp
@@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes
   extern "C" S operator+(S, S) { return S(); }
 }
 
-namespace dr108 { // dr108: yes
+namespace dr108 { // dr108: 2.9
   template struct A {
 struct B { typedef int X; };
 B::X x;
@@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes
   } b; // expected-error {{abstract}}
 }
 
-namespace dr115 { // dr115: yes
+namespace dr115 { // dr115: 3.0
   template int f(T); // expected-note +{{}}
   template int g(T); // expected-note +{{}}
   template int g(T, int); // expected-note +{{}}
@@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes
   void g(int n) { n = 2; }
 }
 
-namespace dr141 { // dr141: yes
+namespace dr141 { // dr141: 3.1
   template void f();
   template struct S { int n; }; // expected-note 
{{'::dr141::S::n' declared here}}
   struct A : S {
@@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes
   void i() { C().i(); } // ok!!
 }
 
-namespace dr142 { // dr142: yes
+namespace dr142 { // dr142: 2.8
   class B { // expected-note +{{here}}
   public:
 int mi; // expected-note +{{here}}
@@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes
 
 // dr149: na
 
-namespace dr151 { // dr151: yes
+namespace dr151 { // dr151: 3.1
   struct X {};
   typedef int X::*p;
 #if __cplusplus < 201103L
@@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5
 
 // dr160: na
 
-namespace dr161 { // dr161: yes
+namespace dr161 { // dr161: 3.1
   class A {
   protected:
 struct B { int n; } b; // expected-note 2{{here}}
@@ -724,7 +724,7 @@ namespace dr165 { // dr165: no
   void N::g() {}
 }
 
-namespace dr166 { // dr166: yes
+namespace dr166 { // dr166: 2.9
   namespace A { class X; }
 
   template int f(T t) { return t.n; }
@@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes
 
 // dr174: sup 1012
 
-namespace dr175 { // dr175: yes
+namespace dr175 { // dr175: 2.8
   struct A {}; // expected-note {{here}}
   struct B : private A {}; // expected-note {{constrained by private 
inheritance}}
   struct C : B {
@@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes
   };
 }
 
-namespace dr176 { // dr176: yes
+namespace dr176 { // dr176: 3.1
   template class Y;
   template<> class Y {
 void f() {
@@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes
   int n = &f - &f; // expected-error {{arithmetic on pointers to the function 
type 'void ()'}}
 }
 
-namespace dr180 { // dr180: yes
+namespace dr180 { // dr180: 2.8
   template struct X : T, T::some_base {
 X() : T::some_type_that_might_be_T(), T::some_base() {}
 friend class T::some_class;
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 7cf657a47d64093..141b2aa515ad9ad 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -685,7 +685,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/108.html";>108
 TC1
 Are classes nested in templates dependent?
-Yes
+Clang 2.9
   
   
 https://cplusplus.github.io/CWG/issues/109.html";>109
@@ -727,7 +727,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/115.html";>115
 CD1
 Address of template-id
-Yes
+Clang 3.0
   
   
 https://cplusplus.github.io/CWG/issues/116.html";>116
@@ -883,13 +883,13 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/141.html";>141
 CD1
 Non-member function templates in member access expressions
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/142.html";>142
 TC1
 Injection-related errors in access example
-Yes
+Clang 2.8
   
   
 https://cplusplus.github.io/CWG/issues/143.html";>143
@@ -943,7 +943,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/151.html";>151
 TC1
 Terminology of zero-initialization
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/152.html";>152
@@ -1003,7 +1003,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/161.html";>161
 TC1
 Access to protected nested type
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/162.html";>162
@@ -

[Lldb-commits] [flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)

2023-12-01 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

This PR is created to run the patch through CI, so no review requested.

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


[Lldb-commits] [lld] [libc] [flang] [lldb] [libcxx] [clang] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)

2023-12-01 Thread Vlad Serebrennikov via lldb-commits

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

>From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Fri, 1 Dec 2023 13:35:23 +0300
Subject: [PATCH 1/3] [clang][NFC] Fill in historical data on when C++ DRs
 100-199 were fixed

---
 clang/test/CXX/drs/dr1xx.cpp | 20 ++--
 clang/www/cxx_dr_status.html | 20 ++--
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp
index 60e80a4c0e1c4f9..50236eb7c9499d4 100644
--- a/clang/test/CXX/drs/dr1xx.cpp
+++ b/clang/test/CXX/drs/dr1xx.cpp
@@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes
   extern "C" S operator+(S, S) { return S(); }
 }
 
-namespace dr108 { // dr108: yes
+namespace dr108 { // dr108: 2.9
   template struct A {
 struct B { typedef int X; };
 B::X x;
@@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes
   } b; // expected-error {{abstract}}
 }
 
-namespace dr115 { // dr115: yes
+namespace dr115 { // dr115: 3.0
   template int f(T); // expected-note +{{}}
   template int g(T); // expected-note +{{}}
   template int g(T, int); // expected-note +{{}}
@@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes
   void g(int n) { n = 2; }
 }
 
-namespace dr141 { // dr141: yes
+namespace dr141 { // dr141: 3.1
   template void f();
   template struct S { int n; }; // expected-note 
{{'::dr141::S::n' declared here}}
   struct A : S {
@@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes
   void i() { C().i(); } // ok!!
 }
 
-namespace dr142 { // dr142: yes
+namespace dr142 { // dr142: 2.8
   class B { // expected-note +{{here}}
   public:
 int mi; // expected-note +{{here}}
@@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes
 
 // dr149: na
 
-namespace dr151 { // dr151: yes
+namespace dr151 { // dr151: 3.1
   struct X {};
   typedef int X::*p;
 #if __cplusplus < 201103L
@@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5
 
 // dr160: na
 
-namespace dr161 { // dr161: yes
+namespace dr161 { // dr161: 3.1
   class A {
   protected:
 struct B { int n; } b; // expected-note 2{{here}}
@@ -724,7 +724,7 @@ namespace dr165 { // dr165: no
   void N::g() {}
 }
 
-namespace dr166 { // dr166: yes
+namespace dr166 { // dr166: 2.9
   namespace A { class X; }
 
   template int f(T t) { return t.n; }
@@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes
 
 // dr174: sup 1012
 
-namespace dr175 { // dr175: yes
+namespace dr175 { // dr175: 2.8
   struct A {}; // expected-note {{here}}
   struct B : private A {}; // expected-note {{constrained by private 
inheritance}}
   struct C : B {
@@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes
   };
 }
 
-namespace dr176 { // dr176: yes
+namespace dr176 { // dr176: 3.1
   template class Y;
   template<> class Y {
 void f() {
@@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes
   int n = &f - &f; // expected-error {{arithmetic on pointers to the function 
type 'void ()'}}
 }
 
-namespace dr180 { // dr180: yes
+namespace dr180 { // dr180: 2.8
   template struct X : T, T::some_base {
 X() : T::some_type_that_might_be_T(), T::some_base() {}
 friend class T::some_class;
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 7cf657a47d64093..141b2aa515ad9ad 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -685,7 +685,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/108.html";>108
 TC1
 Are classes nested in templates dependent?
-Yes
+Clang 2.9
   
   
 https://cplusplus.github.io/CWG/issues/109.html";>109
@@ -727,7 +727,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/115.html";>115
 CD1
 Address of template-id
-Yes
+Clang 3.0
   
   
 https://cplusplus.github.io/CWG/issues/116.html";>116
@@ -883,13 +883,13 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/141.html";>141
 CD1
 Non-member function templates in member access expressions
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/142.html";>142
 TC1
 Injection-related errors in access example
-Yes
+Clang 2.8
   
   
 https://cplusplus.github.io/CWG/issues/143.html";>143
@@ -943,7 +943,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/151.html";>151
 TC1
 Terminology of zero-initialization
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/152.html";>152
@@ -1003,7 +1003,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/161.html";>161
 TC1
 Access to protected nested type
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/162.html";>162
@@ -1033,7 +1033,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/166.html";>166
 TC1
 Friend dec

[Lldb-commits] [libcxx] [lldb] [flang] [lld] [clang] [llvm] [libc] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)

2023-12-01 Thread Vlad Serebrennikov via lldb-commits

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

>From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Fri, 1 Dec 2023 13:35:23 +0300
Subject: [PATCH 1/4] [clang][NFC] Fill in historical data on when C++ DRs
 100-199 were fixed

---
 clang/test/CXX/drs/dr1xx.cpp | 20 ++--
 clang/www/cxx_dr_status.html | 20 ++--
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp
index 60e80a4c0e1c4f9..50236eb7c9499d4 100644
--- a/clang/test/CXX/drs/dr1xx.cpp
+++ b/clang/test/CXX/drs/dr1xx.cpp
@@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes
   extern "C" S operator+(S, S) { return S(); }
 }
 
-namespace dr108 { // dr108: yes
+namespace dr108 { // dr108: 2.9
   template struct A {
 struct B { typedef int X; };
 B::X x;
@@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes
   } b; // expected-error {{abstract}}
 }
 
-namespace dr115 { // dr115: yes
+namespace dr115 { // dr115: 3.0
   template int f(T); // expected-note +{{}}
   template int g(T); // expected-note +{{}}
   template int g(T, int); // expected-note +{{}}
@@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes
   void g(int n) { n = 2; }
 }
 
-namespace dr141 { // dr141: yes
+namespace dr141 { // dr141: 3.1
   template void f();
   template struct S { int n; }; // expected-note 
{{'::dr141::S::n' declared here}}
   struct A : S {
@@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes
   void i() { C().i(); } // ok!!
 }
 
-namespace dr142 { // dr142: yes
+namespace dr142 { // dr142: 2.8
   class B { // expected-note +{{here}}
   public:
 int mi; // expected-note +{{here}}
@@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes
 
 // dr149: na
 
-namespace dr151 { // dr151: yes
+namespace dr151 { // dr151: 3.1
   struct X {};
   typedef int X::*p;
 #if __cplusplus < 201103L
@@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5
 
 // dr160: na
 
-namespace dr161 { // dr161: yes
+namespace dr161 { // dr161: 3.1
   class A {
   protected:
 struct B { int n; } b; // expected-note 2{{here}}
@@ -724,7 +724,7 @@ namespace dr165 { // dr165: no
   void N::g() {}
 }
 
-namespace dr166 { // dr166: yes
+namespace dr166 { // dr166: 2.9
   namespace A { class X; }
 
   template int f(T t) { return t.n; }
@@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes
 
 // dr174: sup 1012
 
-namespace dr175 { // dr175: yes
+namespace dr175 { // dr175: 2.8
   struct A {}; // expected-note {{here}}
   struct B : private A {}; // expected-note {{constrained by private 
inheritance}}
   struct C : B {
@@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes
   };
 }
 
-namespace dr176 { // dr176: yes
+namespace dr176 { // dr176: 3.1
   template class Y;
   template<> class Y {
 void f() {
@@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes
   int n = &f - &f; // expected-error {{arithmetic on pointers to the function 
type 'void ()'}}
 }
 
-namespace dr180 { // dr180: yes
+namespace dr180 { // dr180: 2.8
   template struct X : T, T::some_base {
 X() : T::some_type_that_might_be_T(), T::some_base() {}
 friend class T::some_class;
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 7cf657a47d64093..141b2aa515ad9ad 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -685,7 +685,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/108.html";>108
 TC1
 Are classes nested in templates dependent?
-Yes
+Clang 2.9
   
   
 https://cplusplus.github.io/CWG/issues/109.html";>109
@@ -727,7 +727,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/115.html";>115
 CD1
 Address of template-id
-Yes
+Clang 3.0
   
   
 https://cplusplus.github.io/CWG/issues/116.html";>116
@@ -883,13 +883,13 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/141.html";>141
 CD1
 Non-member function templates in member access expressions
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/142.html";>142
 TC1
 Injection-related errors in access example
-Yes
+Clang 2.8
   
   
 https://cplusplus.github.io/CWG/issues/143.html";>143
@@ -943,7 +943,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/151.html";>151
 TC1
 Terminology of zero-initialization
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/152.html";>152
@@ -1003,7 +1003,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/161.html";>161
 TC1
 Access to protected nested type
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/162.html";>162
@@ -1033,7 +1033,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/166.html";>166
 TC1
 Friend dec

[Lldb-commits] [libc] [libcxx] [llvm] [lld] [lldb] [clang] [flang] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)

2023-12-01 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [libc] [compiler-rt] [libclc] [clang] [llvm] [clang-tools-extra] [lld] [flang] [lldb] [libunwind] [libcxx] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-10 Thread Vlad Serebrennikov via lldb-commits

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

>From 1cbf8eec15112cd6871fcfb69425c62f08c8f681 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Jan 2024 14:17:21 +0300
Subject: [PATCH 1/2] [clang] Add tests for DRs about complete-class context
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the 
older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the 
unrestricted forward lookup in complete-class contexts (despite current 
implementation behavior for non-templates).
Wording: The declaration set is the result of a single search in the scope of C 
for N from immediately after the class-specifier of C if P is in a 
complete-class context of C or from P otherwise. [Drafting note: The plan for 
CWG2335 is to describe forbidden dependency cycles among the complete-class 
contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] 
[p7](http://eel.is/c++draft/class#mem.general-7) and 
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests 
only for CWG issues that fall under current definition of complete-class 
context, because I'm not sure how CWG1255 and CWG287 are going to work. That's 
why I skip over them, but mark CWG1308 as superseded by CWG1330.
---
 clang/test/CXX/drs/dr13xx.cpp |  2 ++
 clang/test/CXX/drs/dr16xx.cpp | 22 
 clang/test/CXX/drs/dr18xx.cpp | 38 +++
 clang/test/CXX/drs/dr2335.cpp | 48 +++
 clang/www/cxx_dr_status.html  |  8 +++---
 5 files changed, 109 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CXX/drs/dr2335.cpp

diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 359c04b3e0f3d4..81a8a8a361700a 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -40,6 +40,8 @@ void caller() {
 #endif // __cplusplus >= 201103L
 } // namespace dr1307
 
+// dr1308: sup 1330
+
 namespace dr1310 { // dr1310: 5
   struct S {} * sp = new S::S;
   // expected-error@-1 {{qualified reference to 'S' is a constructor name 
rather than a type in this context}}
diff --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp
index 3f074c4d57354a..342240cdc7a43d 100644
--- a/clang/test/CXX/drs/dr16xx.cpp
+++ b/clang/test/CXX/drs/dr16xx.cpp
@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.
+#if __cplusplus >= 201103L
+namespace ex1 {
+template  struct C {
+  template  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+};
+template struct C;
+} // namespace ex1
+
+namespace ex2 {
+struct C {
+  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+  // expected-error@-1 {{in-class initializer for static data member is not a 
constant expression}}
+};
+C c;
+} // namespace ex2
+#endif
+} // namespace dr1626
+
 namespace dr1631 {  // dr1631: 3.7
 #if __cplusplus >= 201103L
   // Incorrect overload resolution for single-element initializer-list
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..0a0213c28595fd 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx14,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcx

[Lldb-commits] [libc] [clang-tools-extra] [flang] [libcxx] [lld] [compiler-rt] [libunwind] [llvm] [libclc] [lldb] [clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-10 Thread Vlad Serebrennikov via lldb-commits

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

>From 1cbf8eec15112cd6871fcfb69425c62f08c8f681 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Jan 2024 14:17:21 +0300
Subject: [PATCH 1/3] [clang] Add tests for DRs about complete-class context
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the 
older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the 
unrestricted forward lookup in complete-class contexts (despite current 
implementation behavior for non-templates).
Wording: The declaration set is the result of a single search in the scope of C 
for N from immediately after the class-specifier of C if P is in a 
complete-class context of C or from P otherwise. [Drafting note: The plan for 
CWG2335 is to describe forbidden dependency cycles among the complete-class 
contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] 
[p7](http://eel.is/c++draft/class#mem.general-7) and 
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests 
only for CWG issues that fall under current definition of complete-class 
context, because I'm not sure how CWG1255 and CWG287 are going to work. That's 
why I skip over them, but mark CWG1308 as superseded by CWG1330.
---
 clang/test/CXX/drs/dr13xx.cpp |  2 ++
 clang/test/CXX/drs/dr16xx.cpp | 22 
 clang/test/CXX/drs/dr18xx.cpp | 38 +++
 clang/test/CXX/drs/dr2335.cpp | 48 +++
 clang/www/cxx_dr_status.html  |  8 +++---
 5 files changed, 109 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CXX/drs/dr2335.cpp

diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 359c04b3e0f3d4..81a8a8a361700a 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -40,6 +40,8 @@ void caller() {
 #endif // __cplusplus >= 201103L
 } // namespace dr1307
 
+// dr1308: sup 1330
+
 namespace dr1310 { // dr1310: 5
   struct S {} * sp = new S::S;
   // expected-error@-1 {{qualified reference to 'S' is a constructor name 
rather than a type in this context}}
diff --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp
index 3f074c4d57354a..342240cdc7a43d 100644
--- a/clang/test/CXX/drs/dr16xx.cpp
+++ b/clang/test/CXX/drs/dr16xx.cpp
@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.
+#if __cplusplus >= 201103L
+namespace ex1 {
+template  struct C {
+  template  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+};
+template struct C;
+} // namespace ex1
+
+namespace ex2 {
+struct C {
+  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+  // expected-error@-1 {{in-class initializer for static data member is not a 
constant expression}}
+};
+C c;
+} // namespace ex2
+#endif
+} // namespace dr1626
+
 namespace dr1631 {  // dr1631: 3.7
 #if __cplusplus >= 201103L
   // Incorrect overload resolution for single-element initializer-list
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..0a0213c28595fd 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx14,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcx

[Lldb-commits] [flang] [lldb] [lld] [clang] [llvm] [clang-tools-extra] [libclc] [libunwind] [libcxx] [libc] [compiler-rt] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-11 Thread Vlad Serebrennikov via lldb-commits

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

>From 1cbf8eec15112cd6871fcfb69425c62f08c8f681 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Jan 2024 14:17:21 +0300
Subject: [PATCH 1/4] [clang] Add tests for DRs about complete-class context
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the 
older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the 
unrestricted forward lookup in complete-class contexts (despite current 
implementation behavior for non-templates).
Wording: The declaration set is the result of a single search in the scope of C 
for N from immediately after the class-specifier of C if P is in a 
complete-class context of C or from P otherwise. [Drafting note: The plan for 
CWG2335 is to describe forbidden dependency cycles among the complete-class 
contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] 
[p7](http://eel.is/c++draft/class#mem.general-7) and 
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests 
only for CWG issues that fall under current definition of complete-class 
context, because I'm not sure how CWG1255 and CWG287 are going to work. That's 
why I skip over them, but mark CWG1308 as superseded by CWG1330.
---
 clang/test/CXX/drs/dr13xx.cpp |  2 ++
 clang/test/CXX/drs/dr16xx.cpp | 22 
 clang/test/CXX/drs/dr18xx.cpp | 38 +++
 clang/test/CXX/drs/dr2335.cpp | 48 +++
 clang/www/cxx_dr_status.html  |  8 +++---
 5 files changed, 109 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CXX/drs/dr2335.cpp

diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 359c04b3e0f3d4..81a8a8a361700a 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -40,6 +40,8 @@ void caller() {
 #endif // __cplusplus >= 201103L
 } // namespace dr1307
 
+// dr1308: sup 1330
+
 namespace dr1310 { // dr1310: 5
   struct S {} * sp = new S::S;
   // expected-error@-1 {{qualified reference to 'S' is a constructor name 
rather than a type in this context}}
diff --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp
index 3f074c4d57354a..342240cdc7a43d 100644
--- a/clang/test/CXX/drs/dr16xx.cpp
+++ b/clang/test/CXX/drs/dr16xx.cpp
@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.
+#if __cplusplus >= 201103L
+namespace ex1 {
+template  struct C {
+  template  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+};
+template struct C;
+} // namespace ex1
+
+namespace ex2 {
+struct C {
+  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+  // expected-error@-1 {{in-class initializer for static data member is not a 
constant expression}}
+};
+C c;
+} // namespace ex2
+#endif
+} // namespace dr1626
+
 namespace dr1631 {  // dr1631: 3.7
 #if __cplusplus >= 201103L
   // Incorrect overload resolution for single-element initializer-list
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..0a0213c28595fd 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx14,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcx

[Lldb-commits] [clang] [compiler-rt] [libc] [libunwind] [clang-tools-extra] [libclc] [lldb] [libcxx] [llvm] [flang] [lld] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-11 Thread Vlad Serebrennikov via lldb-commits

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

>From 1cbf8eec15112cd6871fcfb69425c62f08c8f681 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Jan 2024 14:17:21 +0300
Subject: [PATCH 1/4] [clang] Add tests for DRs about complete-class context
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the 
older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the 
unrestricted forward lookup in complete-class contexts (despite current 
implementation behavior for non-templates).
Wording: The declaration set is the result of a single search in the scope of C 
for N from immediately after the class-specifier of C if P is in a 
complete-class context of C or from P otherwise. [Drafting note: The plan for 
CWG2335 is to describe forbidden dependency cycles among the complete-class 
contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] 
[p7](http://eel.is/c++draft/class#mem.general-7) and 
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests 
only for CWG issues that fall under current definition of complete-class 
context, because I'm not sure how CWG1255 and CWG287 are going to work. That's 
why I skip over them, but mark CWG1308 as superseded by CWG1330.
---
 clang/test/CXX/drs/dr13xx.cpp |  2 ++
 clang/test/CXX/drs/dr16xx.cpp | 22 
 clang/test/CXX/drs/dr18xx.cpp | 38 +++
 clang/test/CXX/drs/dr2335.cpp | 48 +++
 clang/www/cxx_dr_status.html  |  8 +++---
 5 files changed, 109 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CXX/drs/dr2335.cpp

diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 359c04b3e0f3d4..81a8a8a361700a 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -40,6 +40,8 @@ void caller() {
 #endif // __cplusplus >= 201103L
 } // namespace dr1307
 
+// dr1308: sup 1330
+
 namespace dr1310 { // dr1310: 5
   struct S {} * sp = new S::S;
   // expected-error@-1 {{qualified reference to 'S' is a constructor name 
rather than a type in this context}}
diff --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp
index 3f074c4d57354a..342240cdc7a43d 100644
--- a/clang/test/CXX/drs/dr16xx.cpp
+++ b/clang/test/CXX/drs/dr16xx.cpp
@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.
+#if __cplusplus >= 201103L
+namespace ex1 {
+template  struct C {
+  template  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+};
+template struct C;
+} // namespace ex1
+
+namespace ex2 {
+struct C {
+  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+  // expected-error@-1 {{in-class initializer for static data member is not a 
constant expression}}
+};
+C c;
+} // namespace ex2
+#endif
+} // namespace dr1626
+
 namespace dr1631 {  // dr1631: 3.7
 #if __cplusplus >= 201103L
   // Incorrect overload resolution for single-element initializer-list
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..0a0213c28595fd 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx14,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcx

[Lldb-commits] [llvm] [libclc] [lldb] [libcxx] [flang] [libc] [libunwind] [lld] [clang] [clang-tools-extra] [compiler-rt] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-11 Thread Vlad Serebrennikov via lldb-commits


@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.

Endilll wrote:

We had an offline discussion, and concluded that this test should be removed.

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


[Lldb-commits] [lldb] fa2b038 - [lldb][NFC] Replace some counting loops with std::distance

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

Author: Vlad Serebrennikov
Date: 2023-07-30T19:22:02+03:00
New Revision: fa2b038cadf17d08014e5fb75c47b5024860953e

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

LOG: [lldb][NFC] Replace some counting loops with std::distance

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 5bc7a47241028d..a83e4625077350 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5361,11 +5361,8 @@ uint32_t 
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
   num_children += cxx_record_decl->getNumBases();
 }
   }
-  clang::RecordDecl::field_iterator field, field_end;
-  for (field = record_decl->field_begin(),
-  field_end = record_decl->field_end();
-   field != field_end; ++field)
-++num_children;
+  num_children += std::distance(record_decl->field_begin(),
+   record_decl->field_end());
 }
 break;
 
@@ -5576,13 +5573,8 @@ uint32_t 
TypeSystemClang::GetNumFields(lldb::opaque_compiler_type_t type) {
   if (record_type) {
 clang::RecordDecl *record_decl = record_type->getDecl();
 if (record_decl) {
-  uint32_t field_idx = 0;
-  clang::RecordDecl::field_iterator field, field_end;
-  for (field = record_decl->field_begin(),
-  field_end = record_decl->field_end();
-   field != field_end; ++field)
-++field_idx;
-  count = field_idx;
+  count = std::distance(record_decl->field_begin(),
+record_decl->field_end());
 }
   }
 }



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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

2023-09-20 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/66879

Migrated from https://reviews.llvm.org/D156774

>From 72f83fb2944829c60bd6f12a079bfba95da4f6e7 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 14 Sep 2023 09:46:53 +0300
Subject: [PATCH 1/2] Implementation (migrated from Phabricator)

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 15 +--
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 37fb16d4e0351c9..fc340da8eba0763 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2150,14 +2150,14 @@ bool DWARFASTParserClang::CompleteRecordType(const 
DWARFDIE &die,
 
 std::vector> bases;
 // Parse members and base classes first
-std::vector member_function_dies;
+std::vector member_function_and_type_dies;
 
 DelayedPropertyList delayed_properties;
-ParseChildMembers(die, clang_type, bases, member_function_dies,
+ParseChildMembers(die, clang_type, bases, member_function_and_type_dies,
   delayed_properties, default_accessibility, layout_info);
 
-// Now parse any methods if there were any...
-for (const DWARFDIE &die : member_function_dies)
+// Now parse any methods or nested types if there were any...
+for (const DWARFDIE &die : member_function_and_type_dies)
   dwarf->ResolveType(die);
 
 if (type_is_objc_object_or_interface) {
@@ -3153,7 +3153,7 @@ void DWARFASTParserClang::ParseSingleMember(
 bool DWARFASTParserClang::ParseChildMembers(
 const DWARFDIE &parent_die, CompilerType &class_clang_type,
 std::vector> &base_classes,
-std::vector &member_function_dies,
+std::vector &member_function_and_type_dies,
 DelayedPropertyList &delayed_properties,
 const AccessType default_accessibility,
 ClangASTImporter::LayoutInfo &layout_info) {
@@ -3189,8 +3189,11 @@ bool DWARFASTParserClang::ParseChildMembers(
   break;
 
 case DW_TAG_subprogram:
+case DW_TAG_enumeration_type:
+case DW_TAG_structure_type:
+case DW_TAG_union_type:
   // Let the type parsing code handle this one for us.
-  member_function_dies.push_back(die);
+  member_function_and_type_dies.push_back(die);
   break;
 
 case DW_TAG_inheritance:
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 88bfc490e890744..d4218959e61a8fa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -157,7 +157,7 @@ class DWARFASTParserClang : public DWARFASTParser {
   bool ParseChildMembers(
   const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type,
   std::vector> &base_classes,
-  std::vector &member_function_dies,
+  std::vector &member_function_and_type_dies,
   DelayedPropertyList &delayed_properties,
   const lldb::AccessType default_accessibility,
   lldb_private::ClangASTImporter::LayoutInfo &layout_info);

>From 4a4aa7ad35124414aafdb7db44c89e51f498aa83 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 20 Sep 2023 12:32:44 +0300
Subject: [PATCH 2/2] Add an incomplete unit test

---
 .../DWARF/DWARFASTParserClangTests.cpp| 93 +++
 1 file changed, 93 insertions(+)

diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index 20a085741f73d00..d47f9b636ec15eb 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -462,3 +462,96 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
 }
   }
 }
+
+TEST_F(DWARFASTParserClangTests, EnsureNestedTypesOfTypeAreParsed) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- Info
+- B
+- C
+- Mask
+- Enum
+  debug_abbrev:
+- Table:
+- Code:0x1
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Code:0x2
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x3
+  Tag: DW_TAG_union_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

2023-09-20 Thread Vlad Serebrennikov via lldb-commits


@@ -462,3 +462,96 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
 }
   }
 }
+
+TEST_F(DWARFASTParserClangTests, EnsureNestedTypesOfTypeAreParsed) {
+  const char *yamldata = R"(

Endilll wrote:

I find this YAML way of describing debug info quite unfriendly, especially 
compared to the output of `llvm-dwarfdump`. Anyway, I tried to encode debug 
info for the following snippet:
```cpp
struct Info {
  enum Mask : uintptr_t {
Enum =  ~(uintptr_t)(((intptr_t)1 << 3) - 1);
  };
  union B {};
  struct C {};
}
```
Filtered out llvm-dwarfdump output:
```
0x000c: DW_TAG_compile_unit
  DW_AT_language [DW_FORM_data2](DW_LANG_C_plus_plus_14)

0x002c:   DW_TAG_structure_type
DW_AT_calling_convention [DW_FORM_data1]
(DW_CC_pass_by_value)
DW_AT_name [DW_FORM_strx1]  ("Info")
DW_AT_byte_size [DW_FORM_data1] (0x04)

0x003a: DW_TAG_union_type
  DW_AT_calling_convention [DW_FORM_data1]  
(DW_CC_pass_by_value)
  DW_AT_name [DW_FORM_strx1]("B")
  DW_AT_byte_size [DW_FORM_data1]   (0x01)

0x0049: DW_TAG_structure_type
  DW_AT_calling_convention [DW_FORM_data1]  
(DW_CC_pass_by_value)
  DW_AT_name [DW_FORM_strx1]("C")
  DW_AT_byte_size [DW_FORM_data1]   (0x01)

0x003b: DW_TAG_enumeration_type
  DW_AT_type [DW_FORM_ref4] (0x005e "uintptr_t")
  DW_AT_name [DW_FORM_strx1]("Mask")
  DW_AT_byte_size [DW_FORM_data1]   (0x08)

0x0044:   DW_TAG_enumerator
DW_AT_name [DW_FORM_strx1]  ("Enum")
DW_AT_const_value [DW_FORM_udata]   (18446744073709551608)
```

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

2023-09-20 Thread Vlad Serebrennikov via lldb-commits


@@ -462,3 +462,96 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
 }
   }
 }
+
+TEST_F(DWARFASTParserClangTests, EnsureNestedTypesOfTypeAreParsed) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- Info
+- B
+- C
+- Mask
+- Enum
+  debug_abbrev:
+- Table:
+- Code:0x1
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Code:0x2
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x3
+  Tag: DW_TAG_union_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x4
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x5
+  Tag: DW_TAG_enumeration_type
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x6
+  Tag: DW_TAG_enumerator
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp  
+  debug_info:
+- Version: 5
+  AddrSize:8
+  UnitType:DW_UT_compile
+  Entries:
+- AbbrCode:0x1
+  Values:
+- Value:   0x21
+- AbbrCode:0x2
+  Values:
+- Value:   0x0
+- AbbrCode:0x3
+  Values:
+- Value:   0x5
+- AbbrCode:0x4
+  Values:
+- Value:   0x7
+- AbbrCode:0x5
+  Values:
+- Value:   0x9
+- AbbrCode:0x6
+  Values:
+- Value:   0xE
+)";
+
+  YAMLModuleTester t(yamldata);
+
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_NE(unit, nullptr);
+  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+  DWARFDIE cu_die(unit, cu_entry);
+
+  auto holder = std::make_unique("ast");
+  auto &ast_ctx = *holder->GetAST();
+  DWARFASTParserClangStub ast_parser(ast_ctx);
+
+  EXPECT_TRUE(false);

Endilll wrote:

@Michael137 Can you help me with the rest of this test? I'm changing function 
that complete (presumably) incomplete CompilerType's, but I'm not sure how to 
gather all required input to call it. Maybe that's not even the right way to 
write the test I need to write. 

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

2023-09-20 Thread Vlad Serebrennikov via lldb-commits


@@ -462,3 +462,96 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
 }
   }
 }
+
+TEST_F(DWARFASTParserClangTests, EnsureNestedTypesOfTypeAreParsed) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- Info
+- B
+- C
+- Mask
+- Enum
+  debug_abbrev:
+- Table:
+- Code:0x1
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Code:0x2
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x3
+  Tag: DW_TAG_union_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x4
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x5
+  Tag: DW_TAG_enumeration_type
+  Children:DW_CHILDREN_yes

Endilll wrote:

Apparently I have to encode tree-like structure (see C++ code above) in a flat 
list, which doesn't seem natural. I wonder if YAML I've written is even 
sensible.

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

2023-09-20 Thread Vlad Serebrennikov via lldb-commits


@@ -462,3 +462,96 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
 }
   }
 }
+
+TEST_F(DWARFASTParserClangTests, EnsureNestedTypesOfTypeAreParsed) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- Info
+- B
+- C
+- Mask
+- Enum
+  debug_abbrev:
+- Table:
+- Code:0x1
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Code:0x2
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x3
+  Tag: DW_TAG_union_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x4
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x5
+  Tag: DW_TAG_enumeration_type
+  Children:DW_CHILDREN_yes

Endilll wrote:

Thank you! I'll give it a try.

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

2023-09-26 Thread Vlad Serebrennikov via lldb-commits

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

>From 72f83fb2944829c60bd6f12a079bfba95da4f6e7 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 14 Sep 2023 09:46:53 +0300
Subject: [PATCH 1/3] Implementation (migrated from Phabricator)

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 15 +--
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 37fb16d4e0351c9..fc340da8eba0763 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2150,14 +2150,14 @@ bool DWARFASTParserClang::CompleteRecordType(const 
DWARFDIE &die,
 
 std::vector> bases;
 // Parse members and base classes first
-std::vector member_function_dies;
+std::vector member_function_and_type_dies;
 
 DelayedPropertyList delayed_properties;
-ParseChildMembers(die, clang_type, bases, member_function_dies,
+ParseChildMembers(die, clang_type, bases, member_function_and_type_dies,
   delayed_properties, default_accessibility, layout_info);
 
-// Now parse any methods if there were any...
-for (const DWARFDIE &die : member_function_dies)
+// Now parse any methods or nested types if there were any...
+for (const DWARFDIE &die : member_function_and_type_dies)
   dwarf->ResolveType(die);
 
 if (type_is_objc_object_or_interface) {
@@ -3153,7 +3153,7 @@ void DWARFASTParserClang::ParseSingleMember(
 bool DWARFASTParserClang::ParseChildMembers(
 const DWARFDIE &parent_die, CompilerType &class_clang_type,
 std::vector> &base_classes,
-std::vector &member_function_dies,
+std::vector &member_function_and_type_dies,
 DelayedPropertyList &delayed_properties,
 const AccessType default_accessibility,
 ClangASTImporter::LayoutInfo &layout_info) {
@@ -3189,8 +3189,11 @@ bool DWARFASTParserClang::ParseChildMembers(
   break;
 
 case DW_TAG_subprogram:
+case DW_TAG_enumeration_type:
+case DW_TAG_structure_type:
+case DW_TAG_union_type:
   // Let the type parsing code handle this one for us.
-  member_function_dies.push_back(die);
+  member_function_and_type_dies.push_back(die);
   break;
 
 case DW_TAG_inheritance:
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 88bfc490e890744..d4218959e61a8fa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -157,7 +157,7 @@ class DWARFASTParserClang : public DWARFASTParser {
   bool ParseChildMembers(
   const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type,
   std::vector> &base_classes,
-  std::vector &member_function_dies,
+  std::vector &member_function_and_type_dies,
   DelayedPropertyList &delayed_properties,
   const lldb::AccessType default_accessibility,
   lldb_private::ClangASTImporter::LayoutInfo &layout_info);

>From 4a4aa7ad35124414aafdb7db44c89e51f498aa83 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 20 Sep 2023 12:32:44 +0300
Subject: [PATCH 2/3] Add an incomplete unit test

---
 .../DWARF/DWARFASTParserClangTests.cpp| 93 +++
 1 file changed, 93 insertions(+)

diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index 20a085741f73d00..d47f9b636ec15eb 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -462,3 +462,96 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
 }
   }
 }
+
+TEST_F(DWARFASTParserClangTests, EnsureNestedTypesOfTypeAreParsed) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- Info
+- B
+- C
+- Mask
+- Enum
+  debug_abbrev:
+- Table:
+- Code:0x1
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Code:0x2
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x3
+  Tag: DW_TAG_union_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:  

[Lldb-commits] [lldb] [lldb] Make SBType::FindDirectNestedType work with expression ASTs (PR #89183)

2024-04-18 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

> One thing I'd like to get feedback on is whether this should be looking into 
> base classes. The discussion on the original PR focuses on lexically nested 
> types, but going through base classes (following usual language rules) is 
> another form of nesting. Both the existing and the new implementations don't 
> do that, but I think it would be more natural to do it. Of course, then the 
> function can definitely return more than one result...

What you're describing here is in line with member lookup described in the 
Standard. While it might be a useful facility, it's at odds with the intent of 
`FindDirectNestedTypes()` to be a small building block for efficient AST 
traversal. For the use case I have for this function, any amount of lookup is 
going to regress the performance of the formatter, and subsequently 
responsiveness of the debugger. So if you're going to pursue this, I suggest 
exposing this as a new function.

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


[Lldb-commits] [lldb] [lldb] Make SBType::FindDirectNestedType work with expression ASTs (PR #89183)

2024-04-19 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

@Michael137 suggested that I check that performance of `FindDirectNestedType` 
doesn't regress (at least for my use case), since I have custom instrumentation 
in my formatter. I can confirm that 3 versions of this function (#68705, 
#74786, and this PR) exhibit the same level of performance. Raw numbers 
fluctuate a lot, but I don't see anything concerning:
```
This PR
---
2,611,025
1,988,893
2,878,981
1,873,220

main branch (#74786)

1,973,071
2,542,073
1,509,624

Initial implementation (#68705)
--
2,029,233
2,477,041
1,315,462
```

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


[Lldb-commits] [lldb] [lldb] Add ability to show enum as name and value at the same time (PR #90059)

2024-04-25 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

I'm excited so see changes in this area!

> It is a subset of https://github.com/llvm/llvm-project/pull/69815, only for 
> use by register printing (ping @Endilll).

Yeah, that effort is stalled because I don't see a clear path forward there, 
and I'm lacking energy to find and push for one. I guess I can try to piggyback 
on this PR if it goes in the direction I need (I hope you don't mind :).

Seriously, though, I'm not sure how your design with a flag orthogonal to 
format fares in the feedback I was given back then. It's also not clear how 
this new "presentation mode" is going to be controlled. While it's not in the 
scope of this PR, it would be nice if you can share a bigger picture.

Another thing this PR doesn't seem to touch is flag-like enums. Even if you 
don't want to add a numerical value there, because it'd be too much information 
to present, it still would be nice to see it explicitly considered.

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


[Lldb-commits] [lldb] [lldb] Add ability to show enum as name and value at the same time (PR #90059)

2024-04-25 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

> For me the picture is limited to register printing. I'll be setting this new 
> option on the register type when printing 
> (https://github.com/DavidSpickett/llvm-project/commit/24dbefaa14030646ba0871298989558221af1ba0#diff-18135f619417bbaa1ab0c181ce55b2c55681323c06e90fa1a3e16099c7176e21).
>  So only from C++ for now.

So it's hard-coded, I see.

> What is a flag like enum?

`enum { a = 1, b = 2, c = 4, d = 8}` — this sort of enumeration. Sorry if my 
terminology was confusing. They are handled further in `DumpEnumValue()`, after 
the changes you've made here, and called bit-fields in the comments.

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


[Lldb-commits] [lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-13 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [clang-tools-extra] [clang] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-13 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll commented:

C++ DR test changes look good to me.

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


[Lldb-commits] [lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-13 Thread Vlad Serebrennikov via lldb-commits


@@ -25,7 +25,7 @@ template  struct S {}; // #dr1801-S
 S V; // #dr1801-S-i
 // cxx98-14-error@-1 {{non-type template argument does not refer to any 
declaration}}
 //   cxx98-14-note@#dr1801-S {{template parameter is declared here}}
-// since-cxx17-error@#dr1801-S-i {{non-type template argument refers to 
subobject '.i'}}
+// cxx17-error@#dr1801-S-i {{non-type template argument refers to subobject 
'.i'}}

Endilll wrote:

Quoting P1907R1 wording changes:
> For a non-type template-parameter of reference or pointer type <...> the 
> reference or pointer value shall not refer to or be the address of 
> (respectively):
> ~a subobject (6.7.2),~
> <...>
> a subobject (6.7.2) of one of the above.

My reading is that you indeed can reference subobjects in NTTP since 20, unless 
they fall into one of the narrow categories listed in that paragraph. The 
change you made is correct, unless P1907R1 was adopted as a DR.

Sorry I forgot to check current wording when I added the test.

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


[Lldb-commits] [compiler-rt] [lld] [clang] [libc] [libclc] [lldb] [llvm] [clang-tools-extra] [flang] [libcxx] [libunwind] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-13 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

CI fails on formatting in unrelated files, so I'm going to ignore it:
```
t=1704988008448 + echo '*** Checking for trailing whitespace left in Clang 
source files ***'
t=1704988008448 *** Checking for trailing whitespace left in Clang source files 
***
t=1704988008448 + grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs
t=1704988008595 clang/docs/HLSL/FunctionCalls.rst:147:Clang Implementation 
t=1704988008602 + echo '*** Trailing whitespace has been found in Clang source 
files as described above ***'
t=1704988008602 *** Trailing whitespace has been found in Clang source files as 
described above ***
t=1704988008602 + exit 1
t=1704988008603 ^^^ +++
t=1704988008603 Error: The command exited with status 1
t=1704988008603 ^^^ +++
t=1704988008603 user command error: exit status 1
```
https://buildkite.com/llvm-project/github-pull-requests/builds/28418

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


[Lldb-commits] [compiler-rt] [lld] [clang] [libc] [libclc] [lldb] [llvm] [clang-tools-extra] [flang] [libcxx] [libunwind] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-13 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-15 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

> The logic is that this is a pretty big hole in our C++20 support and I don't 
> think it's reasonable to try a merge after the deadline for 18. WDYT?

>From our past experience with release managers, they seem quite generous with 
>deadlines to merge stuff in, as long as maintainers agree. I think the real 
>question is how much time do we want this to bake in tree before users get to 
>see it.

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-13 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/81666

This patch attempts to fix lookup in class template specialization that have an 
integral non-type template parameter of non-int type. unsigned 3 might be 
printed as `3` or `3U` depending on PrintingPolicy. This patch bring it in line 
with what Clang does (which addes the suffix).

>From bf92dc89858668518a5d842eac34bdf1b3eaade2 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 14 Feb 2024 00:26:09 +0300
Subject: [PATCH] [lldb] Fix `FindDirectNestedType` not working with class
 templates

This patch attempts to fix lookup in class template specialization that have an 
integral non-type template parameter of non-int type. unsigned 3 might be 
printed as `3` or `3U` depending on PrintingPolicy. This patch bring it in line 
with what Clang does (which addes the suffix).
---
 .../TypeSystem/Clang/TypeSystemClang.cpp|  9 +++--
 lldb/test/API/python_api/type/TestTypeList.py   | 17 +
 lldb/test/API/python_api/type/main.cpp  | 13 +
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index a41e2c690853d2..e6a9d3f4f02836 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2165,6 +2165,7 @@ PrintingPolicy TypeSystemClang::GetTypePrintingPolicy() {
   // (and we then would have suppressed them from the type name) and also 
setups
   // where LLDB wasn't able to reconstruct the default arguments.
   printing_policy.SuppressDefaultTemplateArgs = false;
+  printing_policy.AlwaysIncludeTypeForTemplateArgument = true;
   return printing_policy;
 }
 
@@ -9265,8 +9266,12 @@ ConstString TypeSystemClang::DeclContextGetName(void 
*opaque_decl_ctx) {
   if (opaque_decl_ctx) {
 clang::NamedDecl *named_decl =
 llvm::dyn_cast((clang::DeclContext 
*)opaque_decl_ctx);
-if (named_decl)
-  return ConstString(named_decl->getName());
+if (named_decl) {
+  std::string name;
+  llvm::raw_string_ostream stream{name};
+  named_decl->getNameForDiagnostic(stream, GetTypePrintingPolicy(), 
/*qualified=*/ false);
+  return ConstString(name);
+}
   }
   return ConstString();
 }
diff --git a/lldb/test/API/python_api/type/TestTypeList.py 
b/lldb/test/API/python_api/type/TestTypeList.py
index c267defb58edf9..f874e87771c624 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -150,6 +150,23 @@ def test(self):
 invalid_type = task_type.FindDirectNestedType(None)
 self.assertFalse(invalid_type)
 
+# Check that FindDirectNestedType works with types from AST
+pointer = frame0.FindVariable("pointer")
+pointer_type = pointer.GetType()
+self.assertTrue(pointer_type)
+self.DebugSBType(pointer_type)
+pointer_info_type = pointer_type.template_args[0]
+self.assertTrue(pointer_info_type)
+self.DebugSBType(pointer_info_type)
+
+pointer_masks1_type = pointer_info_type.FindDirectNestedType("Masks1")
+self.assertTrue(pointer_masks1_type)
+self.DebugSBType(pointer_masks1_type)
+
+pointer_masks2_type = pointer_info_type.FindDirectNestedType("Masks2")
+self.assertTrue(pointer_masks2_type)
+self.DebugSBType(pointer_masks2_type)
+
 # We'll now get the child member 'id' from 'task_head'.
 id = task_head.GetChildMemberWithName("id")
 self.DebugSBValue(id)
diff --git a/lldb/test/API/python_api/type/main.cpp 
b/lldb/test/API/python_api/type/main.cpp
index 98de9707d88654..b587acdd96c590 100644
--- a/lldb/test/API/python_api/type/main.cpp
+++ b/lldb/test/API/python_api/type/main.cpp
@@ -34,6 +34,15 @@ class Task {
 {}
 };
 
+template 
+struct PointerInfo {
+  enum Masks1 { pointer_mask };
+  enum class Masks2 { pointer_mask };
+};
+
+template >
+struct Pointer {};
+
 enum EnumType {};
 enum class ScopedEnumType {};
 enum class EnumUChar : unsigned char {};
@@ -71,5 +80,9 @@ int main (int argc, char const *argv[])
 ScopedEnumType scoped_enum_type;
 EnumUChar scoped_enum_type_uchar;
 
+Pointer<3> pointer;
+PointerInfo<3>::Masks1 mask1 = PointerInfo<3>::Masks1::pointer_mask;
+PointerInfo<3>::Masks2 mask2 = PointerInfo<3>::Masks2::pointer_mask;
+
 return 0; // Break at this line
 }

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-13 Thread Vlad Serebrennikov via lldb-commits

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

>From bf92dc89858668518a5d842eac34bdf1b3eaade2 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 14 Feb 2024 00:26:09 +0300
Subject: [PATCH 1/2] [lldb] Fix `FindDirectNestedType` not working with class
 templates

This patch attempts to fix lookup in class template specialization that have an 
integral non-type template parameter of non-int type. unsigned 3 might be 
printed as `3` or `3U` depending on PrintingPolicy. This patch bring it in line 
with what Clang does (which addes the suffix).
---
 .../TypeSystem/Clang/TypeSystemClang.cpp|  9 +++--
 lldb/test/API/python_api/type/TestTypeList.py   | 17 +
 lldb/test/API/python_api/type/main.cpp  | 13 +
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index a41e2c690853d2..e6a9d3f4f02836 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2165,6 +2165,7 @@ PrintingPolicy TypeSystemClang::GetTypePrintingPolicy() {
   // (and we then would have suppressed them from the type name) and also 
setups
   // where LLDB wasn't able to reconstruct the default arguments.
   printing_policy.SuppressDefaultTemplateArgs = false;
+  printing_policy.AlwaysIncludeTypeForTemplateArgument = true;
   return printing_policy;
 }
 
@@ -9265,8 +9266,12 @@ ConstString TypeSystemClang::DeclContextGetName(void 
*opaque_decl_ctx) {
   if (opaque_decl_ctx) {
 clang::NamedDecl *named_decl =
 llvm::dyn_cast((clang::DeclContext 
*)opaque_decl_ctx);
-if (named_decl)
-  return ConstString(named_decl->getName());
+if (named_decl) {
+  std::string name;
+  llvm::raw_string_ostream stream{name};
+  named_decl->getNameForDiagnostic(stream, GetTypePrintingPolicy(), 
/*qualified=*/ false);
+  return ConstString(name);
+}
   }
   return ConstString();
 }
diff --git a/lldb/test/API/python_api/type/TestTypeList.py 
b/lldb/test/API/python_api/type/TestTypeList.py
index c267defb58edf9..f874e87771c624 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -150,6 +150,23 @@ def test(self):
 invalid_type = task_type.FindDirectNestedType(None)
 self.assertFalse(invalid_type)
 
+# Check that FindDirectNestedType works with types from AST
+pointer = frame0.FindVariable("pointer")
+pointer_type = pointer.GetType()
+self.assertTrue(pointer_type)
+self.DebugSBType(pointer_type)
+pointer_info_type = pointer_type.template_args[0]
+self.assertTrue(pointer_info_type)
+self.DebugSBType(pointer_info_type)
+
+pointer_masks1_type = pointer_info_type.FindDirectNestedType("Masks1")
+self.assertTrue(pointer_masks1_type)
+self.DebugSBType(pointer_masks1_type)
+
+pointer_masks2_type = pointer_info_type.FindDirectNestedType("Masks2")
+self.assertTrue(pointer_masks2_type)
+self.DebugSBType(pointer_masks2_type)
+
 # We'll now get the child member 'id' from 'task_head'.
 id = task_head.GetChildMemberWithName("id")
 self.DebugSBValue(id)
diff --git a/lldb/test/API/python_api/type/main.cpp 
b/lldb/test/API/python_api/type/main.cpp
index 98de9707d88654..b587acdd96c590 100644
--- a/lldb/test/API/python_api/type/main.cpp
+++ b/lldb/test/API/python_api/type/main.cpp
@@ -34,6 +34,15 @@ class Task {
 {}
 };
 
+template 
+struct PointerInfo {
+  enum Masks1 { pointer_mask };
+  enum class Masks2 { pointer_mask };
+};
+
+template >
+struct Pointer {};
+
 enum EnumType {};
 enum class ScopedEnumType {};
 enum class EnumUChar : unsigned char {};
@@ -71,5 +80,9 @@ int main (int argc, char const *argv[])
 ScopedEnumType scoped_enum_type;
 EnumUChar scoped_enum_type_uchar;
 
+Pointer<3> pointer;
+PointerInfo<3>::Masks1 mask1 = PointerInfo<3>::Masks1::pointer_mask;
+PointerInfo<3>::Masks2 mask2 = PointerInfo<3>::Masks2::pointer_mask;
+
 return 0; // Break at this line
 }

>From 153c8ec6abda4315c5bce6d088513a6ff63f26f9 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 14 Feb 2024 00:33:17 +0300
Subject: [PATCH 2/2] Run clang-format

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 ++-
 lldb/test/API/python_api/type/main.cpp   | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index e6a9d3f4f02836..0652ac0e134f53 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9269,7 +9269,8 @@ ConstString TypeSystemClang::DeclContextGetName(void 
*opaque_decl_ct

[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-13 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

This PR is a draft because new test, which is simplified `llvm::PointerIntPair` 
and `llvm::PointerIntPairInfo`, doesn't pass even with the proposed fix.

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-14 Thread Vlad Serebrennikov via lldb-commits

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

>From bf92dc89858668518a5d842eac34bdf1b3eaade2 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 14 Feb 2024 00:26:09 +0300
Subject: [PATCH 1/3] [lldb] Fix `FindDirectNestedType` not working with class
 templates

This patch attempts to fix lookup in class template specialization that have an 
integral non-type template parameter of non-int type. unsigned 3 might be 
printed as `3` or `3U` depending on PrintingPolicy. This patch bring it in line 
with what Clang does (which addes the suffix).
---
 .../TypeSystem/Clang/TypeSystemClang.cpp|  9 +++--
 lldb/test/API/python_api/type/TestTypeList.py   | 17 +
 lldb/test/API/python_api/type/main.cpp  | 13 +
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index a41e2c690853d2..e6a9d3f4f02836 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2165,6 +2165,7 @@ PrintingPolicy TypeSystemClang::GetTypePrintingPolicy() {
   // (and we then would have suppressed them from the type name) and also 
setups
   // where LLDB wasn't able to reconstruct the default arguments.
   printing_policy.SuppressDefaultTemplateArgs = false;
+  printing_policy.AlwaysIncludeTypeForTemplateArgument = true;
   return printing_policy;
 }
 
@@ -9265,8 +9266,12 @@ ConstString TypeSystemClang::DeclContextGetName(void 
*opaque_decl_ctx) {
   if (opaque_decl_ctx) {
 clang::NamedDecl *named_decl =
 llvm::dyn_cast((clang::DeclContext 
*)opaque_decl_ctx);
-if (named_decl)
-  return ConstString(named_decl->getName());
+if (named_decl) {
+  std::string name;
+  llvm::raw_string_ostream stream{name};
+  named_decl->getNameForDiagnostic(stream, GetTypePrintingPolicy(), 
/*qualified=*/ false);
+  return ConstString(name);
+}
   }
   return ConstString();
 }
diff --git a/lldb/test/API/python_api/type/TestTypeList.py 
b/lldb/test/API/python_api/type/TestTypeList.py
index c267defb58edf9..f874e87771c624 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -150,6 +150,23 @@ def test(self):
 invalid_type = task_type.FindDirectNestedType(None)
 self.assertFalse(invalid_type)
 
+# Check that FindDirectNestedType works with types from AST
+pointer = frame0.FindVariable("pointer")
+pointer_type = pointer.GetType()
+self.assertTrue(pointer_type)
+self.DebugSBType(pointer_type)
+pointer_info_type = pointer_type.template_args[0]
+self.assertTrue(pointer_info_type)
+self.DebugSBType(pointer_info_type)
+
+pointer_masks1_type = pointer_info_type.FindDirectNestedType("Masks1")
+self.assertTrue(pointer_masks1_type)
+self.DebugSBType(pointer_masks1_type)
+
+pointer_masks2_type = pointer_info_type.FindDirectNestedType("Masks2")
+self.assertTrue(pointer_masks2_type)
+self.DebugSBType(pointer_masks2_type)
+
 # We'll now get the child member 'id' from 'task_head'.
 id = task_head.GetChildMemberWithName("id")
 self.DebugSBValue(id)
diff --git a/lldb/test/API/python_api/type/main.cpp 
b/lldb/test/API/python_api/type/main.cpp
index 98de9707d88654..b587acdd96c590 100644
--- a/lldb/test/API/python_api/type/main.cpp
+++ b/lldb/test/API/python_api/type/main.cpp
@@ -34,6 +34,15 @@ class Task {
 {}
 };
 
+template 
+struct PointerInfo {
+  enum Masks1 { pointer_mask };
+  enum class Masks2 { pointer_mask };
+};
+
+template >
+struct Pointer {};
+
 enum EnumType {};
 enum class ScopedEnumType {};
 enum class EnumUChar : unsigned char {};
@@ -71,5 +80,9 @@ int main (int argc, char const *argv[])
 ScopedEnumType scoped_enum_type;
 EnumUChar scoped_enum_type_uchar;
 
+Pointer<3> pointer;
+PointerInfo<3>::Masks1 mask1 = PointerInfo<3>::Masks1::pointer_mask;
+PointerInfo<3>::Masks2 mask2 = PointerInfo<3>::Masks2::pointer_mask;
+
 return 0; // Break at this line
 }

>From 153c8ec6abda4315c5bce6d088513a6ff63f26f9 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 14 Feb 2024 00:33:17 +0300
Subject: [PATCH 2/3] Run clang-format

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 ++-
 lldb/test/API/python_api/type/main.cpp   | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index e6a9d3f4f02836..0652ac0e134f53 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9269,7 +9269,8 @@ ConstString TypeSystemClang::DeclContextGetName(void 
*opaque_decl_ct

[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-14 Thread Vlad Serebrennikov via lldb-commits


@@ -150,6 +150,23 @@ def test(self):
 invalid_type = task_type.FindDirectNestedType(None)
 self.assertFalse(invalid_type)
 
+# Check that FindDirectNestedType works with types from AST
+pointer = frame0.FindVariable("pointer")
+pointer_type = pointer.GetType()
+self.assertTrue(pointer_type)
+self.DebugSBType(pointer_type)
+pointer_info_type = pointer_type.template_args[0]

Endilll wrote:

You're absolutely right. Thank you!

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-14 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-14 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-14 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-14 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-16 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-16 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

Trying to take a look, but https://green.lab.llvm.org is extraordinary slow for 
me.

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-16 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

@JDevlieghere I have an idea what have caused this failure, but I guess I have 
to enable libcxx to replicate it locally.

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


[Lldb-commits] [lldb] [lldb] Fix `FindDirectNestedType` not working with class templates (PR #81666)

2024-02-16 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

I'd appreciate if you gave me a slightly bit more time, because I've been 
testing the fix locally in the meantime.

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


[Lldb-commits] [lldb] 4214f25 - Re-land "[lldb] Fix `FindDirectNestedType` not working with class templates (#81666)"

2024-02-16 Thread Vlad Serebrennikov via lldb-commits

Author: Vlad Serebrennikov
Date: 2024-02-16T22:47:09+03:00
New Revision: 4214f25dccba36472c9666f1395eef894dca1bba

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

LOG: Re-land "[lldb] Fix `FindDirectNestedType` not working with class 
templates (#81666)"

This patch attempts to fix lookup in class template specialization.

The first fixed problem is that during type lookup `DeclContextGetName`
have been dropping template arguments. So when such a name was compared
against a name in `DW_AT_name`, which contains template arguments, false
mismatches have been occurring.

The second fixed problem is that LLDB's printing policy hasn't been
matching Clang's printing policy when it comes to integral non-type
template arguments. This again caused some false mismatches during type
lookup, because Clang puts e.g. `3U` in debug info for class
specializations, but LLDB has been expecting just `3`. This patch brings
printing policy in line with what Clang does.

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/python_api/type/TestTypeList.py
lldb/test/API/python_api/type/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index a41e2c690853d2..51ab13108feb3a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9265,8 +9265,14 @@ ConstString TypeSystemClang::DeclContextGetName(void 
*opaque_decl_ctx) {
   if (opaque_decl_ctx) {
 clang::NamedDecl *named_decl =
 llvm::dyn_cast((clang::DeclContext 
*)opaque_decl_ctx);
-if (named_decl)
-  return ConstString(named_decl->getName());
+if (named_decl) {
+  std::string name;
+  llvm::raw_string_ostream stream{name};
+  auto policy = GetTypePrintingPolicy();
+  policy.AlwaysIncludeTypeForTemplateArgument = true;
+  named_decl->getNameForDiagnostic(stream, policy, /*qualified=*/false);
+  return ConstString(name);
+}
   }
   return ConstString();
 }

diff  --git a/lldb/test/API/python_api/type/TestTypeList.py 
b/lldb/test/API/python_api/type/TestTypeList.py
index c267defb58edf9..63ab958193574b 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -150,6 +150,23 @@ def test(self):
 invalid_type = task_type.FindDirectNestedType(None)
 self.assertFalse(invalid_type)
 
+# Check that FindDirectNestedType works with types from AST
+pointer = frame0.FindVariable("pointer")
+pointer_type = pointer.GetType()
+self.assertTrue(pointer_type)
+self.DebugSBType(pointer_type)
+pointer_info_type = pointer_type.template_args[1]
+self.assertTrue(pointer_info_type)
+self.DebugSBType(pointer_info_type)
+
+pointer_masks1_type = pointer_info_type.FindDirectNestedType("Masks1")
+self.assertTrue(pointer_masks1_type)
+self.DebugSBType(pointer_masks1_type)
+
+pointer_masks2_type = pointer_info_type.FindDirectNestedType("Masks2")
+self.assertTrue(pointer_masks2_type)
+self.DebugSBType(pointer_masks2_type)
+
 # We'll now get the child member 'id' from 'task_head'.
 id = task_head.GetChildMemberWithName("id")
 self.DebugSBValue(id)

diff  --git a/lldb/test/API/python_api/type/main.cpp 
b/lldb/test/API/python_api/type/main.cpp
index 98de9707d88654..391f58e3e5871c 100644
--- a/lldb/test/API/python_api/type/main.cpp
+++ b/lldb/test/API/python_api/type/main.cpp
@@ -34,6 +34,14 @@ class Task {
 {}
 };
 
+template  struct PointerInfo {
+  enum Masks1 { pointer_mask };
+  enum class Masks2 { pointer_mask };
+};
+
+template >
+struct Pointer {};
+
 enum EnumType {};
 enum class ScopedEnumType {};
 enum class EnumUChar : unsigned char {};
@@ -71,5 +79,9 @@ int main (int argc, char const *argv[])
 ScopedEnumType scoped_enum_type;
 EnumUChar scoped_enum_type_uchar;
 
+Pointer<3> pointer;
+PointerInfo<3>::Masks1 mask1 = PointerInfo<3>::Masks1::pointer_mask;
+PointerInfo<3>::Masks2 mask2 = PointerInfo<3>::Masks2::pointer_mask;
+
 return 0; // Break at this line
 }



___
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::FindNestedType() function (PR #68705)

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

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

This patch adds a `SBType::FindNestedType(name)` function which performs a 
non-recursive search in given class for a type with specified name. The intent 
is to perform a fast search in debug info, so that it can be used in 
formatters, and let them remain responsive.

This is driven by my work on formatters for Clang and LLVM types. In 
particular, by 
[`PointerIntPairInfo::MaskAndShiftConstants`](https://github.com/llvm/llvm-project/blob/cde9f9df79805a0850310870d6dcc64004292727/llvm/include/llvm/ADT/PointerIntPair.h#L174C16-L174C16),
 which is required to extract pointer and integer from `PointerIntPair`.

Related Discourse thread: 
https://discourse.llvm.org/t/traversing-member-types-of-a-type/72452

>From ca4d1bbdeb4ea541199e3db3518b35eb2d5a8cad Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 10 Oct 2023 15:07:56 +0300
Subject: [PATCH] [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

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

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

Endilll wrote:

Intended usage is going to look like the following for `PointerIntPair`:
```python
class PointerIntPairProvider:
def update(self):
pointer_info = self.valobj.type.template_args[4] # PointerIntPairInfo
masks = pointer_info.FindNestedType("MaskAndShiftConstants")
if masks.IsValid():
for enumerator in enum.enum_members:
if enumerator.name == "PointerBitMask":
pointer_mask = enumerator.unsigned
# extract pointer using the mask
```
Fully qualified name of `PointerIntPairInfo` used in `clang::QualType` is the 
following: `llvm::PointerIntPairInfo, 3, 
llvm::PointerLikeTypeTraits > >::MaskAndShiftConstants`. I'm not sure if existing 
`SBTarget::FindFirstType()` can handle this case as well as proposed function.

I'll submit a proper API test shortly.

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::FindNestedType() function (PR #68705)

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

Endilll wrote:

It should be noted that after calling `FindNestedType` and successfully finding 
`MaskAndShiftConstants` in the example above, the following routine in my fork 
reports that `PointerIntPairInfo` has 2 enums instead of 1:
```cpp
uint32_t TypeSystemClang::GetNumMemberEnums(lldb::opaque_compiler_type_t type) {
  using EnumIt = clang::DeclContext::specific_decl_iterator;
  if (!type)
return 0;

  clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
  if (GetCompleteQualType(&getASTContext(), qual_type)) {
const clang::RecordType *record_type =
llvm::cast(qual_type.getTypePtr());
const clang::RecordDecl *record_decl = record_type->getDecl();
assert(record_decl);
auto result = std::distance(EnumIt(record_decl->decls_begin()), 
EnumIt(record_decl->decls_end()));
return result;
  }
  return 0;
}
```
It's also available here: 
https://github.com/Endilll/llvm-project/blob/fbad2d1fd8e9c67e4de8a196df0cd1d1788fa990/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L7080-L7095

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::FindNestedType() function (PR #68705)

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

Endilll wrote:

> Is FindNestedType guaranteed to have a single return?

Yes, because search is not recursive, i.e. doesn't search inside nested types.
I'm intentionally specifying `FindNestedType` this way, because I'd like it to 
not do too much to remain fast by design, and I'm yet to see a use case when 
I'd be interested in type `NN`, buried inside arbitrary number of intervening 
nested types. Even if there is such use case, `SBTarget::FindFirstType` could 
be a better fit to address it.

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::FindNestedType() function (PR #68705)

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

Endilll wrote:

`depth` parameter makes sense to me.
I wonder if it should have a default value 0 meaning infinite depth.

Now I wonder how my current implementation behaves with respect to depth, which 
is actually embarrassing. And how to implement `depth` parameter. 

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::FindNestedType() function (PR #68705)

2023-10-10 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 1/3] [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::FindNestedType() function (PR #68705)

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


@@ -1082,6 +1082,19 @@ bool TypeImpl::GetDescription(lldb_private::Stream &strm,
   return true;
 }
 
+CompilerType TypeImpl::FindNestedType(ConstString name) {
+  auto type_system = GetTypeSystem(false);

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::FindNestedType() function (PR #68705)

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


@@ -1082,6 +1082,19 @@ bool TypeImpl::GetDescription(lldb_private::Stream &strm,
   return true;
 }
 
+CompilerType TypeImpl::FindNestedType(ConstString name) {
+  auto type_system = GetTypeSystem(false);
+  auto *symbol_file = type_system->GetSymbolFile();
+  auto decl_context = 
type_system->GetCompilerDeclContextForType(m_static_type);
+  llvm::DenseSet searched_symbol_files;
+  TypeMap search_result;
+  symbol_file->FindTypes(name, decl_context, /*max_matches*/ 1, 
searched_symbol_files, search_result);
+  if (search_result.Empty()) {
+return CompilerType();
+  }

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::FindNestedType() function (PR #68705)

2023-10-10 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);

Endilll wrote:

I didn't knew this. Thank you!

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::FindNestedType() function (PR #68705)

2023-10-11 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:

> Do we want to make a ConstString for every argument that is passed to 
> FindNestedType ?

I'm not sure about LLDB conventions around string types, but I need to create 
`ConstString` every time `FindNestedType` is called, because that's what 
`SymbolFile::FindTypes` expects, which I unconditionally call.

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::FindNestedType() function (PR #68705)

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

Endilll wrote:

@jimingham
https://github.com/llvm/llvm-project/blob/d5444ab26743115e42e4abb3782bbefb0e8912d0/lldb/source/Symbol/CompilerDeclContext.cpp#L49-L61
and
https://github.com/llvm/llvm-project/blob/d5444ab26743115e42e4abb3782bbefb0e8912d0/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L9697-L9712
suggest that depth of the search is type-system-dependent, and that Clang type 
system doesn't do recursive check, save for inline namespaces, which doesn't 
matter for this PR. I don't mind writing an interface for recursive search and 
saying somewhere that depths other that 1 are not yet supported, but I consider 
it outside of this PR (and my use case) to implement recursive search. Does 
this sound good to you, or you'd prefer something along the lines of  
`FindDirectNestedType`?

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::FindNestedType() function (PR #68705)

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

Endilll wrote:

> find A::B::C which is a match, note max_matches == 1 and return

Looking at `DeclContextIsContainedInLookup`, `A::B::C` is not a match, because 
it's `DeclContext` is not `DeclContext` of `A`. This is of course is not 
future-proof against changes to `DeclContextIsContainedInLookup` that can make 
it smarter in this regard, but we can have something along the lines 
`TypeSystem::DeclContextIsDirectlyContainedInLookup` if we deem it necessary.

For the context, this is the first check search algorithm performs while 
determining a match:
https://github.com/llvm/llvm-project/blob/d5444ab26743115e42e4abb3782bbefb0e8912d0/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp#L2600
https://github.com/llvm/llvm-project/blob/d5444ab26743115e42e4abb3782bbefb0e8912d0/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp#L2440


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::FindNestedType() function (PR #68705)

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

Endilll wrote:

It's not clear to me whether `TypeSystem::DeclContextIsContainedInLookup` 
provides such a guarantee. Implementation suggests that it's only interested in 
direct `DeclContext`, maybe ignoring transparent decl contexts like inline 
namespace it already handles. I hope reviewers can clarify this.

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::FindNestedType() function (PR #68705)

2023-10-12 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 1/4] [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::FindNestedType() function (PR #68705)

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


@@ -1082,6 +1082,19 @@ bool TypeImpl::GetDescription(lldb_private::Stream &strm,
   return true;
 }
 
+CompilerType TypeImpl::FindNestedType(ConstString name) {

Endilll wrote:

Makes sense.
IIRC it's possible to have multiple anonymous unions, so it's not going to work 
properly even if we allow it.

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::FindNestedType() function (PR #68705)

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


@@ -186,6 +186,11 @@ std::optional 
TypeSystem::ReportStatistics() {
   return std::nullopt;
 }
 
+CompilerDeclContext

Endilll wrote:

> Could add a brief oxygen docstring saying: "Returns the direct parent context 
> of specified type".

I'd be happy to do that as long as Jim is not opposed to the direction of 
`FindDirectNestedType`.

> Also, what happens if no such context exists (if that can happen)?

Half an hour ago I discovered that this can happen, and updated this patch.
See 
https://github.com/llvm/llvm-project/blob/434b8a30804a433526e80eb97f15dafa1815f936/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L2672-L2696

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::FindNestedType() function (PR #68705)

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


@@ -119,6 +119,11 @@ def test(self):
 
 self.assertEqual(task_type, task_head_pointee_type)
 
+# Check whether we can find a nested type by name
+name_type = task_type.FindNestedType("name")

Endilll wrote:

I can, but I'm not sure it would bring additional coverage.

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::FindNestedType() function (PR #68705)

2023-10-12 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 1/6] [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::FindNestedType() function (PR #68705)

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


@@ -119,6 +119,11 @@ def test(self):
 
 self.assertEqual(task_type, task_head_pointee_type)
 
+# Check whether we can find a nested type by name
+name_type = task_type.FindNestedType("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::FindNestedType() function (PR #68705)

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


@@ -1082,6 +1082,19 @@ bool TypeImpl::GetDescription(lldb_private::Stream &strm,
   return true;
 }
 
+CompilerType TypeImpl::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::FindNestedType() function (PR #68705)

2023-10-12 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 1/7] [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::FindNestedType() function (PR #68705)

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


@@ -119,6 +119,15 @@ def test(self):
 
 self.assertEqual(task_type, task_head_pointee_type)
 
+# Check whether we can find a nested type by name
+name_type = task_type.FindNestedType("name")
+self.assertTrue(name_type)
+self.DebugSBType(name_type)
+

Endilll wrote:

I pushed an update. Can you take a look again?

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::FindNestedType() function (PR #68705)

2023-10-12 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 1/8] [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::FindNestedType() function (PR #68705)

2023-10-12 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/11] [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::FindNestedType() function (PR #68705)

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


@@ -186,6 +186,11 @@ std::optional 
TypeSystem::ReportStatistics() {
   return std::nullopt;
 }
 
+CompilerDeclContext

Endilll wrote:

Both items are 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::FindNestedType() function (PR #68705)

2023-10-12 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:

@jimingham @Michael137 Any opinions?

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::FindNestedType() function (PR #68705)

2023-10-12 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/12] [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::FindNestedType() function (PR #68705)

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


@@ -119,6 +119,38 @@ def test(self):
 
 self.assertEqual(task_type, task_head_pointee_type)
 
+# Check whether we can find a directly nested type by name
+name_type = task_type.FindDirectNestedType("name")
+self.assertTrue(name_type)
+self.DebugSBType(name_type)
+
+enum_type = task_type.FindDirectNestedType("E")
+self.assertTrue(enum_type)
+self.DebugSBType(enum_type)
+
+union_type = task_type.FindDirectNestedType("U")
+self.assertTrue(union_type)
+self.DebugSBType(union_type)
+
+# Check that we don't find indirectly nested types
+
+self.assertTrue(enum_type.size == 1)

Endilll wrote:

At the moment we don't have an API to get (direct) `DeclContext` of a type, as 
far as I know. So I made enums distinct by using underlying type of different 
size.

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::FindNestedType() 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::FindNestedType() 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/13] [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::FindNestedType() function (PR #68705)

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


@@ -8,6 +8,9 @@ class Task {
 TASK_TYPE_1,
 TASK_TYPE_2
 } type;
+enum E : unsigned char {} e;
+union U {
+} u;

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 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


  1   2   >