summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-doc/md-linkage.cpp
blob: 942ff35339fcb13905a6d33abdbf7edbb655e031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// THIS IS A GENERATED TEST. DO NOT EDIT.
// To regenerate, see clang-doc/gen_test.py docstring.
//
// REQUIRES: system-linux
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: echo "" > %t/compile_flags.txt
// RUN: cp "%s" "%t/test.cpp"

void function(int x);

inline int inlinedFunction(int x);

int functionWithInnerClass(int x) {
  class InnerClass { //NoLinkage
  public:
    int innerPublicMethod() { return 2; };
  }; //end class
  InnerClass temp;
  return temp.innerPublicMethod();
};

inline int inlinedFunctionWithInnerClass(int x) {
  class InnerClass { //VisibleNoLinkage
  public:
    int innerPublicMethod() { return 2; };
  }; //end class
  InnerClass temp;
  return temp.innerPublicMethod();
};

class Class {
public:
  void publicMethod();
  int publicField;

protected:
  void protectedMethod();
  int protectedField;

private:
  void privateMethod();
  int privateField;
};

namespace named {
class NamedClass {
public:
  void namedPublicMethod();
  int namedPublicField;

protected:
  void namedProtectedMethod();
  int namedProtectedField;

private:
  void namedPrivateMethod();
  int namedPrivateField;
};

void namedFunction();
static void namedStaticFunction();
inline void namedInlineFunction();
} // namespace named

static void staticFunction(int x); //Internal Linkage

static int staticFunctionWithInnerClass(int x) {
  class InnerClass { //NoLinkage
  public:
    int innerPublicMethod() { return 2; };
  }; //end class
  InnerClass temp;
  return temp.innerPublicMethod();
};

namespace {
class AnonClass {
public:
  void anonPublicMethod();
  int anonPublicField;

protected:
  void anonProtectedMethod();
  int anonProtectedField;

private:
  void anonPrivateMethod();
  int anonPrivateField;
};

void anonFunction();
static void anonStaticFunction();
inline void anonInlineFunction();
} // namespace

// RUN: clang-doc --format=md --doxygen --public --extra-arg=-fmodules-ts -p %t %t/test.cpp -output=%t/docs


// RUN: cat %t/docs/./Class.md | FileCheck %s --check-prefix CHECK-0
// CHECK-0: # class Class
// CHECK-0: *Defined at line 32 of test*
// CHECK-0: ## Members
// CHECK-0: int publicField
// CHECK-0: protected int protectedField
// CHECK-0: ## Functions
// CHECK-0: ### void publicMethod()
// CHECK-0: ### void protectedMethod()

// RUN: cat %t/docs/./named.md | FileCheck %s --check-prefix CHECK-1
// CHECK-1: # namespace named
// CHECK-1: ## Functions
// CHECK-1: ### void namedFunction()
// CHECK-1: ### void namedInlineFunction()

// RUN: cat %t/docs/./GlobalNamespace.md | FileCheck %s --check-prefix CHECK-2
// CHECK-2: # Global Namespace
// CHECK-2: ## Functions
// CHECK-2: ### void function(int x)
// CHECK-2: ### int inlinedFunction(int x)
// CHECK-2: ### int functionWithInnerClass(int x)
// CHECK-2: *Defined at line 14 of test*
// CHECK-2: ### int inlinedFunctionWithInnerClass(int x)
// CHECK-2: *Defined at line 23 of test*

// RUN: cat %t/docs/named/NamedClass.md | FileCheck %s --check-prefix CHECK-3
// CHECK-3: # class NamedClass
// CHECK-3: *Defined at line 47 of test*
// CHECK-3: ## Members
// CHECK-3: int namedPublicField
// CHECK-3: protected int namedProtectedField
// CHECK-3: ## Functions
// CHECK-3: ### void namedPublicMethod()
// CHECK-3: ### void namedProtectedMethod()
OpenPOWER on IntegriCloud