Files
clang-p2996/lldb/test/API/functionalities/breakpoint/cpp/main.cpp
Michael Buch d4a55ad346 [lldb][Breakpoint] Fix setting breakpoints on templates by basename
This patch fixes a regression with setting breakpoints on template
functions by name. E.g.,:
```
$ cat main.cpp
template<typename T>
struct Foo {
  template<typename U>
  void func() {}
};

int main() {
  Foo<int> f;
  f.func<double>();
}

(lldb) br se -n func
```

This has regressed since `3339000e0bda696c2e29173d15958c0a4978a143`
where we started using the `CPlusPlusNameParser` for getting the
basename of the function symbol and match it exactly against
the name in the breakpoint command. The parser will include template
parameters in the basename, so the exact match will always fail

**Testing**

* Added API tests
* Added unit-tests

Differential Revision: https://reviews.llvm.org/D135921
2022-10-14 23:51:00 +01:00

128 lines
2.0 KiB
C++

#include <stdio.h>
#include <stdint.h>
namespace a {
class c {
public:
c();
~c();
void func1()
{
puts (__PRETTY_FUNCTION__);
}
void func2()
{
puts (__PRETTY_FUNCTION__);
}
void func3()
{
puts (__PRETTY_FUNCTION__);
}
};
c::c() {}
c::~c() {}
}
namespace aa {
class cc {
public:
cc();
~cc();
void func1()
{
puts (__PRETTY_FUNCTION__);
}
void func2()
{
puts (__PRETTY_FUNCTION__);
}
void func3()
{
puts (__PRETTY_FUNCTION__);
}
};
cc::cc() {}
cc::~cc() {}
}
namespace b {
class c {
public:
c();
~c();
void func1()
{
puts (__PRETTY_FUNCTION__);
}
void func3()
{
puts (__PRETTY_FUNCTION__);
}
};
c::c() {}
c::~c() {}
}
namespace c {
class d {
public:
d () {}
~d() {}
void func2()
{
puts (__PRETTY_FUNCTION__);
}
void func3()
{
puts (__PRETTY_FUNCTION__);
}
};
}
namespace ns {
template <typename Type> struct Foo {
template <typename T> void import() {}
template <typename T> auto func() {}
operator bool() { return true; }
template <typename T> operator T() { return {}; }
template <typename T> void operator<<(T t) {}
};
} // namespace ns
int main (int argc, char const *argv[])
{
a::c ac;
aa::cc aac;
b::c bc;
c::d cd;
ac.func1();
ac.func2();
ac.func3();
aac.func1();
aac.func2();
aac.func3();
bc.func1();
bc.func3();
cd.func2();
cd.func3();
ns::Foo<double> f;
f.import <int>();
f.func<int>();
f.func<ns::Foo<int>>();
f.operator bool();
f.operator a::c();
f.operator ns::Foo<int>();
f.operator<<(5);
f.operator<< <ns::Foo<int>>({});
return 0;
}