[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc abandoned this revision.
mibintc added a comment.

I'll modify this to be a cc1 only option, there doesn't seem to be community 
interest.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61743/new/

https://reviews.llvm.org/D61743



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@rjmccall Can you take a look at this patch or recommend someone who can review 
it? Many thanks. --Melanie


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61743/new/

https://reviews.llvm.org/D61743



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-17 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@dexonsmith Can you take a look at this patch or recommend someone who can 
review it?  Many thanks. --Melanie


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61743/new/

https://reviews.llvm.org/D61743



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-10 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 199082.
mibintc added a comment.

respond to suggestion from @xbolva00 (thanks).  Added a test case where prefix 
fails to match


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61743/new/

https://reviews.llvm.org/D61743

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/DependencyOutputOptions.h
  lib/Driver/ToolChains/Clang.cpp
  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
@@ -5,6 +5,11 @@
 // RUN: cd %t.dir
 // RUN: %clang -MD -MF - %s -fsyntax-only -I a/b | FileCheck -check-prefix=CHECK-ONE %s
 // CHECK-ONE: {{ }}a{{[/\\]}}b{{[/\\]}}x.h
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b -MD-filter="a/b" | FileCheck -check-prefix=CHECK-FILTER %s
+// CHECK-FILTER-NOT: {{ }}a{{[/\\]}}b{{[/\\]}}x.h
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b -MD-filter="a/b" | FileCheck -check-prefix=CHECK-WS %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b -MD-filter="fail" | FileCheck -check-prefix=CHECK-ONE %s
+// CHECK-WS: {{^ *$}}
 
 // PR8974 (-include flag)
 // RUN: %clang -MD -MF - %s -fsyntax-only -include a/b/x.h -DINCLUDE_FLAG_TEST | FileCheck -check-prefix=CHECK-TWO %s
Index: lib/Frontend/DependencyFile.cpp
===
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -154,6 +154,7 @@
   llvm::StringSet<> FilesSet;
   const Preprocessor *PP;
   std::string OutputFile;
+  std::string DependencyFilter;
   std::vector Targets;
   bool IncludeSystemHeaders;
   bool PhonyTarget;
@@ -170,7 +171,8 @@
 
 public:
   DFGImpl(const Preprocessor *_PP, const DependencyOutputOptions &Opts)
-: PP(_PP), OutputFile(Opts.OutputFile), Targets(Opts.Targets),
+: PP(_PP), OutputFile(Opts.OutputFile),
+  DependencyFilter(Opts.DependencyFilter), Targets(Opts.Targets),
   IncludeSystemHeaders(Opts.IncludeSystemHeaders),
   PhonyTarget(Opts.UsePhonyTargets),
   AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),
@@ -273,6 +275,12 @@
   if (isSpecialFilename(Filename))
 return false;
 
+  if (DependencyFilter.size() &&
+  DependencyFilter.compare(0, DependencyFilter.size(), Filename,
+   DependencyFilter.size()) == 0)
+// Remove dependencies that are prefixed by the Filter string.
+return false;
+
   if (IncludeSystemHeaders)
 return true;
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1340,6 +1340,7 @@
 static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
   ArgList &Args) {
   Opts.OutputFile = Args.getLastArgValue(OPT_dependency_file);
+  Opts.DependencyFilter = Args.getLastArgValue(OPT_dependency_filter);
   Opts.Targets = Args.getAllArgValues(OPT_MT);
   Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
   Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1118,6 +1118,11 @@
   CmdArgs.push_back("-module-file-deps");
   }
 
+  if (Arg *MD_Filter = Args.getLastArg(options::OPT_MD_filter)) {
+CmdArgs.push_back("-dependency-filter");
+CmdArgs.push_back(MD_Filter->getValue());
+  }
+
   if (Args.hasArg(options::OPT_MG)) {
 if (!A || A->getOption().matches(options::OPT_MD) ||
 A->getOption().matches(options::OPT_MMD))
Index: include/clang/Frontend/DependencyOutputOptions.h
===
--- include/clang/Frontend/DependencyOutputOptions.h
+++ include/clang/Frontend/DependencyOutputOptions.h
@@ -41,6 +41,10 @@
   /// The file to write dependency output to.
   std::string OutputFile;
 
+  /// Dependency output which is prefixed with this string is filtered
+  /// from the dependency output.
+  std::string DependencyFilter;
+
   /// The file to write header include output to. This is orthogonal to
   /// ShowHeaderIncludes (-H) and will include headers mentioned in the
   /// predefines buffer. If the output file is "-", output will be sent to
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -368,6 +368,8 @@
 HelpText<"Like -MD, but also implies -E and writes to stdout by default">;
 def MM : Flag<["-"], "MM">, Group,
 HelpText<"Like -MMD, but also implies -E and writes to stdout by default">;
+def MD_filter : Joined<["-"], "MD-filter=">, Gro

[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: lib/Frontend/DependencyFile.cpp:279
+  if (DependencyFilter.size() &&
+  strncmp(Filename, DependencyFilter.c_str(), DependencyFilter.size()) == 
0)
+// Remove dependencies that are prefixed by the Filter string.

xbolva00 wrote:
> mibintc wrote:
> > I wasn't sure about using strncmp to do the prefix comparison, but i 
> > checked around in the clang code and saw strncmp used in several places so 
> > I thought it would be acceptable. 
> DependencyFilter.compare(Filename)?
They are overloads with pos and len.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61743/new/

https://reviews.llvm.org/D61743



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: lib/Frontend/DependencyFile.cpp:279
+  if (DependencyFilter.size() &&
+  strncmp(Filename, DependencyFilter.c_str(), DependencyFilter.size()) == 
0)
+// Remove dependencies that are prefixed by the Filter string.

mibintc wrote:
> I wasn't sure about using strncmp to do the prefix comparison, but i checked 
> around in the clang code and saw strncmp used in several places so I thought 
> it would be acceptable. 
DependencyFilter.compare(Filename)?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61743/new/

https://reviews.llvm.org/D61743



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added a comment.

added an inline comment about the use of strncmp




Comment at: lib/Frontend/DependencyFile.cpp:279
+  if (DependencyFilter.size() &&
+  strncmp(Filename, DependencyFilter.c_str(), DependencyFilter.size()) == 
0)
+// Remove dependencies that are prefixed by the Filter string.

I wasn't sure about using strncmp to do the prefix comparison, but i checked 
around in the clang code and saw strncmp used in several places so I thought it 
would be acceptable. 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61743/new/

https://reviews.llvm.org/D61743



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: clang-c, fedor.sergeev.
mibintc added a project: clang.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Intel is developing an offload compiler based on clang (that will eventually be 
contributed to open source). In the course of the compilation many temporary .h 
files are generated in /tmp.  We'd like to have a way of eliding these 
dependencies from the -MD output. This new option -MD-filter=prefixstring is 
proposed.


Repository:
  rL LLVM

https://reviews.llvm.org/D61743

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/DependencyOutputOptions.h
  lib/Driver/ToolChains/Clang.cpp
  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
@@ -5,6 +5,10 @@
 // RUN: cd %t.dir
 // RUN: %clang -MD -MF - %s -fsyntax-only -I a/b | FileCheck -check-prefix=CHECK-ONE %s
 // CHECK-ONE: {{ }}a{{[/\\]}}b{{[/\\]}}x.h
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b -MD-filter="a/b" | FileCheck -check-prefix=CHECK-FILTER %s
+// CHECK-FILTER-NOT: {{ }}a{{[/\\]}}b{{[/\\]}}x.h
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b -MD-filter="a/b" | FileCheck -check-prefix=CHECK-WS %s
+// CHECK-WS: {{^ *$}}
 
 // PR8974 (-include flag)
 // RUN: %clang -MD -MF - %s -fsyntax-only -include a/b/x.h -DINCLUDE_FLAG_TEST | FileCheck -check-prefix=CHECK-TWO %s
Index: lib/Frontend/DependencyFile.cpp
===
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -154,6 +154,7 @@
   llvm::StringSet<> FilesSet;
   const Preprocessor *PP;
   std::string OutputFile;
+  std::string DependencyFilter;
   std::vector Targets;
   bool IncludeSystemHeaders;
   bool PhonyTarget;
@@ -170,7 +171,8 @@
 
 public:
   DFGImpl(const Preprocessor *_PP, const DependencyOutputOptions &Opts)
-: PP(_PP), OutputFile(Opts.OutputFile), Targets(Opts.Targets),
+: PP(_PP), OutputFile(Opts.OutputFile),
+  DependencyFilter(Opts.DependencyFilter), Targets(Opts.Targets),
   IncludeSystemHeaders(Opts.IncludeSystemHeaders),
   PhonyTarget(Opts.UsePhonyTargets),
   AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),
@@ -273,6 +275,11 @@
   if (isSpecialFilename(Filename))
 return false;
 
+  if (DependencyFilter.size() &&
+  strncmp(Filename, DependencyFilter.c_str(), DependencyFilter.size()) == 0)
+// Remove dependencies that are prefixed by the Filter string.
+return false;
+
   if (IncludeSystemHeaders)
 return true;
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1340,6 +1340,7 @@
 static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
   ArgList &Args) {
   Opts.OutputFile = Args.getLastArgValue(OPT_dependency_file);
+  Opts.DependencyFilter = Args.getLastArgValue(OPT_dependency_filter);
   Opts.Targets = Args.getAllArgValues(OPT_MT);
   Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
   Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1118,6 +1118,11 @@
   CmdArgs.push_back("-module-file-deps");
   }
 
+  if (Arg *MD_Filter = Args.getLastArg(options::OPT_MD_filter)) {
+CmdArgs.push_back("-dependency-filter");
+CmdArgs.push_back(MD_Filter->getValue());
+  }
+
   if (Args.hasArg(options::OPT_MG)) {
 if (!A || A->getOption().matches(options::OPT_MD) ||
 A->getOption().matches(options::OPT_MMD))
Index: include/clang/Frontend/DependencyOutputOptions.h
===
--- include/clang/Frontend/DependencyOutputOptions.h
+++ include/clang/Frontend/DependencyOutputOptions.h
@@ -41,6 +41,10 @@
   /// The file to write dependency output to.
   std::string OutputFile;
 
+  /// Dependency output which is prefixed with this string is filtered
+  /// from the dependency output.
+  std::string DependencyFilter;
+
   /// The file to write header include output to. This is orthogonal to
   /// ShowHeaderIncludes (-H) and will include headers mentioned in the
   /// predefines buffer. If the output file is "-", output will be sent to
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -368,6 +368,8 @@
 HelpText<"Like -MD, but also implies -E and writes to stdout by default">;
 def MM : Flag<["-"], "MM">,