complete-documentation-templates.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Note: the run lines follow their respective tests, since line/column numbers
  2. // matter in this test.
  3. /// This is T1.
  4. template<typename T>
  5. void T1(T t) { }
  6. /// This is T2.
  7. template<typename T>
  8. void T2(T t) { }
  9. /// This is T2<int>.
  10. template<>
  11. void T2(int t) { }
  12. void test_CC1() {
  13. }
  14. // Check that implicit instantiations of class templates and members pick up
  15. // comments from class templates and specializations.
  16. /// This is T3.
  17. template<typename T>
  18. class T3 {
  19. public:
  20. /// This is T4.
  21. static void T4();
  22. /// This is T5.
  23. static int T5;
  24. /// This is T6.
  25. void T6();
  26. /// This is T7.
  27. int T7;
  28. /// This is T8.
  29. class T8 {};
  30. /// This is T9.
  31. enum T9 {
  32. /// This is T10.
  33. T10
  34. };
  35. /// This is T11.
  36. template<typename U>
  37. void T11(U t) {}
  38. typedef T3<double> T12;
  39. };
  40. void test_CC2_CC3_CC4() {
  41. T3<int>::T4();
  42. T3<int> t3;
  43. t3.T6();
  44. T3<int>::T8 t8;
  45. }
  46. /// This is T100.
  47. template<typename T, typename U>
  48. class T100 {
  49. };
  50. /// This is T100<int, T>.
  51. template<typename T>
  52. class T100<int, T> {
  53. public:
  54. /// This is T101.
  55. static void T101();
  56. /// This is T102.
  57. static int T102;
  58. /// This is T103.
  59. void T103();
  60. /// This is T104.
  61. int T104;
  62. /// This is T105.
  63. class T105 {};
  64. /// This is T106.
  65. enum T106 {
  66. /// This is T107.
  67. T107
  68. };
  69. /// This is T108.
  70. template<typename U>
  71. void T108(U t) {}
  72. typedef T100<double, T> T109;
  73. typedef T100<double, double> T110;
  74. };
  75. void test_CC5_CC6_CC7() {
  76. T100<int, long>::T101();
  77. T100<int, long> t100;
  78. t100.T103();
  79. T100<int, long>::T105 t105;
  80. }
  81. // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:17:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
  82. // CHECK-CC1: FunctionTemplate:{ResultType void}{TypedText T1}{{.*}}(brief comment: This is T1.)
  83. // CHECK-CC1: FunctionTemplate:{ResultType void}{TypedText T2}{{.*}}(brief comment: This is T2.)
  84. // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:56:12 %s | FileCheck -check-prefix=CHECK-CC2 %s
  85. // CHECK-CC2: CXXMethod:{ResultType void}{TypedText T4}{{.*}}(brief comment: This is T4.)
  86. // CHECK-CC2: VarDecl:{ResultType int}{TypedText T5}{{.*}}(brief comment: This is T5.)
  87. // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:58:6 %s | FileCheck -check-prefix=CHECK-CC3 %s
  88. // CHECK-CC3: FunctionTemplate:{ResultType void}{TypedText T11}{{.*}}(brief comment: This is T11.)
  89. // CHECK-CC3: CXXMethod:{ResultType void}{TypedText T6}{{.*}}(brief comment: This is T6.)
  90. // CHECK-CC3: FieldDecl:{ResultType int}{TypedText T7}{{.*}}(brief comment: This is T7.)
  91. // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:59:12 %s | FileCheck -check-prefix=CHECK-CC4 %s
  92. // CHECK-CC4: EnumConstantDecl:{ResultType T3<int>::T9}{TypedText T10}{{.*}}(brief comment: This is T10.)
  93. // FIXME: after we implement propagating comments through typedefs, this
  94. // typedef for implicit instantiation should pick up the documentation
  95. // comment from class template.
  96. // CHECK-CC4: TypedefDecl:{TypedText T12}
  97. // CHECK-CC4-SHOULD-BE: TypedefDecl:{TypedText T12}{{.*}}(brief comment: This is T3.)
  98. // CHECK-CC4: ClassDecl:{TypedText T8}{{.*}}(brief comment: This is T8.)
  99. // CHECK-CC4: EnumDecl:{TypedText T9}{{.*}}(brief comment: This is T9.)
  100. // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:102:20 %s | FileCheck -check-prefix=CHECK-CC5 %s
  101. // CHECK-CC5: CXXMethod:{ResultType void}{TypedText T101}{{.*}}(brief comment: This is T101.)
  102. // CHECK-CC5: VarDecl:{ResultType int}{TypedText T102}{{.*}}(brief comment: This is T102.)
  103. // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:104:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
  104. // CHECK-CC6: CXXMethod:{ResultType void}{TypedText T103}{{.*}}(brief comment: This is T103.)
  105. // CHECK-CC6: FieldDecl:{ResultType int}{TypedText T104}{{.*}}(brief comment: This is T104.)
  106. // CHECK-CC6: FunctionTemplate:{ResultType void}{TypedText T108}{{.*}}(brief comment: This is T108.)
  107. // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:105:20 %s | FileCheck -check-prefix=CHECK-CC7 %s
  108. // CHECK-CC7: ClassDecl:{TypedText T105}{{.*}}(brief comment: This is T105.)
  109. // CHECK-CC7: EnumDecl:{TypedText T106}{{.*}}(brief comment: This is T106.)
  110. // CHECK-CC7: EnumConstantDecl:{ResultType T100<int, long>::T106}{TypedText T107}{{.*}}(brief comment: This is T107.)
  111. // FIXME: after we implement propagating comments through typedefs, these two
  112. // typedefs for implicit instantiations should pick up the documentation
  113. // comment from class template.
  114. // CHECK-CC7: TypedefDecl:{TypedText T109}
  115. // CHECK-CC7: TypedefDecl:{TypedText T110}
  116. // CHECK-CC7-SHOULD-BE: TypedefDecl:{TypedText T109}{{.*}}(brief comment: This is T100.)
  117. // CHECK-CC7-SHOULD-BE: TypedefDecl:{TypedText T110}{{.*}}(brief comment: This is T100.)