xref: /llvm-project/lldb/test/Shell/Settings/Inputs/names.cpp (revision f4ede08c61cba631de204398a91aa59bac9d5db9)
1031096d0SMichael Buch namespace detail {
2031096d0SMichael Buch template <typename T> struct Quux {};
3031096d0SMichael Buch } // namespace detail
4031096d0SMichael Buch 
5031096d0SMichael Buch using FuncPtr = detail::Quux<double> (*(*)(int))(float);
6031096d0SMichael Buch 
7031096d0SMichael Buch struct Foo {
fooFoo8c1889106SMichael Buch   template <typename T> void foo(T arg) const noexcept(true) {}
9031096d0SMichael Buch 
operator <<Foo10c1889106SMichael Buch   template <int T> void operator<<(int) {}
11031096d0SMichael Buch 
returns_func_ptrFoo12031096d0SMichael Buch   template <typename T> FuncPtr returns_func_ptr(detail::Quux<int> &&) const noexcept(false) { return nullptr; }
13031096d0SMichael Buch };
14031096d0SMichael Buch 
15031096d0SMichael Buch namespace ns {
foo(char const * str)16c1889106SMichael Buch template <typename T> int foo(char const *str) noexcept(false) { return 0; }
foo(T t)17c1889106SMichael Buch template <typename T> int foo(T t) { return 1; }
18031096d0SMichael Buch 
returns_func_ptr(detail::Quux<int> &&)19031096d0SMichael Buch template <typename T> FuncPtr returns_func_ptr(detail::Quux<int> &&) { return nullptr; }
20031096d0SMichael Buch } // namespace ns
21031096d0SMichael Buch 
bar()22031096d0SMichael Buch int bar() { return 1; }
23031096d0SMichael Buch 
24031096d0SMichael Buch namespace {
anon_bar()25031096d0SMichael Buch int anon_bar() { return 1; }
__anon310810fc0202null26c1889106SMichael Buch auto anon_lambda = [] {};
27031096d0SMichael Buch } // namespace
28031096d0SMichael Buch 
inlined_foo(const char * str)29*f4ede08cSZequan Wu __attribute__((always_inline)) int inlined_foo(const char *str) {
30*f4ede08cSZequan Wu   if (bool b = bar())
31*f4ede08cSZequan Wu     return 1;
32*f4ede08cSZequan Wu   return 2;
33*f4ede08cSZequan Wu }
34*f4ede08cSZequan Wu 
main()35031096d0SMichael Buch int main() {
36c1889106SMichael Buch   ns::foo<decltype(bar)>(bar);
37c1889106SMichael Buch   ns::foo<decltype(bar)>("bar");
38031096d0SMichael Buch   ns::foo(anon_lambda);
39c1889106SMichael Buch   ns::foo(anon_bar);
40c1889106SMichael Buch   ns::foo<decltype(&Foo::foo<int(int)>)>("method");
41031096d0SMichael Buch   ns::returns_func_ptr<int>(detail::Quux<int>{});
42031096d0SMichael Buch   Foo f;
43c1889106SMichael Buch   f.foo(anon_bar);
44031096d0SMichael Buch   f.operator<< <(2 > 1)>(0);
45031096d0SMichael Buch   f.returns_func_ptr<int>(detail::Quux<int>{});
46*f4ede08cSZequan Wu   inlined_foo("bar");
47031096d0SMichael Buch   return 0;
48031096d0SMichael Buch }
49