[PATCH] D56846: [NewPM] Catch sanitizers passed to -fsanitize that haven't been implemented

Philip Pfaffe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 17 04:39:03 PST 2019


philip.pfaffe created this revision.
philip.pfaffe added reviewers: chandlerc, rsmith, rnk.
Herald added a subscriber: bollu.

Currently clang's new-pm driver silently breaks sanitizers. Make using a not implemented sanitizer a hard failuer.

On drawback is that when you try to use a group that's not implemented, such as -fsanitize=undefined, it will complain about the first member of the group that's not available, Alignment in this case. Is that worth fixing?


https://reviews.llvm.org/D56846

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1013,9 +1013,23 @@
       // configure the pipeline.
       PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
 
-      // Register callbacks to schedule sanitizer passes at the appropriate part of
-      // the pipeline.
-      // FIXME: either handle asan/the remaining sanitizers or error out
+      // Register callbacks to schedule sanitizer passes at the appropriate part
+      // of the pipeline.
+      //
+      // FIXME: Handle the remaining sanitizers. This throws a fatal error when
+      // one is selected that's not implemented in the meantime. Update the
+      // following list as appropriate.
+      SanitizerMask ImplementedSanitizers = SanitizerKind::LocalBounds |
+                                            SanitizerKind::Memory |
+                                            SanitizerKind::Thread;
+#define SANITIZER(NAME, ID)                                                    \
+  if (LangOpts.Sanitize.hasOneOf(SanitizerKind::ID & ~ImplementedSanitizers))  \
+    report_fatal_error("Trying to use the " NAME                               \
+                       " sanitizer, which is not implemented.");
+#define SANITIZER_GROUP(NAME, ID, ALIAS)                                       \
+  SANITIZER(NAME, ID##Group) SANITIZER(NAME, ID)
+#include "clang/Basic/Sanitizers.def"
+
       if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
         PB.registerScalarOptimizerLateEPCallback(
             [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56846.182251.patch
Type: text/x-patch
Size: 1707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190117/cfab90f2/attachment.bin>


More information about the llvm-commits mailing list