Skip to content

Commit dd918d8

Browse files
committed
[lldb][Test] Make TestFrameFormatNameWithArgs.test more compatible across platforms
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. Differential Revision: https://reviews.llvm.org/D137272 (cherry picked from commit c188910)
1 parent 6dfce66 commit dd918d8

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
#include <functional>
2-
31
namespace detail {
42
template <typename T> struct Quux {};
53
} // namespace detail
64

75
using FuncPtr = detail::Quux<double> (*(*)(int))(float);
86

97
struct Foo {
10-
template <typename T> void foo(T const &t) const noexcept(true) {}
8+
template <typename T> void foo(T arg) const noexcept(true) {}
119

12-
template <size_t T> void operator<<(size_t) {}
10+
template <int T> void operator<<(int) {}
1311

1412
template <typename T> FuncPtr returns_func_ptr(detail::Quux<int> &&) const noexcept(false) { return nullptr; }
1513
};
1614

1715
namespace ns {
18-
template <typename T> int foo(T const &t) noexcept(false) { return 0; }
16+
template <typename T> int foo(char const *str) noexcept(false) { return 0; }
17+
template <typename T> int foo(T t) { return 1; }
1918

2019
template <typename T> FuncPtr returns_func_ptr(detail::Quux<int> &&) { return nullptr; }
2120
} // namespace ns
@@ -24,20 +23,20 @@ int bar() { return 1; }
2423

2524
namespace {
2625
int anon_bar() { return 1; }
27-
auto anon_lambda = [](std::function<int(int (*)(int))>) mutable {};
26+
auto anon_lambda = [] {};
2827
} // namespace
2928

3029
int main() {
31-
ns::foo(bar);
32-
ns::foo(std::function{bar});
30+
ns::foo<decltype(bar)>(bar);
31+
ns::foo<decltype(bar)>("bar");
3332
ns::foo(anon_lambda);
34-
ns::foo(std::function{anon_bar});
35-
ns::foo(&Foo::foo<std::function<int(int)>>);
33+
ns::foo(anon_bar);
34+
ns::foo<decltype(&Foo::foo<int(int)>)>("method");
3635
ns::returns_func_ptr<int>(detail::Quux<int>{});
3736
Foo f;
38-
f.foo(std::function{bar});
39-
f.foo(std::function{anon_bar});
37+
f.foo(anon_bar);
4038
f.operator<< <(2 > 1)>(0);
4139
f.returns_func_ptr<int>(detail::Quux<int>{});
40+
4241
return 0;
4342
}
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# REQUIRES: system-darwin
1+
# UNSUPPORTED: system-windows
22
# RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out
33
# RUN: %lldb -b -s %s %t.out | FileCheck %s
44
settings set -f frame-format "frame ${function.name-with-args}\n"
@@ -8,21 +8,19 @@ break set -n returns_func_ptr
88
run
99
# CHECK: frame int ns::foo<int ()>(t={{.*}})
1010
c
11-
# CHECK: frame int ns::foo<std::{{.*}}function<int ()>>(t= Function = bar() )
11+
# CHECK: frame int ns::foo<int ()>(str="bar")
1212
c
13-
# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t={{.*}})
13+
# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t=(anonymous namespace)::(unnamed class) @ {{.*}})
1414
c
15-
# CHECK: frame int ns::foo<std::{{.*}}function<int ()>>(t= Function = (anonymous namespace)::anon_bar() )
15+
# CHECK: frame int ns::foo<int (*)()>(t=({{.*}}`(anonymous namespace)::anon_bar() at {{.*}}))
1616
c
17-
# CHECK: frame int ns::foo<void (Foo::*)(std::{{.*}}function<int (int)> const&) const noexcept>(t={{.*}})
17+
# CHECK: frame int ns::foo<void (Foo::*)(int (*)(int)) const noexcept>(str="method")
1818
c
1919
# CHECK: frame ns::returns_func_ptr<int>((null)={{.*}})
2020
c
21-
# CHECK: frame void Foo::foo<std::{{.*}}function<int ()>>(this={{.*}}, t= Function = bar() ) const
21+
# CHECK: frame void Foo::foo<int (*)()>(this={{.*}}, arg=({{.*}}`(anonymous namespace)::anon_bar() at {{.*}}))
2222
c
23-
# CHECK: frame void Foo::foo<std::{{.*}}function<int ()>>(this={{.*}}, t= Function = (anonymous namespace)::anon_bar() ) const
24-
c
25-
# CHECK: frame void Foo::operator<<<1ul>(this={{.*}}, (null)=0)
23+
# CHECK: frame void Foo::operator<<<1>(this={{.*}}, (null)=0)
2624
c
2725
# CHECK: frame Foo::returns_func_ptr<int>(this={{.*}}, (null)={{.*}})
2826
q

0 commit comments

Comments
 (0)