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