@@ -171,22 +171,28 @@ TEST(BoundsSafetyBringUpMissingChecks, ChkPairValidMask) {
171
171
ASSERT_EQ (SeenBits, LangOptions::BS_CHK_All);
172
172
}
173
173
174
+ #if 1
175
+ #define NEED_CC1_ARG
176
+ #else
177
+ #define NEED_CC1_ARG "-Xclang",
178
+ #endif
179
+
174
180
// =============================================================================
175
181
// Default behavior
176
182
// =============================================================================
177
183
178
184
TEST (BoundsSafetyBringUpMissingChecks, DefaultWithBoundsSafety) {
179
- bool Result =
180
- runOnToolAndCheckLangOptions ({ " -fbounds-safety" }, [](LangOptions &LO) {
185
+ bool Result = runOnToolAndCheckLangOptions (
186
+ {NEED_CC1_ARG " -fbounds-safety" }, [](LangOptions &LO) {
181
187
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (),
182
188
LangOptions::BS_CHK_Default);
183
189
});
184
190
ASSERT_TRUE (Result);
185
191
}
186
192
187
193
TEST (BoundsSafetyBringUpMissingChecks, DefaultWithoutBoundsSafety) {
188
- bool Result =
189
- runOnToolAndCheckLangOptions ({ " -fno-bounds-safety" }, [](LangOptions &LO) {
194
+ bool Result = runOnToolAndCheckLangOptions (
195
+ {NEED_CC1_ARG " -fno-bounds-safety" }, [](LangOptions &LO) {
190
196
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (),
191
197
LangOptions::BS_CHK_Default);
192
198
});
@@ -201,7 +207,8 @@ TEST(BoundsSafetyBringUpMissingChecks, DefaultWithoutBoundsSafety) {
201
207
TEST (BoundsSafetyBringUpMissingChecks,
202
208
DefaultAllDisabledExperimentalBoundsSafetyAttributes) {
203
209
bool Result = runOnToolAndCheckLangOptions (
204
- {" -fexperimental-bounds-safety-attributes" }, [](LangOptions &LO) {
210
+ {NEED_CC1_ARG " -fexperimental-bounds-safety-attributes" },
211
+ [](LangOptions &LO) {
205
212
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (),
206
213
LangOptions::BS_CHK_Default);
207
214
});
@@ -214,7 +221,8 @@ TEST(BoundsSafetyBringUpMissingChecks,
214
221
215
222
TEST (BoundsSafetyBringUpMissingChecks, all_eq) {
216
223
bool Result = runOnToolAndCheckLangOptions (
217
- {" -fbounds-safety" , " -fbounds-safety-bringup-missing-checks=all" },
224
+ {NEED_CC1_ARG " -fbounds-safety" ,
225
+ NEED_CC1_ARG " -fbounds-safety-bringup-missing-checks=all" },
218
226
[](LangOptions &LO) {
219
227
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (),
220
228
LangOptions::BS_CHK_All);
@@ -229,7 +237,8 @@ TEST(BoundsSafetyBringUpMissingChecks, all_eq) {
229
237
230
238
TEST (BoundsSafetyBringUpMissingChecks, all) {
231
239
bool Result = runOnToolAndCheckLangOptions (
232
- {" -fbounds-safety" , " -fbounds-safety-bringup-missing-checks" },
240
+ {NEED_CC1_ARG " -fbounds-safety" ,
241
+ NEED_CC1_ARG " -fbounds-safety-bringup-missing-checks" },
233
242
[](LangOptions &LO) {
234
243
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (),
235
244
LangOptions::BS_CHK_All);
@@ -249,9 +258,10 @@ TEST(BoundsSafetyBringUpMissingChecks, all) {
249
258
TEST (BoundsSafetyBringUpMissingChecks, only_one_check) {
250
259
for (size_t ChkIdx = 0 ; ChkIdx < NumPairs; ++ChkIdx) {
251
260
ChkPair Chk = Pairs[ChkIdx];
252
- std::vector<std::string> Args = {" -fbounds-safety" ,
261
+ std::vector<std::string> Args = {NEED_CC1_ARG " -fbounds-safety" ,
262
+ NEED_CC1_ARG
253
263
" -fbounds-safety-bringup-missing-checks=" };
254
- Args[1 ].append (Chk.arg );
264
+ Args[Args. size () - 1 ].append (Chk.arg );
255
265
256
266
bool Result = runOnToolAndCheckLangOptions (Args, [&Chk](LangOptions &LO) {
257
267
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (), Chk.Mask );
@@ -284,10 +294,11 @@ TEST(BoundsSafetyBringUpMissingChecks, all_pairs) {
284
294
ChkPair First = Pairs[firstIdx];
285
295
auto Second = Pairs[secondIdx];
286
296
std::vector<std::string> Args = {
287
- " -fbounds-safety" , " -fbounds-safety-bringup-missing-checks=" };
288
- Args[1 ].append (First.arg );
289
- Args[1 ].append (" ," );
290
- Args[1 ].append (Second.arg );
297
+ NEED_CC1_ARG " -fbounds-safety" ,
298
+ NEED_CC1_ARG " -fbounds-safety-bringup-missing-checks=" };
299
+ Args[Args.size () - 1 ].append (First.arg );
300
+ Args[Args.size () - 1 ].append (" ," );
301
+ Args[Args.size () - 1 ].append (Second.arg );
291
302
ASSERT_NE (First.Mask , Second.Mask );
292
303
293
304
bool Result = runOnToolAndCheckLangOptions (
@@ -320,9 +331,10 @@ TEST(BoundsSafetyBringUpMissingChecks, all_with_one_removed) {
320
331
for (size_t ChkIdx = 0 ; ChkIdx < NumPairs; ++ChkIdx) {
321
332
ChkPair Chk = Pairs[ChkIdx];
322
333
std::vector<std::string> Args = {
323
- " -fbounds-safety" , " -fbounds-safety-bringup-missing-checks=all" ,
324
- " -fno-bounds-safety-bringup-missing-checks=" };
325
- Args[2 ].append (Chk.arg );
334
+ NEED_CC1_ARG " -fbounds-safety" ,
335
+ NEED_CC1_ARG " -fbounds-safety-bringup-missing-checks=all" ,
336
+ NEED_CC1_ARG " -fno-bounds-safety-bringup-missing-checks=" };
337
+ Args[Args.size () - 1 ].append (Chk.arg );
326
338
327
339
bool Result = runOnToolAndCheckLangOptions (Args, [&Chk](LangOptions &LO) {
328
340
unsigned ExpectedMask = LangOptions::BS_CHK_All & (~Chk.Mask );
@@ -350,7 +362,8 @@ TEST(BoundsSafetyBringUpMissingChecks, all_with_one_removed) {
350
362
351
363
TEST (BoundsSafetyBringUpMissingChecks, all_disabled) {
352
364
bool Result = runOnToolAndCheckLangOptions (
353
- {" -fbounds-safety" , " -fno-bounds-safety-bringup-missing-checks" },
365
+ {NEED_CC1_ARG " -fbounds-safety" ,
366
+ NEED_CC1_ARG " -fno-bounds-safety-bringup-missing-checks" },
354
367
[](LangOptions &LO) {
355
368
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (),
356
369
LangOptions::BS_CHK_None);
@@ -360,8 +373,9 @@ TEST(BoundsSafetyBringUpMissingChecks, all_disabled) {
360
373
361
374
TEST (BoundsSafetyBringUpMissingChecks, all_enable_then_disable) {
362
375
bool Result = runOnToolAndCheckLangOptions (
363
- {" -fbounds-safety" , " -fbounds-safety-bringup-missing-checks" ,
364
- " -fno-bounds-safety-bringup-missing-checks" },
376
+ {NEED_CC1_ARG " -fbounds-safety" ,
377
+ NEED_CC1_ARG " -fbounds-safety-bringup-missing-checks" ,
378
+ NEED_CC1_ARG " -fno-bounds-safety-bringup-missing-checks" },
365
379
[](LangOptions &LO) {
366
380
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (),
367
381
LangOptions::BS_CHK_None);
@@ -377,9 +391,10 @@ TEST(BoundsSafetyBringUpMissingChecks, all_disabled_then_enable_one) {
377
391
for (size_t ChkIdx = 0 ; ChkIdx < NumPairs; ++ChkIdx) {
378
392
ChkPair Chk = Pairs[ChkIdx];
379
393
std::vector<std::string> Args = {
380
- " -fbounds-safety" , " -fno-bounds-safety-bringup-missing-checks" ,
381
- " -fbounds-safety-bringup-missing-checks=" };
382
- Args[2 ].append (Chk.arg );
394
+ NEED_CC1_ARG " -fbounds-safety" ,
395
+ NEED_CC1_ARG " -fno-bounds-safety-bringup-missing-checks" ,
396
+ NEED_CC1_ARG " -fbounds-safety-bringup-missing-checks=" };
397
+ Args[Args.size () - 1 ].append (Chk.arg );
383
398
384
399
bool Result = runOnToolAndCheckLangOptions (Args, [&Chk](LangOptions &LO) {
385
400
EXPECT_EQ (LO.getBoundsSafetyBringUpMissingChecks (), Chk.Mask );
0 commit comments