]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Driver/autocomplete.c
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / Driver / autocomplete.c
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 // MEABIALL: 4
30 // MEABIALL-NEXT: 5
31 // MEABIALL-NEXT: default
32 // MEABIALL-NEXT: gnu
33 // RUN: %clang --autocomplete=-cl-std=,CL2 | FileCheck %s -check-prefix=CLSTD
34 // CLSTD: CL2.0
35 // RUN: %clang --autocomplete=-cl-std= | FileCheck %s -check-prefix=CLSTDALL
36 // CLSTDALL: c++
37 // CLSTDALL-NEXT: cl
38 // CLSTDALL-NEXT: CL
39 // CLSTDALL-NEXT: cl1.1
40 // CLSTDALL-NEXT: CL1.1
41 // CLSTDALL-NEXT: cl1.2
42 // CLSTDALL-NEXT: CL1.2
43 // CLSTDALL-NEXT: cl2.0
44 // CLSTDALL-NEXT: CL2.0
45 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
46 // FNOSANICOVER: func
47 // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL
48 // FNOSANICOVERALL: 8bit-counters
49 // FNOSANICOVERALL-NEXT: bb
50 // FNOSANICOVERALL-NEXT: edge
51 // FNOSANICOVERALL-NEXT: func
52 // FNOSANICOVERALL-NEXT: indirect-calls
53 // FNOSANICOVERALL-NEXT: inline-8bit-counters
54 // FNOSANICOVERALL-NEXT: no-prune
55 // FNOSANICOVERALL-NEXT: trace-bb
56 // FNOSANICOVERALL-NEXT: trace-cmp
57 // FNOSANICOVERALL-NEXT: trace-div
58 // FNOSANICOVERALL-NEXT: trace-gep
59 // FNOSANICOVERALL-NEXT: trace-pc
60 // FNOSANICOVERALL-NEXT: trace-pc-guard
61 // RUN: %clang --autocomplete=-ffp-contract= | FileCheck %s -check-prefix=FFPALL
62 // FFPALL: fast
63 // FFPALL-NEXT: off
64 // FFPALL-NEXT: on
65 // RUN: %clang --autocomplete=-flto= | FileCheck %s -check-prefix=FLTOALL
66 // FLTOALL: full
67 // FLTOALL-NEXT: thin
68 // RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL
69 // FVECLIBALL: Accelerate
70 // FVECLIBALL-NEXT: none
71 // FVECLIBALL-NEXT: SVML
72 // RUN: %clang --autocomplete=-fshow-overloads= | FileCheck %s -check-prefix=FSOVERALL
73 // FSOVERALL: all
74 // FSOVERALL-NEXT: best
75 // RUN: %clang --autocomplete=-fvisibility= | FileCheck %s -check-prefix=FVISIBILITYALL
76 // FVISIBILITYALL: default
77 // FVISIBILITYALL-NEXT: hidden
78 // RUN: %clang --autocomplete=-mfloat-abi= | FileCheck %s -check-prefix=MFLOATABIALL
79 // MFLOATABIALL: hard
80 // MFLOATABIALL-NEXT: soft
81 // MFLOATABIALL-NEXT: softfp
82 // RUN: %clang --autocomplete=-mthread-model | FileCheck %s -check-prefix=MTHREADMODELALL
83 // MTHREADMODELALL: posix
84 // MTHREADMODELALL-NEXT: single
85 // RUN: %clang --autocomplete=-mrelocation-model | FileCheck %s -check-prefix=MRELOCMODELALL
86 // MRELOCMODELALL: dynamic-no-pic
87 // MRELOCMODELALL-NEXT: pic
88 // MRELOCMODELALL-NEXT: ropi
89 // MRELOCMODELALL-NEXT: ropi-rwpi
90 // MRELOCMODELALL-NEXT: rwpi
91 // MRELOCMODELALL-NEXT: static
92 // RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
93 // WARNING: -Wmacro-redefined
94 // WARNING-NEXT: -Wmain
95 // WARNING-NEXT: -Wmain-return-type
96 // WARNING-NEXT: -Wmalformed-warning-check
97 // WARNING-NEXT: -Wmany-braces-around-scalar-init
98 // WARNING-NEXT: -Wmax-unsigned-zero
99 // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING
100 // NOWARNING: -Wno-invalid-pp-token
101 // RUN: %clang --autocomplete=-analyzer-checker | FileCheck %s -check-prefix=ANALYZER
102 // ANALYZER: unix.Malloc
103 // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STDVAL
104 // STDVAL: c99
105 //
106 // Clang shouldn't autocomplete CC1 options unless -cc1 or -Xclang were provided
107 // RUN: %clang --autocomplete=-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CLANG
108 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
109 // RUN: %clang --autocomplete=-Xclang,-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
110 // RUN: %clang --autocomplete=-cc1,-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
111 // MRELOCMODEL_CC1: -mrelocation-model
112 // Make sure it ignores passed flags unlesss they are -Xclang or -cc1
113 // RUN: %clang --autocomplete=foo,bar,,-fsyn | FileCheck %s -check-prefix=FSYN-CORON
114 // FSYN-CORON: -fsyntax-only
115 // Check if they can autocomplete values with coron
116 // RUN: %clang --autocomplete=foo,bar,,,-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER-CORON
117 // FNOSANICOVER-CORON: func