[PATCH] Sanitizer: Add support for default blacklist locations in resource directory.
Alexey Samsonov
samsonov at google.com
Wed Feb 6 07:19:59 PST 2013
Hi chandlerc, rsmith,
If -fsanitize-blacklist= option is not explicitly specified,
Clang will look for the default blacklist for a given sanitizer in the
resource directory. Blacklists would be optionally created and installed
by compiler-rt build system.
http://llvm-reviews.chandlerc.com/D378
Files:
lib/Driver/SanitizerArgs.h
lib/Driver/Tools.cpp
Index: lib/Driver/SanitizerArgs.h
===================================================================
--- lib/Driver/SanitizerArgs.h
+++ lib/Driver/SanitizerArgs.h
@@ -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 @@
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
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1548,6 +1548,14 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D378.1.patch
Type: text/x-patch
Size: 1557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130206/7e0623a7/attachment.bin>
More information about the cfe-commits
mailing list