xref: /minix3/external/bsd/llvm/dist/clang/test/Index/cxx-operator-overload.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // Run lines are sensitive to line numbers and come below the code.
2*f4a2713aSLionel Sambuc // FIXME: re-enable this when we can serialize more C++ ASTs
3*f4a2713aSLionel Sambuc class Cls {
4*f4a2713aSLionel Sambuc public:
5*f4a2713aSLionel Sambuc     Cls operator +(const Cls &RHS);
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
bar()8*f4a2713aSLionel Sambuc static void bar() {
9*f4a2713aSLionel Sambuc     Cls x1, x2, x3;
10*f4a2713aSLionel Sambuc     Cls x4 = x1 + x2 + x3;
11*f4a2713aSLionel Sambuc }
12*f4a2713aSLionel Sambuc 
operator +(const Cls & RHS)13*f4a2713aSLionel Sambuc Cls Cls::operator +(const Cls &RHS) { while (1) {} }
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-pch %s -o %t.ast
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc // RUNx: index-test %t.ast -point-at %s:10:17 -print-decls > %t &&
18*f4a2713aSLionel Sambuc // RUNx: cat %t | count 2 &&
19*f4a2713aSLionel Sambuc // RUNx: grep ':5:9,' %t &&
20*f4a2713aSLionel Sambuc // RUNx: grep ':13:10,' %t &&
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc // Yep, we can show references of '+' plus signs that are overloaded, w00t!
23*f4a2713aSLionel Sambuc // RUNx: index-test %t.ast -point-at %s:5:15 -print-refs > %t &&
24*f4a2713aSLionel Sambuc // RUNx: cat %t | count 2 &&
25*f4a2713aSLionel Sambuc // RUNx: grep ':10:17,' %t &&
26*f4a2713aSLionel Sambuc // RUNx: grep ':10:22,' %t &&
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // RUNx: index-test %t.ast -point-at %s:10:14 | grep 'DeclRefExpr x1'
29