[PATCH] D32341: Fix a bug that warnings generated with -M or -MM flags

Yuka Takahashi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 27 16:24:58 PDT 2017


yamaguchi updated this revision to Diff 97019.
yamaguchi added a comment.

Add testcase


https://reviews.llvm.org/D32341

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/m_and_mm.c


Index: test/Driver/m_and_mm.c
===================================================================
--- test/Driver/m_and_mm.c
+++ test/Driver/m_and_mm.c
@@ -1,3 +1,15 @@
 // RUN: %clang -### \
 // RUN:   -M -MM %s 2> %t
 // RUN: not grep '"-sys-header-deps"' %t
+
+// RUN: %clang -M -MM %s 2> %t
+// RUN: not grep "warning" %t
+
+// RUN: %clang -MMD -MD %s 2> %t
+// RUN: grep "warning" %t
+
+#warning "This warning shouldn't show up with -M and -MM"
+int main (void)
+{
+    return 0;
+}
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -980,6 +980,9 @@
         DepTarget = Args.MakeArgString(llvm::sys::path::filename(P));
       }
 
+      if (!A->getOption().matches(options::OPT_MD) && !A->getOption().matches(options::OPT_MMD)) {
+        CmdArgs.push_back("-w");
+      }
       CmdArgs.push_back("-MT");
       SmallString<128> Quoted;
       QuoteTarget(DepTarget, Quoted);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32341.97019.patch
Type: text/x-patch
Size: 1016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170427/b11f9c2b/attachment.bin>


More information about the cfe-commits mailing list