[PATCH] D11968: Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.
Ivan Krasin via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 17:16:05 PDT 2015
krasin created this revision.
krasin added subscribers: cfe-commits, pcc.
Clang sanitizers, such as AddressSanitizer, ThreadSanitizer, MemorySanitizer,
Control Flow Integrity and others, use blacklists to specify which types / functions
should not be instrumented to avoid false positives or suppress known failures.
This change adds the blacklist filenames to the list of dependencies of the rules,
generated with -M/-MM/-MD/-MMD. This lets CMake/Ninja recognize that certain
C/C++/ObjC files need to be recompiled (if a blacklist is updated).
http://reviews.llvm.org/D11968
Files:
include/clang/Frontend/DependencyOutputOptions.h
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/DependencyFile.cpp
test/Frontend/dependency-gen.c
Index: test/Frontend/dependency-gen.c
===================================================================
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -20,6 +20,10 @@
// RUN: cd a/b
// RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
// CHECK-SIX: {{ }}x.h
+// RUN: echo "fun:foo" > %t.blacklist
+// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// CHECK-SEVEN: {{ }}x.h
+// CHECK-SEVEN: .blacklist
#ifndef INCLUDE_FLAG_TEST
#include <x.h>
Index: lib/Frontend/DependencyFile.cpp
===================================================================
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -162,6 +162,7 @@
const Preprocessor *PP;
std::string OutputFile;
std::vector<std::string> Targets;
+ std::vector<std::string> ExtraDeps;
bool IncludeSystemHeaders;
bool PhonyTarget;
bool AddMissingHeaderDeps;
@@ -177,6 +178,7 @@
public:
DFGImpl(const Preprocessor *_PP, const DependencyOutputOptions &Opts)
: PP(_PP), OutputFile(Opts.OutputFile), Targets(Opts.Targets),
+ ExtraDeps(Opts.ExtraDeps),
IncludeSystemHeaders(Opts.IncludeSystemHeaders),
PhonyTarget(Opts.UsePhonyTargets),
AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),
@@ -411,6 +413,11 @@
return;
}
+ // Add extra dependencies to the end of the list.
+ for (auto ExtraDep : ExtraDeps) {
+ AddFilename(ExtraDep);
+ }
+
// Write out the dependency targets, trying to avoid overly long
// lines when possible. We try our best to emit exactly the same
// dependency file as GCC (4.2), assuming the included files are the
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -705,6 +705,10 @@
Args.getLastArgValue(OPT_module_dependency_dir);
if (Args.hasArg(OPT_MV))
Opts.OutputFormat = DependencyOutputFormat::NMake;
+ // Add sanitizer blacklists as extra dependencies.
+ // They won't be discovered by the regular preprocessor, so
+ // we let make / ninja to know about this implicit dependency.
+ Opts.ExtraDeps = Args.getAllArgValues(OPT_fsanitize_blacklist);
}
bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
Index: include/clang/Frontend/DependencyOutputOptions.h
===================================================================
--- include/clang/Frontend/DependencyOutputOptions.h
+++ include/clang/Frontend/DependencyOutputOptions.h
@@ -47,6 +47,9 @@
/// must contain at least one entry.
std::vector<std::string> Targets;
+ /// A list of filenames to be used as extra dependencies for every target.
+ std::vector<std::string> ExtraDeps;
+
/// \brief The file to write GraphViz-formatted header dependencies to.
std::string DOTOutputFile;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11968.31889.patch
Type: text/x-patch
Size: 2987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150812/50b5fd0e/attachment-0001.bin>
More information about the cfe-commits
mailing list