r175505 - [Sanitizer] If -fsanitize-blacklist= option is not explicitly specified, make Clang look for the default sanitizer-specific blacklist in the resource directory.

Alexey Samsonov samsonov at google.com
Tue Feb 19 03:25:29 PST 2013


Author: samsonov
Date: Tue Feb 19 05:25:29 2013
New Revision: 175505

URL: http://llvm.org/viewvc/llvm-project?rev=175505&view=rev
Log:
[Sanitizer] If -fsanitize-blacklist= option is not explicitly specified, make Clang look for the default sanitizer-specific blacklist in the resource directory.

Modified:
    cfe/trunk/lib/Driver/SanitizerArgs.h
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/SanitizerArgs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.h?rev=175505&r1=175504&r2=175505&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.h Tue Feb 19 05:25:29 2013
@@ -15,6 +15,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace driver {
@@ -189,6 +190,18 @@ class SanitizerArgs {
 
     llvm_unreachable("arg didn't provide expected value");
   }
+
+  static bool getDefaultBlacklistForKind(const Driver &D, unsigned Kind,
+                                         std::string &BLPath) {
+    // For now, specify the default blacklist location for ASan only.
+    if (Kind & NeedsAsanRt) {
+      SmallString<64> Path(D.ResourceDir);
+      llvm::sys::path::append(Path, "asan_blacklist.txt");
+      BLPath = Path.str();
+      return true;
+    }
+    return false;
+  }
 };
 
 }  // namespace driver

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=175505&r1=175504&r2=175505&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Feb 19 05:25:29 2013
@@ -1543,6 +1543,14 @@ SanitizerArgs::SanitizerArgs(const Drive
       else
         D.Diag(diag::err_drv_no_such_file) << BLPath;
     }
+  } else {
+    // If no -fsanitize-blacklist option is specified, try to look up for
+    // blacklist in the resource directory.
+    std::string BLPath;
+    bool BLExists = false;
+    if (getDefaultBlacklistForKind(D, Kind, BLPath) &&
+        !llvm::sys::fs::exists(BLPath, BLExists) && BLExists)
+      BlacklistFile = BLPath;
   }
 
   // Parse -f(no-)sanitize-memory-track-origins options.





More information about the cfe-commits mailing list