[PATCH] Introduce -fsanitize-trap= flag.

Peter Collingbourne peter at pcc.me.uk
Tue Jun 16 17:53:02 PDT 2015


================
Comment at: lib/CodeGen/CGExpr.cpp:2306
@@ -2304,2 +2305,3 @@
     llvm::Value *Check = Checked[i].first;
+    // -fsanitize-trap= overrides -fsanitize-recover=.
     llvm::Value *&Cond =
----------------
samsonov wrote:
> Should we clarify this behavior in the docs?
> We can also handle this case in the driver, so that frontend can assert that each sanitizer check is listed in at most one of `-fsanitize-recover=` and `-fsanitize-trap=` lists. (i.e. intersection of `SanitizeTrap` and `SanitizeRecover` is empty).
> 
> Another interesting question is handling the relative order of `-fsanitize-trap=` and `-fsanitize-recover=` flags. Now we parse them completely independently, but this may not be the best solution. Consider global
>   CFLAGS='-fsanitize=undefined -fsanitize-trap=undefined'
> and now I want to compile a special program, and enable recovery for alignment issues. Using
>   clang++ $(CFLAGS) -fsanitize-recover=alignment a.cc
> wouldn't work, I would have to write
>   clang++ $(CFLAGS) -fno-sanitize-trap=alignment -fsanitize-recover=alignment a.cc
> Do you think we should instead parse `-fsanitize-trap` and `-fsanitize-recover` in a single pass, and maintain the recovery setting for each sanitizer kind to be one of
>   * diagnosed, recoverable
>   * diagnosed, unrecoverable/fatal
>   * undiagnosed, trapping.
> ?
> 
> Should we clarify this behavior in the docs?

Yes, done.

> Do you think we should instead parse -fsanitize-trap and -fsanitize-recover in a single pass

The logic around parsing these flags is already too complicated and I would be against making it more complex than it already is. I would prefer to solve this problem with documentation.

================
Comment at: lib/Driver/SanitizerArgs.cpp:503
@@ -462,2 +502,3 @@
   RecoverableSanitizers.Mask |= RecoverableKinds;
+  TrapSanitizers.Mask |= TrappingKinds;
 }
----------------
samsonov wrote:
> Note that you can also strip out sanitizers which were not enabled eventually from here
>   TrappingKinds &= Kinds;
> as we do for recoverable sanitizers.
Done

http://reviews.llvm.org/D10464

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list