<div dir="rtl"><div dir="ltr">Hi Ivan,</div><div dir="ltr"><br></div><div dir="ltr">CHECK-EIGHT is failing bots, see</div><div dir="ltr"><br></div><div dir="ltr"> <a href="http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c">http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c</a><br></div><div dir="ltr"><br></div><div dir="ltr">I disabled it in r<span style="font-size:12.8000001907349px">244869.</span></div><div dir="ltr"><br></div><div dir="ltr">Yaron</div><div dir="ltr"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div dir="ltr">2015-08-13 7:04 GMT+03:00 Ivan Krasin via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span>:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: krasin<br>
Date: Wed Aug 12 23:04:37 2015<br>
New Revision: 244867<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244867&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244867&view=rev</a><br>
Log:<br>
Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.<br>
<br>
Summary:<br>
Clang sanitizers, such as AddressSanitizer, ThreadSanitizer, MemorySanitizer,<br>
Control Flow Integrity and others, use blacklists to specify which types / functions<br>
should not be instrumented to avoid false positives or suppress known failures.<br>
<br>
This change adds the blacklist filenames to the list of dependencies of the rules,<br>
generated with -M/-MM/-MD/-MMD. This lets CMake/Ninja recognize that certain<br>
C/C++/ObjC files need to be recompiled (if a blacklist is updated).<br>
<br>
Reviewers: pcc<br>
<br>
Subscribers: rsmith, honggyu.kim, pcc, cfe-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D11968" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11968</a><br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h<br>
    cfe/trunk/include/clang/Frontend/Utils.h<br>
    cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
    cfe/trunk/lib/Frontend/DependencyFile.cpp<br>
    cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp<br>
    cfe/trunk/test/Frontend/dependency-gen.c<br>
    cfe/trunk/test/Frontend/print-header-includes.c<br>
<br>
Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=244867&r1=244866&r2=244867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=244867&r1=244866&r2=244867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)<br>
+++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Wed Aug 12 23:04:37 2015<br>
@@ -47,6 +47,9 @@ public:<br>
   /// must contain at least one entry.<br>
   std::vector<std::string> Targets;<br>
<br>
+  /// A list of filenames to be used as extra dependencies for every target.<br>
+  std::vector<std::string> ExtraDeps;<br>
+<br>
   /// \brief The file to write GraphViz-formatted header dependencies to.<br>
   std::string DOTOutputFile;<br>
<br>
<br>
Modified: cfe/trunk/include/clang/Frontend/Utils.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=244867&r1=244866&r2=244867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=244867&r1=244866&r2=244867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Frontend/Utils.h (original)<br>
+++ cfe/trunk/include/clang/Frontend/Utils.h Wed Aug 12 23:04:37 2015<br>
@@ -148,6 +148,9 @@ public:<br>
 /// AttachHeaderIncludeGen - Create a header include list generator, and attach<br>
 /// it to the given preprocessor.<br>
 ///<br>
+/// \param ExtraHeaders - If not empty, will write the header filenames, just<br>
+/// like they were included during a regular preprocessing. Useful for<br>
+/// implicit include dependencies, like sanitizer blacklists.<br>
 /// \param ShowAllHeaders - If true, show all header information instead of just<br>
 /// headers following the predefines buffer. This is useful for making sure<br>
 /// includes mentioned on the command line are also reported, but differs from<br>
@@ -156,7 +159,9 @@ public:<br>
 /// information to, instead of writing to stderr.<br>
 /// \param ShowDepth - Whether to indent to show the nesting of the includes.<br>
 /// \param MSStyle - Whether to print in cl.exe /showIncludes style.<br>
-void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders = false,<br>
+void AttachHeaderIncludeGen(Preprocessor &PP,<br>
+                            const std::vector<std::string> &ExtraHeaders,<br>
+                            bool ShowAllHeaders = false,<br>
                             StringRef OutputPath = "",<br>
                             bool ShowDepth = true, bool MSStyle = false);<br>
<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=244867&r1=244866&r2=244867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=244867&r1=244866&r2=244867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Aug 12 23:04:37 2015<br>
@@ -354,17 +354,19 @@ void CompilerInstance::createPreprocesso<br>
<br>
   // Handle generating header include information, if requested.<br>
   if (DepOpts.ShowHeaderIncludes)<br>
-    AttachHeaderIncludeGen(*PP);<br>
+    AttachHeaderIncludeGen(*PP, DepOpts.ExtraDeps);<br>
   if (!DepOpts.HeaderIncludeOutputFile.empty()) {<br>
     StringRef OutputPath = DepOpts.HeaderIncludeOutputFile;<br>
     if (OutputPath == "-")<br>
       OutputPath = "";<br>
-    AttachHeaderIncludeGen(*PP, /*ShowAllHeaders=*/true, OutputPath,<br>
+    AttachHeaderIncludeGen(*PP, DepOpts.ExtraDeps,<br>
+                           /*ShowAllHeaders=*/true, OutputPath,<br>
                            /*ShowDepth=*/false);<br>
   }<br>
<br>
   if (DepOpts.PrintShowIncludes) {<br>
-    AttachHeaderIncludeGen(*PP, /*ShowAllHeaders=*/false, /*OutputPath=*/"",<br>
+    AttachHeaderIncludeGen(*PP, DepOpts.ExtraDeps,<br>
+                           /*ShowAllHeaders=*/false, /*OutputPath=*/"",<br>
                            /*ShowDepth=*/true, /*MSStyle=*/true);<br>
   }<br>
 }<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=244867&r1=244866&r2=244867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=244867&r1=244866&r2=244867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Aug 12 23:04:37 2015<br>
@@ -705,6 +705,10 @@ static void ParseDependencyOutputArgs(De<br>
       Args.getLastArgValue(OPT_module_dependency_dir);<br>
   if (Args.hasArg(OPT_MV))<br>
     Opts.OutputFormat = DependencyOutputFormat::NMake;<br>
+  // Add sanitizer blacklists as extra dependencies.<br>
+  // They won't be discovered by the regular preprocessor, so<br>
+  // we let make / ninja to know about this implicit dependency.<br>
+  Opts.ExtraDeps = Args.getAllArgValues(OPT_fsanitize_blacklist);<br>
 }<br>
<br>
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,<br>
<br>
Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244867&r1=244866&r2=244867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244867&r1=244866&r2=244867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Wed Aug 12 23:04:37 2015<br>
@@ -182,7 +182,11 @@ public:<br>
       AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),<br>
       SeenMissingHeader(false),<br>
       IncludeModuleFiles(Opts.IncludeModuleFiles),<br>
-      OutputFormat(Opts.OutputFormat) {}<br>
+      OutputFormat(Opts.OutputFormat) {<br>
+    for (auto ExtraDep : Opts.ExtraDeps) {<br>
+      AddFilename(ExtraDep);<br>
+    }<br>
+  }<br>
<br>
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,<br>
                    SrcMgr::CharacteristicKind FileType,<br>
<br>
Modified: cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp?rev=244867&r1=244866&r2=244867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp?rev=244867&r1=244866&r2=244867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp Wed Aug 12 23:04:37 2015<br>
@@ -46,7 +46,36 @@ public:<br>
 };<br>
 }<br>
<br>
-void clang::AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders,<br>
+static void PrintHeaderInfo(raw_ostream *OutputFile, const char* Filename,<br>
+                            bool ShowDepth, unsigned CurrentIncludeDepth,<br>
+                            bool MSStyle) {<br>
+    // Write to a temporary string to avoid unnecessary flushing on errs().<br>
+    SmallString<512> Pathname(Filename);<br>
+    if (!MSStyle)<br>
+      Lexer::Stringify(Pathname);<br>
+<br>
+    SmallString<256> Msg;<br>
+    if (MSStyle)<br>
+      Msg += "Note: including file:";<br>
+<br>
+    if (ShowDepth) {<br>
+      // The main source file is at depth 1, so skip one dot.<br>
+      for (unsigned i = 1; i != CurrentIncludeDepth; ++i)<br>
+        Msg += MSStyle ? ' ' : '.';<br>
+<br>
+      if (!MSStyle)<br>
+        Msg += ' ';<br>
+    }<br>
+    Msg += Pathname;<br>
+    Msg += '\n';<br>
+<br>
+    OutputFile->write(Msg.data(), Msg.size());<br>
+    OutputFile->flush();<br>
+}<br>
+<br>
+void clang::AttachHeaderIncludeGen(Preprocessor &PP,<br>
+                                   const std::vector<std::string> &ExtraHeaders,<br>
+                                   bool ShowAllHeaders,<br>
                                    StringRef OutputPath, bool ShowDepth,<br>
                                    bool MSStyle) {<br>
   raw_ostream *OutputFile = MSStyle ? &llvm::outs() : &llvm::errs();<br>
@@ -69,6 +98,14 @@ void clang::AttachHeaderIncludeGen(Prepr<br>
     }<br>
   }<br>
<br>
+  // Print header info for extra headers, pretending they were discovered<br>
+  // by the regular preprocessor. The primary use case is to support<br>
+  // proper generation of Make / Ninja file dependencies for implicit includes,<br>
+  // such as sanitizer blacklists. It's only important for cl.exe<br>
+  // compatibility, the GNU way to generate rules is -M / -MM / -MD / -MMD.<br>
+  for (auto Header : ExtraHeaders) {<br>
+    PrintHeaderInfo(OutputFile, Header.c_str(), ShowDepth, 2, MSStyle);<br>
+  }<br>
   PP.addPPCallbacks(llvm::make_unique<HeaderIncludesCallback>(&PP,<br>
                                                               ShowAllHeaders,<br>
                                                               OutputFile,<br>
@@ -112,27 +149,7 @@ void HeaderIncludesCallback::FileChanged<br>
   // Dump the header include information we are past the predefines buffer or<br>
   // are showing all headers.<br>
   if (ShowHeader && Reason == PPCallbacks::EnterFile) {<br>
-    // Write to a temporary string to avoid unnecessary flushing on errs().<br>
-    SmallString<512> Filename(UserLoc.getFilename());<br>
-    if (!MSStyle)<br>
-      Lexer::Stringify(Filename);<br>
-<br>
-    SmallString<256> Msg;<br>
-    if (MSStyle)<br>
-      Msg += "Note: including file:";<br>
-<br>
-    if (ShowDepth) {<br>
-      // The main source file is at depth 1, so skip one dot.<br>
-      for (unsigned i = 1; i != CurrentIncludeDepth; ++i)<br>
-        Msg += MSStyle ? ' ' : '.';<br>
-<br>
-      if (!MSStyle)<br>
-        Msg += ' ';<br>
-    }<br>
-    Msg += Filename;<br>
-    Msg += '\n';<br>
-<br>
-    OutputFile->write(Msg.data(), Msg.size());<br>
-    OutputFile->flush();<br>
+    PrintHeaderInfo(OutputFile, UserLoc.getFilename(),<br>
+                    ShowDepth, CurrentIncludeDepth, MSStyle);<br>
   }<br>
 }<br>
<br>
Modified: cfe/trunk/test/Frontend/dependency-gen.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=244867&r1=244866&r2=244867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=244867&r1=244866&r2=244867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Frontend/dependency-gen.c (original)<br>
+++ cfe/trunk/test/Frontend/dependency-gen.c Wed Aug 12 23:04:37 2015<br>
@@ -20,7 +20,16 @@<br>
 // RUN: cd a/b<br>
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s<br>
 // CHECK-SIX: {{ }}x.h<br>
-<br>
+// RUN: echo "fun:foo" > %t.blacklist<br>
+// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s<br>
+// CHECK-SEVEN: .blacklist<br>
+// CHECK-SEVEN: {{ }}x.h<br>
+// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=address -flto -I . | FileCheck -check-prefix=CHECK-EIGHT %s<br>
+// CHECK-EIGHT: asan_blacklist.txt<br>
+// CHECK-EIGHT: {{ }}x.h<br>
+// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=address -flto -I . -fno-sanitize-blacklist | FileCheck -check-prefix=CHECK-NINE %s<br>
+// CHECK-NINE-NOT: asan_blacklist.txt<br>
+// CHECK-NINE: {{ }}x.h<br>
 #ifndef INCLUDE_FLAG_TEST<br>
 #include <x.h><br>
 #endif<br>
<br>
Modified: cfe/trunk/test/Frontend/print-header-includes.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/print-header-includes.c?rev=244867&r1=244866&r2=244867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/print-header-includes.c?rev=244867&r1=244866&r2=244867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Frontend/print-header-includes.c (original)<br>
+++ cfe/trunk/test/Frontend/print-header-includes.c Wed Aug 12 23:04:37 2015<br>
@@ -13,4 +13,12 @@<br>
 // MS: Note: including file:  {{.*test2.h}}<br>
 // MS-NOT: Note<br>
<br>
+// RUN: echo "fun:foo" > %t.blacklist<br>
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t.blacklist -E --show-includes -o %t.out %s > %t.stdout<br>
+// RUN: FileCheck --check-prefix=MS-BLACKLIST < %t.stdout %s<br>
+// MS-BLACKLIST: Note: including file: {{.*\.blacklist}}<br>
+// MS-BLACKLIST: Note: including file: {{.*test.h}}<br>
+// MS-BLACKLIST: Note: including file:  {{.*test2.h}}<br>
+// MS-BLACKLIST-NOT: Note<br>
+<br>
 #include "Inputs/test.h"<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>