xref: /llvm-project/lldb/test/API/lang/cpp/const_this/main.cpp (revision 7862728cab1b7724d2adf0f0075a3289d87ec20c)
1*7862728cSRaphael Isemann struct ContextClass {
2*7862728cSRaphael Isemann   int member = 3;
3*7862728cSRaphael Isemann   ContextClass *this_type = nullptr;
ContextClassContextClass4*7862728cSRaphael Isemann   ContextClass() { this_type = this; }
5*7862728cSRaphael Isemann 
funcContextClass6*7862728cSRaphael Isemann   int func() const {
7*7862728cSRaphael Isemann     return member; // break in function in class.
8*7862728cSRaphael Isemann   }
9*7862728cSRaphael Isemann 
templateFuncContextClass10*7862728cSRaphael Isemann   template <class T> T templateFunc(T x) const {
11*7862728cSRaphael Isemann     return member; // break in templated function in class.
1299451b44SJordan Rupprecht   }
1399451b44SJordan Rupprecht };
1499451b44SJordan Rupprecht 
15*7862728cSRaphael Isemann template <typename TC> struct TemplatedContextClass {
16*7862728cSRaphael Isemann   int member = 4;
17*7862728cSRaphael Isemann   TemplatedContextClass<TC> *this_type = nullptr;
TemplatedContextClassTemplatedContextClass18*7862728cSRaphael Isemann   TemplatedContextClass() { this_type = this; }
19*7862728cSRaphael Isemann 
funcTemplatedContextClass20*7862728cSRaphael Isemann   int func() const {
21*7862728cSRaphael Isemann     return member; // break in function in templated class.
22*7862728cSRaphael Isemann   }
23*7862728cSRaphael Isemann 
templateFuncTemplatedContextClass24*7862728cSRaphael Isemann   template <class T> T templateFunc(T x) const {
25*7862728cSRaphael Isemann     return member; // break in templated function in templated class.
26*7862728cSRaphael Isemann   }
27*7862728cSRaphael Isemann };
2899451b44SJordan Rupprecht 
main()2999451b44SJordan Rupprecht int main() {
30*7862728cSRaphael Isemann   ContextClass c;
31*7862728cSRaphael Isemann   TemplatedContextClass<int> t;
32*7862728cSRaphael Isemann   return c.func() + c.templateFunc(1) + t.func() + t.templateFunc(1);
3399451b44SJordan Rupprecht }
34