complete-exprs.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Line- and column-sensitive test; run lines follow.
  2. class string {
  3. public:
  4. string();
  5. string(const char *);
  6. string(const char *, int n);
  7. };
  8. template<typename T>
  9. class vector {
  10. public:
  11. vector(const T &, unsigned n);
  12. template<typename InputIterator>
  13. vector(InputIterator first, InputIterator last);
  14. void push_back(const T&);
  15. };
  16. template<typename T> void vector<T>::push_back(const T&) { }
  17. void f() {
  18. }
  19. int foo();
  20. void g() {
  21. vector<int>(foo(), foo());
  22. }
  23. struct X {
  24. void f() const;
  25. };
  26. void X::f() const {
  27. }
  28. namespace N {
  29. int x;
  30. class C {
  31. int member;
  32. int f(int param) {
  33. return member;
  34. }
  35. };
  36. }
  37. // RUN: c-index-test -code-completion-at=%s:20:2 %s -std=c++0x | FileCheck -check-prefix=CHECK-CC1 %s
  38. // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:20:2 -std=c++0x %s | FileCheck -check-prefix=CHECK-CC1 %s
  39. // CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText alignof}{LeftParen (}{Placeholder type}{RightParen )} (40)
  40. // CHECK-CC1: NotImplemented:{ResultType bool}{TypedText noexcept}{LeftParen (}{Placeholder expression}{RightParen )} (40)
  41. // CHECK-CC1: NotImplemented:{ResultType std::nullptr_t}{TypedText nullptr} (40)
  42. // CHECK-CC1: NotImplemented:{TypedText operator} (40)
  43. // CHECK-CC1-NOT: push_back
  44. // CHECK-CC1: ClassDecl:{TypedText string} (50)
  45. // CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{RightParen )} (50)
  46. // CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{Placeholder const char *}{RightParen )} (50)
  47. // CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{Placeholder const char *}{Comma , }{Placeholder int n}{RightParen )} (50)
  48. // CHECK-CC1: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
  49. // CHECK-CC1: CXXConstructor:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder const T &}{Comma , }{Placeholder unsigned int n}{RightParen )} (50)
  50. // CHECK-CC1: FunctionTemplate:{ResultType void}{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder InputIterator first}{Comma , }{Placeholder InputIterator last}{RightParen )} (50)
  51. // RUN: c-index-test -code-completion-at=%s:19:1 %s | FileCheck -check-prefix=CHECK-CC2 %s
  52. // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:19:1 %s | FileCheck -check-prefix=CHECK-CC2 %s
  53. // CHECK-CC2: ClassDecl:{TypedText string} (50)
  54. // CHECK-CC2-NOT: CXXConstructor
  55. // CHECK-CC2: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
  56. // RUN: c-index-test -code-completion-at=%s:26:15 %s | FileCheck -check-prefix=CHECK-CC3 %s
  57. // CHECK-CC3: NotImplemented:{TypedText float} (50)
  58. // CHECK-CC3: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{RightParen )} (50)
  59. // CHECK-CC3: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{RightParen )} (50)
  60. // CHECK-CC3: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
  61. // CHECK-CC3: CXXConstructor:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder const T &}{Comma , }{Placeholder unsigned int n}{RightParen )} (50)
  62. // CHECK-CC3: FunctionTemplate:{ResultType void}{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder InputIterator first}{Comma , }{Placeholder InputIterator last}{RightParen )} (50)
  63. // RUN: c-index-test -code-completion-at=%s:34:1 %s -std=c++0x | FileCheck -check-prefix=CHECK-CC4 %s
  64. // CHECK-CC4: NotImplemented:{ResultType const X *}{TypedText this} (40)
  65. // RUN: c-index-test -code-completion-at=%s:43:14 %s | FileCheck -check-prefix=CHECK-CC5 %s
  66. // CHECK-CC5: FieldDecl:{ResultType int}{TypedText member} (8)
  67. // CHECK-CC5: ParmDecl:{ResultType int}{TypedText param} (8)
  68. // CHECK-CC5: StructDecl:{TypedText X} (50)
  69. // CHECK-CC5: VarDecl:{ResultType int}{TypedText x} (12)