Skip to content

Commit 51973b7

Browse files
committed
Simplify per Vitaly's feedback
1 parent e24fbd3 commit 51973b7

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,16 @@ static SanitizerMask setGroupBits(SanitizerMask Kinds) {
248248
}
249249

250250
// Computes the sanitizer mask as:
251-
// Default + Arguments (in or out) + AlwaysIn - AlwaysOut
251+
// Default + Arguments (in or out)
252252
// with arguments parsed from left to right.
253253
//
254-
// AlwaysOut is not enforced if AlwaysOutAdvisoryOnly is enabled.
255-
//
256-
// Error messages are optionally printed if the AlwaysIn or AlwaysOut
257-
// invariants are violated.
254+
// Error messages are printed if the AlwaysIn or AlwaysOut invariants are
255+
// violated, but the caller must enforce these invariants themselves.
258256
static SanitizerMask
259257
parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList &Args,
260258
bool DiagnoseErrors, SanitizerMask Default,
261259
SanitizerMask AlwaysIn, SanitizerMask AlwaysOut, int OptInID,
262-
int OptOutID, bool AlwaysOutAdvisoryOnly) {
260+
int OptOutID) {
263261
assert(!(AlwaysIn & AlwaysOut) &&
264262
"parseSanitizeArgs called with contradictory in/out requirements");
265263

@@ -304,10 +302,6 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList &Args,
304302
}
305303
}
306304

307-
Output |= AlwaysIn;
308-
if (!AlwaysOutAdvisoryOnly)
309-
Output &= ~AlwaysOut;
310-
311305
return Output;
312306
}
313307

@@ -317,7 +311,7 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
317311
SanitizerMask AlwaysTrap; // Empty
318312
SanitizerMask NeverTrap = ~(setGroupBits(TrappingSupported));
319313

320-
// AlwaysOutAdvisoryOnly = true is needed to maintain the behavior of
314+
// N.B. We do *not* enforce NeverTrap. This maintains the behavior of
321315
// '-fsanitize=undefined -fsanitize-trap=undefined'
322316
// (clang/test/Driver/fsanitize.c ), which is that vptr is not enabled at all
323317
// (not even in recover mode) in order to avoid the need for a ubsan runtime.
@@ -326,8 +320,7 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
326320
/* AlwaysIn */ AlwaysTrap,
327321
/* AlwaysOut */ NeverTrap,
328322
/* OptInID */ options::OPT_fsanitize_trap_EQ,
329-
/* OptOutID */ options::OPT_fno_sanitize_trap_EQ,
330-
/* AlwaysOutAdvisoryOnly */ true);
323+
/* OptOutID */ options::OPT_fno_sanitize_trap_EQ);
331324
}
332325

333326
bool SanitizerArgs::needsFuzzerInterceptors() const {
@@ -696,9 +689,9 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
696689
/* AlwaysIn */ AlwaysRecoverable,
697690
/* AlwaysOut */ Unrecoverable,
698691
/* OptInID */ options::OPT_fsanitize_recover_EQ,
699-
/* OptOutID */ options::OPT_fno_sanitize_recover_EQ,
700-
/* AlwaysOutAdvisoryOnly */ false);
701-
692+
/* OptOutID */ options::OPT_fno_sanitize_recover_EQ);
693+
RecoverableKinds |= AlwaysRecoverable;
694+
RecoverableKinds &= ~Unrecoverable;
702695
RecoverableKinds &= Kinds;
703696

704697
TrappingKinds &= Kinds;

0 commit comments

Comments
 (0)