| 1 |
// Check to make sure clang is somewhat picky about -g options. |
| 2 |
|
| 3 |
// Linux. |
| 4 |
// RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \ |
| 5 |
// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s |
| 6 |
// RUN: %clang -### -c -g2 %s -target x86_64-linux-gnu 2>&1 \ |
| 7 |
// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s |
| 8 |
// RUN: %clang -### -c -g3 %s -target x86_64-linux-gnu 2>&1 \ |
| 9 |
// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s |
| 10 |
// RUN: %clang -### -c -ggdb %s -target x86_64-linux-gnu 2>&1 \ |
| 11 |
// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s |
| 12 |
// RUN: %clang -### -c -ggdb1 %s -target x86_64-linux-gnu 2>&1 \ |
| 13 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_GDB %s |
| 14 |
// RUN: %clang -### -c -ggdb3 %s -target x86_64-linux-gnu 2>&1 \ |
| 15 |
// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s |
| 16 |
// RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \ |
| 17 |
// RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_LLDB %s |
| 18 |
// RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \ |
| 19 |
// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_SCE %s |
| 20 |
// RUN: %clang -### -c -gdbx %s -target x86_64-linux-gnu 2>&1 \ |
| 21 |
// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s |
| 22 |
|
| 23 |
// Android. |
| 24 |
// Android should always generate DWARF4. |
| 25 |
// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \ |
| 26 |
// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DWARF4 %s |
| 27 |
|
| 28 |
// Darwin. |
| 29 |
// RUN: %clang -### -c -g %s -target x86_64-apple-darwin14 2>&1 \ |
| 30 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 31 |
// RUN: -check-prefix=G_DWARF2 \ |
| 32 |
// RUN: -check-prefix=G_LLDB %s |
| 33 |
// RUN: %clang -### -c -g %s -target x86_64-apple-darwin16 2>&1 \ |
| 34 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 35 |
// RUN: -check-prefix=G_DWARF4 \ |
| 36 |
// RUN: -check-prefix=G_LLDB %s |
| 37 |
// RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin16 2>&1 \ |
| 38 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 39 |
// RUN: -check-prefix=G_DWARF4 %s |
| 40 |
// RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin16 2>&1 \ |
| 41 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 42 |
// RUN: -check-prefix=G_DWARF4 %s |
| 43 |
// RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin16 2>&1 \ |
| 44 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 45 |
// RUN: -check-prefix=G_DWARF4 \ |
| 46 |
// RUN: -check-prefix=G_GDB %s |
| 47 |
// RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin16 2>&1 \ |
| 48 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s |
| 49 |
// RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin16 2>&1 \ |
| 50 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 51 |
// RUN: -check-prefix=G_DWARF4 %s |
| 52 |
// RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.11 2>&1 \ |
| 53 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 54 |
// RUN: -check-prefix=G_DWARF4 %s |
| 55 |
// RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.10 2>&1 \ |
| 56 |
// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s |
| 57 |
// RUN: %clang -### -c -g %s -target armv7-apple-ios9.0 2>&1 \ |
| 58 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 59 |
// RUN: -check-prefix=G_DWARF4 %s |
| 60 |
// RUN: %clang -### -c -g %s -target armv7-apple-ios8.0 2>&1 \ |
| 61 |
// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s |
| 62 |
// RUN: %clang -### -c -g %s -target armv7k-apple-watchos 2>&1 \ |
| 63 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 64 |
// RUN: -check-prefix=G_DWARF4 %s |
| 65 |
// RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \ |
| 66 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 67 |
// RUN: -check-prefix=G_DWARF4 %s |
| 68 |
// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \ |
| 69 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 70 |
// RUN: -check-prefix=G_DWARF4 %s |
| 71 |
// RUN: %clang -### -c -g %s -target x86_64-apple-macosx15 2>&1 \ |
| 72 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 73 |
// RUN: -check-prefix=G_DWARF5 %s |
| 74 |
// RUN: %clang -### -c -g %s -target arm64-apple-ios17.0 2>&1 \ |
| 75 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 76 |
// RUN: -check-prefix=G_DWARF4 %s |
| 77 |
// RUN: %clang -### -c -g %s -target arm64-apple-ios18.0 2>&1 \ |
| 78 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 79 |
// RUN: -check-prefix=G_DWARF5 %s |
| 80 |
// RUN: %clang -### -c -g %s -target arm64_32-apple-watchos11 2>&1 \ |
| 81 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 82 |
// RUN: -check-prefix=G_DWARF5 %s |
| 83 |
// RUN: %clang -### -c -g %s -target arm64-apple-tvos18.0 2>&1 \ |
| 84 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 85 |
// RUN: -check-prefix=G_DWARF5 %s |
| 86 |
// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit24.0 2>&1 \ |
| 87 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 88 |
// RUN: -check-prefix=G_DWARF5 %s |
| 89 |
// RUN: %clang -### -c -g %s -target arm64-apple-xros1 2>&1 \ |
| 90 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 91 |
// RUN: -check-prefix=G_DWARF4 %s |
| 92 |
// RUN: %clang -### -c -g %s -target arm64-apple-xros2 2>&1 \ |
| 93 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 94 |
// RUN: -check-prefix=G_DWARF5 %s |
| 95 |
// |
| 96 |
// RUN: %clang -### -c -fsave-optimization-record %s \ |
| 97 |
// RUN: -target x86_64-apple-darwin 2>&1 \ |
| 98 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s |
| 99 |
// RUN: %clang -### -c -g -fsave-optimization-record %s \ |
| 100 |
// RUN: -target x86_64-apple-darwin 2>&1 \ |
| 101 |
// RUN: | FileCheck -check-prefix=G_STANDALONE %s |
| 102 |
|
| 103 |
// FreeBSD. |
| 104 |
// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd 2>&1 \ |
| 105 |
// RUN: | FileCheck -check-prefix=G_GDB \ |
| 106 |
// RUN: -check-prefix=G_DWARF4 %s |
| 107 |
|
| 108 |
// Haiku. |
| 109 |
// RUN: %clang -### -c -g %s --target=x86_64-unknown-haiku 2>&1 \ |
| 110 |
// RUN: | FileCheck -check-prefix=G_STANDALONE \ |
| 111 |
// RUN: -check-prefix=G_DWARF4 %s |
| 112 |
|
| 113 |
// Windows. |
| 114 |
// RUN: %clang -### -c -g %s -target x86_64-w64-windows-gnu 2>&1 \ |
| 115 |
// RUN: | FileCheck -check-prefix=G_GDB %s |
| 116 |
// RUN: %clang -### -c -g %s -target x86_64-windows-msvc 2>&1 \ |
| 117 |
// RUN: | FileCheck -check-prefix=G_NOTUNING %s |
| 118 |
// RUN: %clang_cl -### -c -Z7 -target x86_64-windows-msvc -- %s 2>&1 \ |
| 119 |
// RUN: | FileCheck -check-prefix=G_NOTUNING %s |
| 120 |
|
| 121 |
// On the PS4/PS5, -g defaults to -gno-column-info. We default to always |
| 122 |
// generating the arange section, but keyed off SCE DebuggerTuning being in |
| 123 |
// play during codegen, instead of -generate-arange-section. |
| 124 |
// RUN: %clang -### -c %s -target x86_64-scei-ps4 2>&1 \ |
| 125 |
// RUN: | FileCheck -check-prefix=NOG_PS %s |
| 126 |
// RUN: %clang -### -c %s -target x86_64-sie-ps5 2>&1 \ |
| 127 |
// RUN: | FileCheck -check-prefix=NOG_PS %s |
| 128 |
/// PS4 will stay on v4 even if the generic default version changes. |
| 129 |
// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \ |
| 130 |
// RUN: | FileCheck -check-prefixes=G_DWARF4,G_SCE,NOCI,FWD_TMPL_PARAMS %s |
| 131 |
// RUN: %clang -### -c %s -g -target x86_64-sie-ps5 2>&1 \ |
| 132 |
// RUN: | FileCheck -check-prefixes=G_DWARF5,G_SCE,NOCI,FWD_TMPL_PARAMS %s |
| 133 |
// RUN: %clang -### -c %s -g -gcolumn-info -target x86_64-scei-ps4 2>&1 \ |
| 134 |
// RUN: | FileCheck -check-prefix=CI %s |
| 135 |
// RUN: %clang -### -c %s -gsce -target x86_64-unknown-linux 2>&1 \ |
| 136 |
// RUN: | FileCheck -check-prefix=NOCI %s |
| 137 |
// RUN: %clang -### %s -g -flto=thin -target x86_64-scei-ps4 2>&1 \ |
| 138 |
// RUN: | FileCheck -check-prefix=LDGARANGE %s |
| 139 |
// RUN: %clang -### %s -g -flto=full -target x86_64-scei-ps4 2>&1 \ |
| 140 |
// RUN: | FileCheck -check-prefix=LDGARANGE %s |
| 141 |
// RUN: %clang -### %s -g -flto -target x86_64-sie-ps5 2>&1 \ |
| 142 |
// RUN: | FileCheck -check-prefix=LDGARANGE %s |
| 143 |
// RUN: %clang -### %s -g -target x86_64-sie-ps5 2>&1 \ |
| 144 |
// RUN: | FileCheck -check-prefix=LDGARANGE %s |
| 145 |
|
| 146 |
// On the AIX, -g defaults to limited debug info. |
| 147 |
// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \ |
| 148 |
// RUN: | FileCheck -check-prefix=G_LIMITED %s |
| 149 |
// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \ |
| 150 |
// RUN: | FileCheck -check-prefix=G_LIMITED %s |
| 151 |
// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \ |
| 152 |
// RUN: | FileCheck -check-prefix=G_NOTUNING %s |
| 153 |
// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \ |
| 154 |
// RUN: | FileCheck -check-prefix=G_NOTUNING %s |
| 155 |
// RUN: %clang -### -c -g -gdbx %s -target powerpc-ibm-aix-xcoff 2>&1 \ |
| 156 |
// RUN: | FileCheck -check-prefixes=G_LIMITED,G_DBX %s |
| 157 |
// RUN: %clang -### -c -g -gdbx %s -target powerpc64-ibm-aix-xcoff 2>&1 \ |
| 158 |
// RUN: | FileCheck -check-prefixes=G_LIMITED,G_DBX %s |
| 159 |
|
| 160 |
// For DBX, -g defaults to -gstrict-dwarf. |
| 161 |
// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \ |
| 162 |
// RUN: | FileCheck -check-prefix=STRICT %s |
| 163 |
// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \ |
| 164 |
// RUN: | FileCheck -check-prefix=STRICT %s |
| 165 |
// RUN: %clang -### -c -g -gno-strict-dwarf %s -target powerpc-ibm-aix-xcoff \ |
| 166 |
// RUN: 2>&1 | FileCheck -check-prefix=NOSTRICT %s |
| 167 |
// RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \ |
| 168 |
// RUN: | FileCheck -check-prefix=NOSTRICT %s |
| 169 |
// RUN: %clang -### -c -g -ggdb %s -target powerpc-ibm-aix-xcoff 2>&1 \ |
| 170 |
// RUN: | FileCheck -check-prefix=NOSTRICT %s |
| 171 |
|
| 172 |
// On the AIX, -g defaults to -gno-column-info. |
| 173 |
// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \ |
| 174 |
// RUN: | FileCheck -check-prefix=NOCI %s |
| 175 |
// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \ |
| 176 |
// RUN: | FileCheck -check-prefix=NOCI %s |
| 177 |
// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff -gcolumn-info 2>&1 \ |
| 178 |
// RUN: | FileCheck -check-prefix=CI %s |
| 179 |
// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff -gcolumn-info \ |
| 180 |
// RUN: 2>&1 | FileCheck -check-prefix=CI %s |
| 181 |
|
| 182 |
// WebAssembly. |
| 183 |
// WebAssembly should default to DWARF4. |
| 184 |
// RUN: %clang -### -c -g %s -target wasm32 2>&1 \ |
| 185 |
// RUN: | FileCheck -check-prefix=G_DWARF4 %s |
| 186 |
// RUN: %clang -### -c -g %s -target wasm64 2>&1 \ |
| 187 |
// RUN: | FileCheck -check-prefix=G_DWARF4 %s |
| 188 |
|
| 189 |
// RUN: %clang -### -c -gdwarf-2 %s 2>&1 \ |
| 190 |
// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s |
| 191 |
// |
| 192 |
// RUN: not %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_ERR %s |
| 193 |
// RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s |
| 194 |
// RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s |
| 195 |
// RUN: %clang -### -c -glldb -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s |
| 196 |
// RUN: %clang -### -c -glldb -g1 %s 2>&1 \ |
| 197 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_LLDB %s |
| 198 |
// |
| 199 |
// PS4 defaults to sce; -ggdb0 changes tuning but turns off debug info, |
| 200 |
// then -g turns it back on without affecting tuning. |
| 201 |
// RUN: %clang -### -c -ggdb0 -g -target x86_64-scei-ps4 %s 2>&1 \ |
| 202 |
// RUN: | FileCheck -check-prefix=G_GDB %s |
| 203 |
// |
| 204 |
// RUN: %clang -### -c -g1 %s 2>&1 \ |
| 205 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s |
| 206 |
// RUN: %clang -### -c -gmlt %s 2>&1 \ |
| 207 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s |
| 208 |
// RUN: %clang -### -c -gline-tables-only %s 2>&1 \ |
| 209 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s |
| 210 |
// RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \ |
| 211 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s |
| 212 |
// RUN: %clang -### -c -gline-tables-only %s -target i686-pc-openbsd 2>&1 \ |
| 213 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s |
| 214 |
// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \ |
| 215 |
// RUN: | FileCheck -check-prefix=G_ONLY %s |
| 216 |
// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 2>&1 \ |
| 217 |
// RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s |
| 218 |
// RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \ |
| 219 |
// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s |
| 220 |
// RUN: %clang -### -c -gline-tables-only -g %s --target=i386-pc-solaris 2>&1 \ |
| 221 |
// RUN: | FileCheck -check-prefix=G_ONLY %s |
| 222 |
// RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \ |
| 223 |
// RUN: | FileCheck -check-prefix=GLTO_NO %s |
| 224 |
// |
| 225 |
// RUN: %clang -### -c -gline-directives-only %s -target x86_64-apple-darwin 2>&1 \ |
| 226 |
// RUN: | FileCheck -check-prefix=GLIO_ONLY %s |
| 227 |
// RUN: %clang -### -c -gline-directives-only %s -target i686-pc-openbsd 2>&1 \ |
| 228 |
// RUN: | FileCheck -check-prefix=GLIO_ONLY_DWARF2 %s |
| 229 |
// RUN: %clang -### -c -gline-directives-only -g %s -target x86_64-linux-gnu 2>&1 \ |
| 230 |
// RUN: | FileCheck -check-prefix=G_ONLY %s |
| 231 |
// RUN: %clang -### -c -gline-directives-only -g %s -target x86_64-apple-darwin16 2>&1 \ |
| 232 |
// RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s |
| 233 |
// RUN: %clang -### -c -gline-directives-only -g %s -target i686-pc-openbsd 2>&1 \ |
| 234 |
// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s |
| 235 |
// RUN: %clang -### -c -gline-directives-only -g %s --target=i386-pc-solaris 2>&1 \ |
| 236 |
// RUN: | FileCheck -check-prefix=G_ONLY %s |
| 237 |
// RUN: %clang -### -c -gline-directives-only -g0 %s 2>&1 \ |
| 238 |
// RUN: | FileCheck -check-prefix=GLIO_NO %s |
| 239 |
|
| 240 |
// RUN: %clang -### -c -grecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=GRECORD %s |
| 241 |
// RUN: %clang -### -c -gno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=GNO_RECORD %s |
| 242 |
// RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=GNO_RECORD %s |
| 243 |
// RUN: %clang -### -c -grecord-gcc-switches -o - %s 2>&1 | FileCheck -check-prefix=GRECORD_O %s |
| 244 |
// RUN: %clang -### -c -O3 -ffunction-sections -grecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=GRECORD_OPT %s |
| 245 |
|
| 246 |
// RUN: %clang -### -c -grecord-command-line %s 2>&1 | FileCheck -check-prefix=GRECORD %s |
| 247 |
// RUN: %clang -### -c -gno-record-command-line %s 2>&1 | FileCheck -check-prefix=GNO_RECORD %s |
| 248 |
// RUN: %clang -### -c -grecord-command-line -gno-record-command-line %s 2>&1 | FileCheck -check-prefix=GNO_RECORD %s |
| 249 |
// RUN: %clang -### -c -grecord-command-line -o - %s 2>&1 | FileCheck -check-prefix=GRECORD_O %s |
| 250 |
// RUN: %clang -### -c -O3 -ffunction-sections -grecord-command-line %s 2>&1 | FileCheck -check-prefix=GRECORD_OPT %s |
| 251 |
|
| 252 |
// RUN: %clang -### -c -gstrict-dwarf -gno-strict-dwarf %s 2>&1 | FileCheck -check-prefix=GIGNORE %s |
| 253 |
|
| 254 |
// RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GPUB %s |
| 255 |
// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 256 |
// RUN: %clang -### -c -ggnu-pubnames -gno-gnu-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 257 |
// RUN: %clang -### -c -ggnu-pubnames -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 258 |
// |
| 259 |
// RUN: %clang -### -c -gpubnames %s 2>&1 | FileCheck -check-prefix=PUB %s |
| 260 |
// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 261 |
// RUN: %clang -### -c -gpubnames -gno-gnu-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 262 |
// RUN: %clang -### -c -gpubnames -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 263 |
|
| 264 |
/// Specify --target= so that %clang doesn't exit with code 1 even if LLVM_DEFAULT_TARGET_TRIPLE specifies a RISC-V target triple. |
| 265 |
// RUN: %clang -### --target=x86_64 -c -gsplit-dwarf -g -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 266 |
// |
| 267 |
// RUN: %clang -### -c -fdebug-ranges-base-address %s 2>&1 | FileCheck -check-prefix=RNGBSE %s |
| 268 |
// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s |
| 269 |
// RUN: %clang -### -c -fdebug-ranges-base-address -fno-debug-ranges-base-address %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s |
| 270 |
// |
| 271 |
// RUN: %clang -### -c -g -gomit-unreferenced-methods -fno-standalone-debug %s 2>&1 | FileCheck -check-prefix=INCTYPES %s |
| 272 |
// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOINCTYPES %s |
| 273 |
// RUN: %clang -### -c -g -gomit-unreferenced-methods -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \ |
| 274 |
// RUN: | FileCheck -check-prefix=NOINCTYPES %s |
| 275 |
// RUN: %clang -### -c -g -gomit-unreferenced-methods -fstandalone-debug %s 2>&1 | FileCheck -check-prefix=NOINCTYPES %s |
| 276 |
// |
| 277 |
// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 278 |
// RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s |
| 279 |
// |
| 280 |
// RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s |
| 281 |
// |
| 282 |
// RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \ |
| 283 |
// RUN: | FileCheck -check-prefix=FDTS %s |
| 284 |
// |
| 285 |
// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \ |
| 286 |
// RUN: | FileCheck -check-prefix=NOFDTS %s |
| 287 |
// |
| 288 |
// RUN: %clang -### -fdebug-types-section -target wasm32-unknown-unknown %s 2>&1 \ |
| 289 |
// RUN: | FileCheck -check-prefix=FDTS %s |
| 290 |
// |
| 291 |
// RUN: not %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \ |
| 292 |
// RUN: | FileCheck -check-prefix=FDTSE %s |
| 293 |
// |
| 294 |
// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-apple-darwin %s 2>&1 \ |
| 295 |
// RUN: | FileCheck -check-prefix=NOFDTSE %s |
| 296 |
// |
| 297 |
// RUN: %clang -### -g -gno-column-info %s 2>&1 \ |
| 298 |
// RUN: | FileCheck -check-prefix=NOCI %s |
| 299 |
// |
| 300 |
// RUN: %clang -### -g -gno-call-site-info %s 2>&1 \ |
| 301 |
// RUN: | FileCheck -check-prefix=NOCALLSITE %s |
| 302 |
// |
| 303 |
// RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \ |
| 304 |
// | FileCheck -check-prefix=CI %s |
| 305 |
// |
| 306 |
// RUN: %clang -### -gmodules %s 2>&1 \ |
| 307 |
// RUN: | FileCheck -check-prefix=GEXTREFS %s |
| 308 |
// |
| 309 |
// RUN: %clang -### -gmodules -g %s 2>&1 \ |
| 310 |
// RUN: | FileCheck -check-prefix=GEXTREFS %s |
| 311 |
// |
| 312 |
// RUN: %clang -### -gline-tables-only -gmodules %s 2>&1 \ |
| 313 |
// RUN: | FileCheck -check-prefix=GEXTREFS %s |
| 314 |
// |
| 315 |
// RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \ |
| 316 |
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s |
| 317 |
// |
| 318 |
// RUN: %clang -### -target %itanium_abi_triple -gmodules -gline-directives-only %s 2>&1 \ |
| 319 |
// RUN: | FileCheck -check-prefix=GLIO_ONLY %s |
| 320 |
// |
| 321 |
// RUN: %clang -### -gmodules -gno-modules %s 2>&1 \ |
| 322 |
// RUN: | FileCheck -check-prefix=NOGEXTREFS %s |
| 323 |
// |
| 324 |
// RUN: %clang -### -gno-modules %s 2>&1 | FileCheck -check-prefix=GNOMOD %s |
| 325 |
// |
| 326 |
// NOG_PS: "-cc1" |
| 327 |
// NOG_PS-NOT: "-dwarf-version= |
| 328 |
// NOG_PS-NOT: "-generate-arange-section" |
| 329 |
// |
| 330 |
// G_ERR: error: unknown argument: |
| 331 |
// |
| 332 |
// G_NO: "-cc1" |
| 333 |
// G_NO-NOT: -debug-info-kind= |
| 334 |
// |
| 335 |
// GLTO_ONLY: "-cc1" |
| 336 |
// GLTO_ONLY-NOT: "-dwarf-ext-refs" |
| 337 |
// GLTO_ONLY: "-debug-info-kind=line-tables-only" |
| 338 |
// GLTO_ONLY-NOT: "-dwarf-ext-refs" |
| 339 |
// |
| 340 |
// GLTO_ONLY_DWARF2: "-cc1" |
| 341 |
// GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only" |
| 342 |
// GLTO_ONLY_DWARF2: "-dwarf-version=2" |
| 343 |
// |
| 344 |
// GLIO_ONLY: "-cc1" |
| 345 |
// GLIO_ONLY-NOT: "-dwarf-ext-refs" |
| 346 |
// GLIO_ONLY: "-debug-info-kind=line-directives-only" |
| 347 |
// GLIO_ONLY-NOT: "-dwarf-ext-refs" |
| 348 |
// |
| 349 |
// GLIO_ONLY_DWARF2: "-cc1" |
| 350 |
// GLIO_ONLY_DWARF2: "-debug-info-kind=line-directives-only" |
| 351 |
// GLIO_ONLY_DWARF2: "-dwarf-version=2" |
| 352 |
// |
| 353 |
// G_ONLY: "-cc1" |
| 354 |
// G_ONLY: "-debug-info-kind=constructor" |
| 355 |
// |
| 356 |
// These tests assert that "-gline-tables-only" "-g" uses the latter, |
| 357 |
// but otherwise not caring about the DebugInfoKind. |
| 358 |
// G_ONLY_DWARF2: "-cc1" |
| 359 |
// G_ONLY_DWARF2: "-debug-info-kind={{standalone|constructor}}" |
| 360 |
// G_ONLY_DWARF2: "-dwarf-version=2" |
| 361 |
// |
| 362 |
// G_STANDALONE: "-cc1" |
| 363 |
// G_STANDALONE: "-debug-info-kind=standalone" |
| 364 |
// G_LIMITED: "-cc1" |
| 365 |
// G_LIMITED: "-debug-info-kind=constructor" |
| 366 |
// G_DWARF2: "-dwarf-version=2" |
| 367 |
// G_DWARF4-DAG: "-dwarf-version=4" |
| 368 |
// G_DWARF5-DAG: "-dwarf-version=5" |
| 369 |
// |
| 370 |
// G_GDB: "-debugger-tuning=gdb" |
| 371 |
// G_LLDB: "-debugger-tuning=lldb" |
| 372 |
// G_SCE-DAG: "-debugger-tuning=sce" |
| 373 |
// G_DBX: "-debugger-tuning=dbx" |
| 374 |
// |
| 375 |
// STRICT: "-gstrict-dwarf" |
| 376 |
// NOSTRICT-NOT: "-gstrict-dwarf" |
| 377 |
// |
| 378 |
// G_NOTUNING: "-cc1" |
| 379 |
// G_NOTUNING-NOT: "-debugger-tuning=" |
| 380 |
// |
| 381 |
// This tests asserts that "-gline-tables-only" "-g0" disables debug info. |
| 382 |
// GLTO_NO: "-cc1" |
| 383 |
// GLTO_NO-NOT: -debug-info-kind= |
| 384 |
// |
| 385 |
// This tests asserts that "-gline-directives-only" "-g0" disables debug info. |
| 386 |
// GLIO_NO: "-cc1" |
| 387 |
// GLIO_NO-NOT: -debug-info-kind= |
| 388 |
// |
| 389 |
// GRECORD: "-dwarf-debug-flags" |
| 390 |
// GRECORD: -### -c -grecord-command-line |
| 391 |
// |
| 392 |
// GNO_RECORD-NOT: "-dwarf-debug-flags" |
| 393 |
// GNO_RECORD-NOT: -### -c -grecord-command-line |
| 394 |
// |
| 395 |
// GRECORD_O: "-dwarf-debug-flags" |
| 396 |
// GRECORD_O: -### -c -grecord-command-line -o - |
| 397 |
// |
| 398 |
// GRECORD_OPT: -### -c -O3 -ffunction-sections -grecord-command-line |
| 399 |
// |
| 400 |
// GIGNORE-NOT: "argument unused during compilation" |
| 401 |
// |
| 402 |
// GPUB: -ggnu-pubnames |
| 403 |
// NOPUB-NOT: -ggnu-pubnames |
| 404 |
// NOPUB-NOT: -gpubnames |
| 405 |
// |
| 406 |
|
| 407 |
// LDGARANGE: {{".*ld.*"}} {{.*}} |
| 408 |
// LDGARANGE-NOT: -generate-arange-section" |
| 409 |
// SNLDTLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-thin-debug-options= -generate-arange-section" |
| 410 |
// SNLDFLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-debug-options= -generate-arange-section" |
| 411 |
|
| 412 |
// PUB: -gpubnames |
| 413 |
// |
| 414 |
// RNGBSE: -fdebug-ranges-base-address |
| 415 |
// NORNGBSE-NOT: -fdebug-ranges-base-address |
| 416 |
// |
| 417 |
// INCTYPES: -gomit-unreferenced-methods |
| 418 |
// NOINCTYPES-NOT: -gomit-unreferenced-methods |
| 419 |
// |
| 420 |
// GARANGE-DAG: -generate-arange-section |
| 421 |
// |
| 422 |
// FDTS: "-mllvm" "-generate-type-units" |
| 423 |
// FDTSE: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' |
| 424 |
// |
| 425 |
// NOFDTS-NOT: "-mllvm" "-generate-type-units" |
| 426 |
// NOFDTSE-NOT: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' |
| 427 |
// |
| 428 |
// CI-NOT: "-gno-column-info" |
| 429 |
// |
| 430 |
// NOCI-DAG: "-gno-column-info" |
| 431 |
// |
| 432 |
// NOCALLSITE: "-gno-call-site-info" |
| 433 |
// |
| 434 |
// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" |
| 435 |
// GEXTREFS: "-debug-info-kind={{standalone|constructor}}" |
| 436 |
// NOGEXTREFS-NOT: -dwarf-ext-refs |
| 437 |
// |
| 438 |
// GNOMOD-NOT: -debug-info-kind= |
| 439 |
|
| 440 |
// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s |
| 441 |
// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind' |
| 442 |
// RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s |
| 443 |
// BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal' |
| 444 |
|
| 445 |
// RUN: %clang -### -fdebug-macro %s 2>&1 | FileCheck -check-prefix=MACRO %s |
| 446 |
// RUN: %clang -### -fno-debug-macro %s 2>&1 | FileCheck -check-prefix=NOMACRO %s |
| 447 |
// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=NOMACRO %s |
| 448 |
// MACRO: "-debug-info-macro" |
| 449 |
// NOMACRO-NOT: "-debug-info-macro" |
| 450 |
// |
| 451 |
// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \ |
| 452 |
// RUN: | FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s |
| 453 |
// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types" |
| 454 |
// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited" |
| 455 |
// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \ |
| 456 |
// RUN: | FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s |
| 457 |
// RUN: %clang -### -fno-eliminate-unused-debug-types -g1 -c %s 2>&1 \ |
| 458 |
// RUN: | FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s |
| 459 |
// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind={{constructor|line-tables-only|standalone}}" |
| 460 |
// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types" |
| 461 |
// |
| 462 |
// RUN: %clang -### -c -gdwarf-5 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s |
| 463 |
// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s |
| 464 |
// RUN: %clang -### -c -gdwarf-3 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s |
| 465 |
// RUN: not %clang -### -c -gdwarf-2 -gdwarf64 --target=x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_VER %s |
| 466 |
// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64 -target x86_64 %s 2>&1 \ |
| 467 |
// RUN: | FileCheck -check-prefix=GDWARF64_ON %s |
| 468 |
// RUN: not %clang -### -c -gdwarf-4 -gdwarf64 --target=i386-linux-gnu %s 2>&1 \ |
| 469 |
// RUN: | FileCheck -check-prefix=GDWARF64_32ARCH %s |
| 470 |
// RUN: not %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64-apple-darwin %s 2>&1 \ |
| 471 |
// RUN: | FileCheck -check-prefix=GDWARF64_ELF %s |
| 472 |
// |
| 473 |
// GDWARF64_ON: "-gdwarf64" |
| 474 |
// GDWARF64_VER: error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater' |
| 475 |
// GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture' |
| 476 |
// GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms' |
| 477 |
|
| 478 |
/// Default to -fno-dwarf-directory-asm for -fno-integrated-as before DWARF v5. |
| 479 |
// RUN: %clang -### -target x86_64 -c -gdwarf-2 %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s |
| 480 |
// RUN: %clang -### -target x86_64 -c -gdwarf-5 %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s |
| 481 |
// RUN: %clang -### -target x86_64 -c -gdwarf-4 -fno-integrated-as %s 2>&1 | FileCheck --check-prefix=NODIRECTORY %s |
| 482 |
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -fno-integrated-as %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s |
| 483 |
|
| 484 |
// RUN: %clang -### -target x86_64 -c -gdwarf-4 -fno-dwarf-directory-asm %s 2>&1 | FileCheck --check-prefix=NODIRECTORY %s |
| 485 |
|
| 486 |
// DIRECTORY-NOT: "-fno-dwarf-directory-asm" |
| 487 |
// NODIRECTORY: "-fno-dwarf-directory-asm" |
| 488 |
|
| 489 |
// RUN: %clang -### -target x86_64 -c -g -gsimple-template-names %s 2>&1 | FileCheck --check-prefixes=SIMPLE_TMPL_NAMES,FWD_TMPL_PARAMS %s |
| 490 |
// SIMPLE_TMPL_NAMES: -gsimple-template-names=simple |
| 491 |
// FWD_TMPL_PARAMS-DAG: -debug-forward-template-params |
| 492 |
// RUN: not %clang -### -target x86_64 -c -g -gsimple-template-names=mangled %s 2>&1 | FileCheck --check-prefix=MANGLED_TEMP_NAMES %s |
| 493 |
// MANGLED_TEMP_NAMES: error: unknown argument '-gsimple-template-names=mangled'; did you mean '-Xclang -gsimple-template-names=mangled' |
| 494 |
// RUN: %clang -### -target x86_64 -c -g %s 2>&1 | FileCheck --check-prefix=FULL_TEMP_NAMES --implicit-check-not=debug-forward-template-params %s |
| 495 |
// FULL_TEMP_NAMES-NOT: -gsimple-template-names |
| 496 |
|
| 497 |
//// Test -g[no-]template-alias (enabled by default with SCE debugger tuning and DWARF version >= 4). |
| 498 |
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gsce %s 2>&1 | FileCheck %s --check-prefixes=TEMPLATE-ALIAS |
| 499 |
// RUN: %clang -### -target x86_64 -c -gdwarf-3 -gsce %s 2>&1 | FileCheck %s --check-prefixes=NO-TEMPLATE-ALIAS |
| 500 |
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gsce -gtemplate-alias %s 2>&1 | FileCheck %s --check-prefixes=TEMPLATE-ALIAS |
| 501 |
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gsce -gno-template-alias %s 2>&1 | FileCheck %s --check-prefixes=NO-TEMPLATE-ALIAS |
| 502 |
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gtemplate-alias %s 2>&1 | FileCheck %s --check-prefixes=TEMPLATE-ALIAS |
| 503 |
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gtemplate-alias -gno-template-alias %s 2>&1 | FileCheck %s --check-prefixes=NO-TEMPLATE-ALIAS |
| 504 |
// TEMPLATE-ALIAS: "-gtemplate-alias" |
| 505 |
// NO-TEMPLATE-ALIAS-NOT: "-gtemplate-alias" |