r305561 - Fix a bug that warnings generated with -M or -MM flags
Yuka Takahashi via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 16 09:01:13 PDT 2017
Author: yamaguchi
Date: Fri Jun 16 11:01:13 2017
New Revision: 305561
URL: http://llvm.org/viewvc/llvm-project?rev=305561&view=rev
Log:
Fix a bug that warnings generated with -M or -MM flags
This is a patch for bug: https://bugs.llvm.org/show_bug.cgi?id=6817
Warnings should not be emitted with -M and -MM flags, because this mode
is only used for generate MakeFiles.
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/m_and_mm.c
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=305561&r1=305560&r2=305561&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Jun 16 11:01:13 2017
@@ -980,6 +980,9 @@ void Clang::AddPreprocessingOptions(Comp
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);
Modified: cfe/trunk/test/Driver/m_and_mm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/m_and_mm.c?rev=305561&r1=305560&r2=305561&view=diff
==============================================================================
--- cfe/trunk/test/Driver/m_and_mm.c (original)
+++ cfe/trunk/test/Driver/m_and_mm.c Fri Jun 16 11:01:13 2017
@@ -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;
+}
More information about the cfe-commits
mailing list