Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Driver / autocomplete.c
blobd6f57708b67eb6006a4224542fcb5255f00a9dfe
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.
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=-
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
38 // CLSTDALL: cl
39 // CLSTDALL-NEXT: CL
40 // CLSTDALL-NEXT: cl1.0
41 // CLSTDALL-NEXT: CL1.0
42 // CLSTDALL-NEXT: cl1.1
43 // CLSTDALL-NEXT: CL1.1
44 // CLSTDALL-NEXT: cl1.2
45 // CLSTDALL-NEXT: CL1.2
46 // CLSTDALL-NEXT: cl2.0
47 // CLSTDALL-NEXT: CL2.0
48 // CLSTDALL-NEXT: cl3.0
49 // CLSTDALL-NEXT: CL3.0
50 // CLSTDALL-NEXT: clc++
51 // CLSTDALL-NEXT: CLC++
52 // CLSTDALL-NEXT: clc++1.0
53 // CLSTDALL-NEXT: CLC++1.0
54 // CLSTDALL-NEXT: clc++2021
55 // CLSTDALL-NEXT: CLC++2021
56 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
57 // FNOSANICOVER: func
58 // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL
59 // FNOSANICOVERALL: 8bit-counters
60 // FNOSANICOVERALL-NEXT: bb
61 // FNOSANICOVERALL-NEXT: edge
62 // FNOSANICOVERALL-NEXT: func
63 // FNOSANICOVERALL-NEXT: indirect-calls
64 // FNOSANICOVERALL-NEXT: inline-8bit-counters
65 // FNOSANICOVERALL-NEXT: inline-bool-flag
66 // FNOSANICOVERALL-NEXT: no-prune
67 // FNOSANICOVERALL-NEXT: trace-bb
68 // FNOSANICOVERALL-NEXT: trace-cmp
69 // FNOSANICOVERALL-NEXT: trace-div
70 // FNOSANICOVERALL-NEXT: trace-gep
71 // FNOSANICOVERALL-NEXT: trace-pc
72 // FNOSANICOVERALL-NEXT: trace-pc-guard
73 // RUN: %clang --autocomplete=-ffp-contract= | FileCheck %s -check-prefix=FFPALL
74 // FFPALL: fast
75 // FFPALL-NEXT: fast-honor-pragmas
76 // FFPALL-NEXT: off
77 // FFPALL-NEXT: on
78 // RUN: %clang --autocomplete=-flto= | FileCheck %s -check-prefix=FLTOALL
79 // FLTOALL: full
80 // FLTOALL-NEXT: thin
81 // RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL
82 // FVECLIBALL: Accelerate
83 // FVECLIBALL-NEXT: ArmPL
84 // FVECLIBALL-NEXT: Darwin_libsystem_m
85 // FVECLIBALL-NEXT: libmvec
86 // FVECLIBALL-NEXT: MASSV
87 // FVECLIBALL-NEXT: none
88 // FVECLIBALL-NEXT: SLEEF
89 // FVECLIBALL-NEXT: SVML
90 // RUN: %clang --autocomplete=-fshow-overloads= | FileCheck %s -check-prefix=FSOVERALL
91 // FSOVERALL: all
92 // FSOVERALL-NEXT: best
93 // RUN: %clang --autocomplete=-fvisibility= | FileCheck %s -check-prefix=FVISIBILITYALL
94 // FVISIBILITYALL: default
95 // FVISIBILITYALL-NEXT: hidden
96 // RUN: %clang --autocomplete=-mfloat-abi= | FileCheck %s -check-prefix=MFLOATABIALL
97 // MFLOATABIALL: hard
98 // MFLOATABIALL-NEXT: soft
99 // MFLOATABIALL-NEXT: softfp
100 // RUN: %clang --autocomplete=-mthread-model | FileCheck %s -check-prefix=MTHREADMODELALL
101 // MTHREADMODELALL: posix
102 // MTHREADMODELALL-NEXT: single
103 // RUN: %clang --autocomplete=-mrelocation-model | FileCheck %s -check-prefix=MRELOCMODELALL
104 // MRELOCMODELALL: dynamic-no-pic
105 // MRELOCMODELALL-NEXT: pic
106 // MRELOCMODELALL-NEXT: ropi
107 // MRELOCMODELALL-NEXT: ropi-rwpi
108 // MRELOCMODELALL-NEXT: rwpi
109 // MRELOCMODELALL-NEXT: static
110 // RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
111 // WARNING: -Wmacro-redefined
112 // WARNING-NEXT: -Wmain
113 // WARNING-NEXT: -Wmain-return-type
114 // WARNING-NEXT: -Wmalformed-warning-check
115 // WARNING-NEXT: -Wmany-braces-around-scalar-init
116 // WARNING-NEXT: -Wmathematical-notation-identifier-extension
117 // WARNING-NEXT: -Wmax-tokens
118 // WARNING-NEXT: -Wmax-unsigned-zero
119 // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING
120 // NOWARNING: -Wno-invalid-pp-token
121 // RUN: %clang --autocomplete=-analyzer-checker | FileCheck %s -check-prefix=ANALYZER
122 // ANALYZER: unix.Malloc
123 // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STDVAL
124 // STDVAL: c99
126 // Clang shouldn't autocomplete CC1 options unless -cc1 or -Xclang were provided
127 // RUN: %clang --autocomplete=-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CLANG
128 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
129 // RUN: %clang --autocomplete=-Xclang,-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
130 // RUN: %clang --autocomplete=-cc1,-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
131 // MRELOCMODEL_CC1: -mrelocation-model
132 // Make sure it ignores passed flags unlesss they are -Xclang or -cc1
133 // RUN: %clang --autocomplete=foo,bar,,-fsyn | FileCheck %s -check-prefix=FSYN-CORON
134 // FSYN-CORON: -fsyntax-only
135 // Check if they can autocomplete values with coron
136 // RUN: %clang --autocomplete=foo,bar,,,-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER-CORON
137 // FNOSANICOVER-CORON: func
139 // Clang should return empty string when no value completion was found, which will fall back to file autocompletion
140 // RUN: %clang --autocomplete=-fmodule-file= | FileCheck %s -check-prefix=MODULE_FILE_EQUAL
141 // MODULE_FILE_EQUAL-NOT: -fmodule-file=
142 // RUN: %clang --autocomplete=-fmodule-file | FileCheck %s -check-prefix=MODULE_FILE
143 // MODULE_FILE: -fmodule-file=
145 // RUN: %clang --autocomplete=-Qunused-arguments, | FileCheck %s -check-prefix=QUNUSED_COMMA
146 // QUNUSED_COMMA-NOT: -Qunused-arguments
147 // RUN: %clang --autocomplete=-Qunused-arguments | FileCheck %s -check-prefix=QUNUSED
148 // QUNUSED: -Qunused-arguments