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 // RUN: %clang --autocomplete= | FileCheck %s -check-prefix=ALL_FLAGS
7 // RUN: %clang --autocomplete=# | FileCheck %s -check-prefix=ALL_FLAGS
8 // Let's pick some example flags that are hopefully unlikely to change.
9 // ALL_FLAGS: -fast
10 // ALL_FLAGS: -fastcp
11 // ALL_FLAGS: -fastf
12 // Just test that this doesn't crash:
13 // RUN: %clang --autocomplete=,
14 // RUN: %clang --autocomplete==
15 // RUN: %clang --autocomplete=,,
16 // RUN: %clang --autocomplete=-
17 
18 // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN
19 // FSYN: -fsyntax-only
20 // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
21 // STD: -std= Language standard to compile for
22 // RUN: %clang --autocomplete=foo | FileCheck %s -check-prefix=FOO
23 // FOO-NOT: foo
24 // RUN: %clang --autocomplete=-stdlib=,l | FileCheck %s -check-prefix=STDLIB
25 // STDLIB: libc++
26 // STDLIB-NEXT: libstdc++
27 // RUN: %clang --autocomplete=-stdlib=, | FileCheck %s -check-prefix=STDLIBALL
28 // STDLIBALL: libc++
29 // STDLIBALL-NEXT: libstdc++
30 // STDLIBALL-NEXT: platform
31 // RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI
32 // MEABI: default
33 // RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL
34 // MEABIALL: 4
35 // MEABIALL-NEXT: 5
36 // MEABIALL-NEXT: default
37 // MEABIALL-NEXT: gnu
38 // RUN: %clang --autocomplete=-cl-std=,CL2 | FileCheck %s -check-prefix=CLSTD
39 // CLSTD: CL2.0
40 // RUN: %clang --autocomplete=-cl-std=, | FileCheck %s -check-prefix=CLSTDALL
41 // CLSTDALL: cl
42 // CLSTDALL-NEXT: CL
43 // CLSTDALL-NEXT: cl1.1
44 // CLSTDALL-NEXT: CL1.1
45 // CLSTDALL-NEXT: cl1.2
46 // CLSTDALL-NEXT: CL1.2
47 // CLSTDALL-NEXT: cl2.0
48 // CLSTDALL-NEXT: CL2.0
49 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
50 // FNOSANICOVER: func
51 // RUN: %clang --autocomplete=-fno-sanitize-coverage=, | FileCheck %s -check-prefix=FNOSANICOVERALL
52 // FNOSANICOVERALL: 8bit-counters
53 // FNOSANICOVERALL-NEXT: bb
54 // FNOSANICOVERALL-NEXT: edge
55 // FNOSANICOVERALL-NEXT: func
56 // FNOSANICOVERALL-NEXT: indirect-calls
57 // FNOSANICOVERALL-NEXT: inline-8bit-counters
58 // FNOSANICOVERALL-NEXT: no-prune
59 // FNOSANICOVERALL-NEXT: trace-bb
60 // FNOSANICOVERALL-NEXT: trace-cmp
61 // FNOSANICOVERALL-NEXT: trace-div
62 // FNOSANICOVERALL-NEXT: trace-gep
63 // FNOSANICOVERALL-NEXT: trace-pc
64 // FNOSANICOVERALL-NEXT: trace-pc-guard
65 // RUN: %clang --autocomplete=-ffp-contract=, | FileCheck %s -check-prefix=FFPALL
66 // FFPALL: fast
67 // FFPALL-NEXT: off
68 // FFPALL-NEXT: on
69 // RUN: %clang --autocomplete=-flto=, | FileCheck %s -check-prefix=FLTOALL
70 // FLTOALL: full
71 // FLTOALL-NEXT: thin
72 // RUN: %clang --autocomplete=-fveclib=, | FileCheck %s -check-prefix=FVECLIBALL
73 // FVECLIBALL: Accelerate
74 // FVECLIBALL-NEXT: none
75 // FVECLIBALL-NEXT: SVML
76 // RUN: %clang --autocomplete=-fshow-overloads=, | FileCheck %s -check-prefix=FSOVERALL
77 // FSOVERALL: all
78 // FSOVERALL-NEXT: best
79 // RUN: %clang --autocomplete=-fvisibility=, | FileCheck %s -check-prefix=FVISIBILITYALL
80 // FVISIBILITYALL: default
81 // FVISIBILITYALL-NEXT: hidden
82 // RUN: %clang --autocomplete=-mfloat-abi=, | FileCheck %s -check-prefix=MFLOATABIALL
83 // MFLOATABIALL: hard
84 // MFLOATABIALL-NEXT: soft
85 // MFLOATABIALL-NEXT: softfp
86 // RUN: %clang --autocomplete=-mthread-model, | FileCheck %s -check-prefix=MTHREADMODELALL
87 // MTHREADMODELALL: posix
88 // MTHREADMODELALL-NEXT: single
89 // RUN: %clang --autocomplete=-mrelocation-model, | FileCheck %s -check-prefix=MRELOCMODELALL
90 // MRELOCMODELALL: dynamic-no-pic
91 // MRELOCMODELALL-NEXT: pic
92 // MRELOCMODELALL-NEXT: ropi
93 // MRELOCMODELALL-NEXT: ropi-rwpi
94 // MRELOCMODELALL-NEXT: rwpi
95 // MRELOCMODELALL-NEXT: static
96 // RUN: %clang --autocomplete=-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CLANG
97 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
98 // RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
99 // MRELOCMODEL_CC1: -mrelocation-model
100 // RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
101 // WARNING: -Wmacro-redefined
102 // WARNING-NEXT: -Wmain
103 // WARNING-NEXT: -Wmain-return-type
104 // WARNING-NEXT: -Wmalformed-warning-check
105 // WARNING-NEXT: -Wmany-braces-around-scalar-init
106 // WARNING-NEXT: -Wmax-unsigned-zero
107 // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING
108 // NOWARNING: -Wno-invalid-pp-token
109 // RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s -check-prefix=ANALYZER
110 // ANALYZER: unix.Malloc
111 // RUN: %clang --autocomplete=-std=, | FileCheck %s -check-prefix=STDVAL
112 // STDVAL: c99
113