[Lldb-commits] [PATCH] D137272: [lldb][Test] Make TestFrameFormatNameWithArgs.test more compatible across platforms

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 2 10:21:44 PDT 2022


Michael137 created this revision.
Michael137 added a reviewer: labath.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

On Linux the `std::function` behaved differently to that on Darwin.

This patch removes usage of `std::function` in the test but attempts
to retain the test-coverage. We mainly want function types appearing
in the template argument and function argument lists.

Also add a `char const*` overload to one of the test functions to
cover the "format function argument using ValueObject formatter" code-path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137272

Files:
  lldb/test/Shell/Settings/Inputs/names.cpp
  lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test


Index: lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
===================================================================
--- lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-darwin
+# UNSUPPORTED: system-windows
 # RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out
 # RUN: %lldb -b -s %s %t.out | FileCheck %s
 settings set -f frame-format "frame ${function.name-with-args}\n"
@@ -8,21 +8,19 @@
 run
 # CHECK: frame int ns::foo<int ()>(t={{.*}})
 c
-# CHECK: frame int ns::foo<std::{{.*}}function<int ()>>(t= Function = bar() )
+# CHECK: frame int ns::foo<int ()>(str="bar")
 c
-# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t={{.*}})
+# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t=(anonymous namespace)::(unnamed class) @ {{.*}})
 c
-# CHECK: frame int ns::foo<std::{{.*}}function<int ()>>(t= Function = (anonymous namespace)::anon_bar() )
+# CHECK: frame int ns::foo<int (*)()>(t=({{.*}}`(anonymous namespace)::anon_bar() at {{.*}}))
 c
-# CHECK: frame int ns::foo<void (Foo::*)(std::{{.*}}function<int (int)> const&) const noexcept>(t={{.*}})
+# CHECK: frame int ns::foo<void (Foo::*)(int (*)(int)) const noexcept>(str="method")
 c
 # CHECK: frame ns::returns_func_ptr<int>((null)={{.*}})
 c
-# CHECK: frame void Foo::foo<std::{{.*}}function<int ()>>(this={{.*}}, t= Function = bar() ) const
+# CHECK: frame void Foo::foo<int (*)()>(this={{.*}}, arg=({{.*}}`(anonymous namespace)::anon_bar() at {{.*}}))
 c
-# CHECK: frame void Foo::foo<std::{{.*}}function<int ()>>(this={{.*}}, t= Function = (anonymous namespace)::anon_bar() ) const
-c
-# CHECK: frame void Foo::operator<<<1ul>(this={{.*}}, (null)=0)
+# CHECK: frame void Foo::operator<<<1>(this={{.*}}, (null)=0)
 c
 # CHECK: frame Foo::returns_func_ptr<int>(this={{.*}}, (null)={{.*}})
 q
Index: lldb/test/Shell/Settings/Inputs/names.cpp
===================================================================
--- lldb/test/Shell/Settings/Inputs/names.cpp
+++ lldb/test/Shell/Settings/Inputs/names.cpp
@@ -1,5 +1,3 @@
-#include <functional>
-
 namespace detail {
 template <typename T> struct Quux {};
 } // namespace detail
@@ -7,15 +5,16 @@
 using FuncPtr = detail::Quux<double> (*(*)(int))(float);
 
 struct Foo {
-  template <typename T> void foo(T const &t) const noexcept(true) {}
+  template <typename T> void foo(T arg) const noexcept(true) {}
 
-  template <size_t T> void operator<<(size_t) {}
+  template <int T> void operator<<(int) {}
 
   template <typename T> FuncPtr returns_func_ptr(detail::Quux<int> &&) const noexcept(false) { return nullptr; }
 };
 
 namespace ns {
-template <typename T> int foo(T const &t) noexcept(false) { return 0; }
+template <typename T> int foo(char const *str) noexcept(false) { return 0; }
+template <typename T> int foo(T t) { return 1; }
 
 template <typename T> FuncPtr returns_func_ptr(detail::Quux<int> &&) { return nullptr; }
 } // namespace ns
@@ -24,20 +23,20 @@
 
 namespace {
 int anon_bar() { return 1; }
-auto anon_lambda = [](std::function<int(int (*)(int))>) mutable {};
+auto anon_lambda = [] {};
 } // namespace
 
 int main() {
-  ns::foo(bar);
-  ns::foo(std::function{bar});
+  ns::foo<decltype(bar)>(bar);
+  ns::foo<decltype(bar)>("bar");
   ns::foo(anon_lambda);
-  ns::foo(std::function{anon_bar});
-  ns::foo(&Foo::foo<std::function<int(int)>>);
+  ns::foo(anon_bar);
+  ns::foo<decltype(&Foo::foo<int(int)>)>("method");
   ns::returns_func_ptr<int>(detail::Quux<int>{});
   Foo f;
-  f.foo(std::function{bar});
-  f.foo(std::function{anon_bar});
+  f.foo(anon_bar);
   f.operator<< <(2 > 1)>(0);
   f.returns_func_ptr<int>(detail::Quux<int>{});
+
   return 0;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137272.472673.patch
Type: text/x-patch
Size: 3743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221102/6cf0a90b/attachment.bin>


More information about the lldb-commits mailing list