xref: /llvm-project/clang/test/Index/comment-cplus-template-decls.cpp (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 std=c++11 %s > %t/out
4 // RUN: FileCheck %s < %t/out
5 
6 // Ensure that XML we generate is not invalid.
7 // RUN: FileCheck %s -check-prefix=WRONG < %t/out
8 // WRONG-NOT: CommentXMLInvalid
9 
10 /**
11  * \brief Aaa
12 */
13 template<typename T> struct A {
14 /**
15  * \brief Bbb
16 */
17   A();
18 /**
19  * \brief Ccc
20 */
21   ~A();
22 /**
23  * \brief Ddd
24 */
fA25   void f() { }
26 };
27 // CHECK: <Declaration>template &lt;typename T&gt; struct A {}</Declaration>
28 // CHECK: <Declaration>A&lt;T&gt;()</Declaration>
29 // CHECK: <Declaration>~A&lt;T&gt;()</Declaration>
30 
31 /**
32  * \Brief Eee
33 */
34 template <typename T> struct D : A<T> {
35 /**
36  * \brief
37 */
38   using A<T>::f;
39 
40   void f();
41 };
42 // CHECK: <Declaration>template &lt;typename T&gt; struct D :  A&lt;T&gt; {}</Declaration>
43 // CHECK: <Declaration>using A&lt;T&gt;::f</Declaration>
44 
45 struct Base {
46     int foo;
47 };
48 /**
49  * \brief
50 */
51 template<typename T> struct E : Base {
52 /**
53  * \brief
54 */
55   using Base::foo;
56 };
57 // CHECK: <Declaration>template &lt;typename T&gt; struct E :  Base {}</Declaration>
58 // CHECK: <Declaration>using Base::foo</Declaration>
59 
60 /// \tparam
61 /// \param AAA Blah blah
62 template<typename T>
63 void func_template_1(T AAA);
64 // CHECK: <Declaration>template &lt;typename T&gt; void func_template_1(T AAA)</Declaration>
65 
66 template<template<template<typename CCC> class DDD, class BBB> class AAA>
67 void func_template_2();
68 // FIXME: There is not Declaration field in the generated output.
69 
70 namespace rdar16128173 {
71 // CHECK: <Declaration>template &lt;class PtrTy&gt; class OpaquePtr {}</Declaration>
72 
73 /// \brief Wrapper for void* pointer.
74 /// \tparam PtrTy Either a pointer type like 'T*' or a type that behaves like
75 ///               a pointer.
76 template <class PtrTy>
77 class OpaquePtr {};
78 
79 // CHECK: <Declaration>typedef OpaquePtr&lt;int&gt; DeclGroupPtrTy</Declaration>
80 typedef OpaquePtr<int> DeclGroupPtrTy;
81 
82 DeclGroupPtrTy blah;
83 }
84