[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 8 15:43:26 PDT 2024


================
@@ -4248,6 +4248,22 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
       Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
+  if (auto *A = Args.getLastArg(OPT_fsanitize_overflow_pattern_exclusion_EQ)) {
+    for (int i = 0, n = A->getNumValues(); i != n; ++i) {
+      StringRef Value = A->getValue(i);
+      if (Value == "none")
+        Opts.OverflowPatternExclusionMask |= LangOptionsBase::None;
----------------
bwendling wrote:

This seems counter-intuitive. Shouldn't this be an assignment instead?

```c
Opts.OverflowPatternExclusionMask = LangOptionsBase::None;
```

Or is that not the behavior you want?

Also, look up `StringSwitch`, which does the same as these if-then statements, but in the LLVM way. :-)

https://github.com/llvm/llvm-project/pull/100272


More information about the cfe-commits mailing list