Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeCompletion / patterns.cpp
blob9d18ced8aa6d12b671a054c3eed582acb834b26a
1 void loops() {
2 while (true) {
3 // line 3
5 for (;;) {
6 // line 6
8 do {
9 // line 9
10 } while (true);
11 // line 11
13 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:3:1 %s -o - | FileCheck -check-prefix=LOOP %s
14 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:6:1 %s -o - | FileCheck -check-prefix=LOOP %s
15 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:9:1 %s -o - | FileCheck -check-prefix=LOOP %s
16 // LOOP: COMPLETION: Pattern : break;{{$}}
17 // LOOP: COMPLETION: Pattern : continue;{{$}}
18 // LOOP: COMPLETION: Pattern : goto <#label#>;{{$}}
19 // LOOP: COMPLETION: Pattern : return;{{$}}
21 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:1 %s -o - | FileCheck -check-prefix=OUTSIDE-LOOP %s
22 // OUTSIDE-LOOP-NOT: COMPLETION: Pattern : break;{{$}}
23 // OUTSIDE-LOOP-NOT: COMPLETION: Pattern : continue;{{$}}
24 // OUTSIDE-LOOP: COMPLETION: Pattern : goto <#label#>;{{$}}
25 // OUTSIDE-LOOP: COMPLETION: Pattern : return;{{$}}
27 int value_return() {
28 // line 28
30 void void_return() {
31 // line 31
33 bool bool_return() {
34 // line 34
36 int *ptr_return() {
37 // line 37
39 struct Cls {};
40 int Cls::*memptr_return() {
41 // line 41
43 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:28:1 %s -o - | FileCheck -check-prefix=RETURN-VAL %s
44 // RETURN-VAL-NOT: COMPLETION: Pattern : return;
45 // RETURN-VAL-NOT: COMPLETION: Pattern : return false;
46 // RETURN-VAL-NOT: COMPLETION: Pattern : return true;
47 // RETURN-VAL-NOT: COMPLETION: Pattern : return nullptr;
48 // RETURN-VAL: COMPLETION: Pattern : return <#expression#>;{{$}}
50 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:31:1 %s -o - | FileCheck -check-prefix=RETURN-VOID %s
51 // RETURN-VOID-NOT: COMPLETION: Pattern : return false;
52 // RETURN-VOID-NOT: COMPLETION: Pattern : return true;
53 // RETURN-VOID-NOT: COMPLETION: Pattern : return <#expression#>;
54 // RETURN-VOID-NOT: COMPLETION: Pattern : return nullptr;
55 // RETURN-VOID: COMPLETION: Pattern : return;{{$}}
57 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:34:1 %s -o - | FileCheck -check-prefix=RETURN-BOOL %s
58 // RETURN-BOOL-NOT: COMPLETION: Pattern : return;
59 // RETURN-BOOL-NOT: COMPLETION: Pattern : return nullptr;
60 // RETURN-BOOL: COMPLETION: Pattern : return <#expression#>;{{$}}
61 // RETURN-BOOL: COMPLETION: Pattern : return false;{{$}}
62 // RETURN-BOOL: COMPLETION: Pattern : return true;{{$}}
64 // Check both pointer and member pointer return types.
65 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-patterns -code-completion-at=%s:37:1 %s -o - | FileCheck -check-prefix=RETURN-PTR %s
66 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-patterns -code-completion-at=%s:41:1 %s -o - | FileCheck -check-prefix=RETURN-PTR %s
67 // RETURN-PTR-NOT: COMPLETION: Pattern : return false;{{$}}
68 // RETURN-PTR-NOT: COMPLETION: Pattern : return true;{{$}}
69 // RETURN-PTR-NOT: COMPLETION: Pattern : return;
70 // RETURN-PTR: COMPLETION: Pattern : return <#expression#>;{{$}}
71 // RETURN-PTR: COMPLETION: Pattern : return nullptr;
73 // 'return nullptr' is not available before C++11.
74 // RUN: %clang_cc1 -fsyntax-only -std=c++03 -code-completion-patterns -code-completion-at=%s:37:1 %s -o - | FileCheck -check-prefix=RETURN-PTR-STD03 %s
75 // RUN: %clang_cc1 -fsyntax-only -std=c++03 -code-completion-patterns -code-completion-at=%s:41:1 %s -o - | FileCheck -check-prefix=RETURN-PTR-STD03 %s
76 // RETURN-PTR-STD03-NOT: COMPLETION: Pattern : return nullptr;
78 void something();
80 void unbraced_if() {
81 if (true)
82 something();
83 // line 83
85 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:83:3 %s -o - | FileCheck -check-prefix=UNBRACED-IF %s
86 // UNBRACED-IF: COMPLETION: Pattern : else
87 // UNBRACED-IF-NEXT: <#statement#>;
88 // UNBRACED-IF: COMPLETION: Pattern : else if (<#condition#>)
89 // UNBRACED-IF-NEXT: <#statement#>;
91 void braced_if() {
92 if (true) {
93 something();
95 // line 95
97 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:95:3 %s -o - | FileCheck -check-prefix=BRACED-IF %s
98 // BRACED-IF: COMPLETION: Pattern : else {
99 // BRACED-IF-NEXT: <#statements#>
100 // BRACED-IF-NEXT: }
101 // BRACED-IF: COMPLETION: Pattern : else if (<#condition#>) {
102 // BRACED-IF-NEXT: <#statements#>
103 // BRACED-IF-NEXT: }