1 | // Test for the --autocompletion flag, which is an API used for shell |
2 | // autocompletion. You may have to update tests in this file when you |
3 | // add/modify flags, change HelpTexts or the values of some flags. |
4 | |
5 | // Some corner cases. |
6 | // Just test that this doesn't crash: |
7 | // RUN: %clang --autocomplete= |
8 | // RUN: %clang --autocomplete=, |
9 | // RUN: %clang --autocomplete== |
10 | // RUN: %clang --autocomplete=,, |
11 | // RUN: %clang --autocomplete=- |
12 | |
13 | // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN |
14 | // FSYN: -fsyntax-only |
15 | // RUN: %clang --autocomplete=-std | FileCheck %s -check-prefix=STD |
16 | // STD: -std= Language standard to compile for |
17 | // RUN: %clang --autocomplete=foo | FileCheck %s -check-prefix=FOO |
18 | // FOO-NOT: foo |
19 | // RUN: %clang --autocomplete=-stdlib=,l | FileCheck %s -check-prefix=STDLIB |
20 | // STDLIB: libc++ |
21 | // STDLIB-NEXT: libstdc++ |
22 | // RUN: %clang --autocomplete=-stdlib= | FileCheck %s -check-prefix=STDLIBALL |
23 | // STDLIBALL: libc++ |
24 | // STDLIBALL-NEXT: libstdc++ |
25 | // STDLIBALL-NEXT: platform |
26 | // RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI |
27 | // MEABI: default |
28 | // RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL |
29 | // RUN: %clang --autocomplete=-meabi | FileCheck %s -check-prefix=MEABIALL |
30 | // MEABIALL: 4 |
31 | // MEABIALL-NEXT: 5 |
32 | // MEABIALL-NEXT: default |
33 | // MEABIALL-NEXT: gnu |
34 | // RUN: %clang --autocomplete=-cl-std=,CL2 | FileCheck %s -check-prefix=CLSTD |
35 | // CLSTD: CL2.0 |
36 | // RUN: %clang --autocomplete=-cl-std= | FileCheck %s -check-prefix=CLSTDALL |
37 | // CLSTDALL: c++ |
38 | // CLSTDALL-NEXT: cl |
39 | // CLSTDALL-NEXT: CL |
40 | // CLSTDALL-NEXT: cl1.1 |
41 | // CLSTDALL-NEXT: CL1.1 |
42 | // CLSTDALL-NEXT: cl1.2 |
43 | // CLSTDALL-NEXT: CL1.2 |
44 | // CLSTDALL-NEXT: cl2.0 |
45 | // CLSTDALL-NEXT: CL2.0 |
46 | // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER |
47 | // FNOSANICOVER: func |
48 | // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL |
49 | // FNOSANICOVERALL: 8bit-counters |
50 | // FNOSANICOVERALL-NEXT: bb |
51 | // FNOSANICOVERALL-NEXT: edge |
52 | // FNOSANICOVERALL-NEXT: func |
53 | // FNOSANICOVERALL-NEXT: indirect-calls |
54 | // FNOSANICOVERALL-NEXT: inline-8bit-counters |
55 | // FNOSANICOVERALL-NEXT: no-prune |
56 | // FNOSANICOVERALL-NEXT: trace-bb |
57 | // FNOSANICOVERALL-NEXT: trace-cmp |
58 | // FNOSANICOVERALL-NEXT: trace-div |
59 | // FNOSANICOVERALL-NEXT: trace-gep |
60 | // FNOSANICOVERALL-NEXT: trace-pc |
61 | // FNOSANICOVERALL-NEXT: trace-pc-guard |
62 | // RUN: %clang --autocomplete=-ffp-contract= | FileCheck %s -check-prefix=FFPALL |
63 | // FFPALL: fast |
64 | // FFPALL-NEXT: off |
65 | // FFPALL-NEXT: on |
66 | // RUN: %clang --autocomplete=-flto= | FileCheck %s -check-prefix=FLTOALL |
67 | // FLTOALL: full |
68 | // FLTOALL-NEXT: thin |
69 | // RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL |
70 | // FVECLIBALL: Accelerate |
71 | // FVECLIBALL-NEXT: none |
72 | // FVECLIBALL-NEXT: SVML |
73 | // RUN: %clang --autocomplete=-fshow-overloads= | FileCheck %s -check-prefix=FSOVERALL |
74 | // FSOVERALL: all |
75 | // FSOVERALL-NEXT: best |
76 | // RUN: %clang --autocomplete=-fvisibility= | FileCheck %s -check-prefix=FVISIBILITYALL |
77 | // FVISIBILITYALL: default |
78 | // FVISIBILITYALL-NEXT: hidden |
79 | // RUN: %clang --autocomplete=-mfloat-abi= | FileCheck %s -check-prefix=MFLOATABIALL |
80 | // MFLOATABIALL: hard |
81 | // MFLOATABIALL-NEXT: soft |
82 | // MFLOATABIALL-NEXT: softfp |
83 | // RUN: %clang --autocomplete=-mthread-model | FileCheck %s -check-prefix=MTHREADMODELALL |
84 | // MTHREADMODELALL: posix |
85 | // MTHREADMODELALL-NEXT: single |
86 | // RUN: %clang --autocomplete=-mrelocation-model | FileCheck %s -check-prefix=MRELOCMODELALL |
87 | // MRELOCMODELALL: dynamic-no-pic |
88 | // MRELOCMODELALL-NEXT: pic |
89 | // MRELOCMODELALL-NEXT: ropi |
90 | // MRELOCMODELALL-NEXT: ropi-rwpi |
91 | // MRELOCMODELALL-NEXT: rwpi |
92 | // MRELOCMODELALL-NEXT: static |
93 | // RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING |
94 | // WARNING: -Wmacro-redefined |
95 | // WARNING-NEXT: -Wmain |
96 | // WARNING-NEXT: -Wmain-return-type |
97 | // WARNING-NEXT: -Wmalformed-warning-check |
98 | // WARNING-NEXT: -Wmany-braces-around-scalar-init |
99 | // WARNING-NEXT: -Wmax-unsigned-zero |
100 | // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING |
101 | // NOWARNING: -Wno-invalid-pp-token |
102 | // RUN: %clang --autocomplete=-analyzer-checker | FileCheck %s -check-prefix=ANALYZER |
103 | // ANALYZER: unix.Malloc |
104 | // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STDVAL |
105 | // STDVAL: c99 |
106 | // |
107 | // Clang shouldn't autocomplete CC1 options unless -cc1 or -Xclang were provided |
108 | // RUN: %clang --autocomplete=-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CLANG |
109 | // MRELOCMODEL_CLANG-NOT: -mrelocation-model |
110 | // RUN: %clang --autocomplete=-Xclang,-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1 |
111 | // RUN: %clang --autocomplete=-cc1,-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1 |
112 | // MRELOCMODEL_CC1: -mrelocation-model |
113 | // Make sure it ignores passed flags unlesss they are -Xclang or -cc1 |
114 | // RUN: %clang --autocomplete=foo,bar,,-fsyn | FileCheck %s -check-prefix=FSYN-CORON |
115 | // FSYN-CORON: -fsyntax-only |
116 | // Check if they can autocomplete values with coron |
117 | // RUN: %clang --autocomplete=foo,bar,,,-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER-CORON |
118 | // FNOSANICOVER-CORON: func |
119 | |
120 | // Clang should return empty string when no value completion was found, which will fall back to file autocompletion |
121 | // RUN: %clang --autocomplete=-fmodule-file= | FileCheck %s -check-prefix=MODULE_FILE_EQUAL |
122 | // MODULE_FILE_EQUAL-NOT: -fmodule-file= |
123 | // RUN: %clang --autocomplete=-fmodule-file | FileCheck %s -check-prefix=MODULE_FILE |
124 | // MODULE_FILE: -fmodule-file= |
125 | |
126 | // RUN: %clang --autocomplete=-Qunused-arguments, | FileCheck %s -check-prefix=QUNUSED_COMMA |
127 | // QUNUSED_COMMA-NOT: -Qunused-arguments |
128 | // RUN: %clang --autocomplete=-Qunused-arguments | FileCheck %s -check-prefix=QUNUSED |
129 | // QUNUSED: -Qunused-arguments |
130 | |