cxx-operator-overload.cpp 812 B

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