]> granicus.if.org Git - clang/commitdiff
clang-cl: Don't warn about overriding /MD with /MT, /Fo with another /Fo, etc.
authorHans Wennborg <hans@hanshq.net>
Wed, 18 Sep 2013 22:26:39 +0000 (22:26 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 18 Sep 2013 22:26:39 +0000 (22:26 +0000)
I put in the warnings because MSVC has them, but I don't think they're very
useful.

Clang does not warn about overriding flags in general, e.g. it's perfectly
fine to have -fomit-frame-pointer followed by -fno-omit-frame-pointer.

We should focus on warning where things get confusing, such as with the
/TP and /TC options. In "clang-cl /TC a.c /TP b.cc", the user might not
realize that the /TP flag will apply to both files, and we warn about that.

Differential Revision: http://llvm-reviews.chandlerc.com/D1718

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190964 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticDriverKinds.td
lib/Driver/Driver.cpp
lib/Driver/Tools.cpp
test/Driver/cl-outputs.c
test/Driver/cl-runtime-flags.c

index 2f69e5de8eb401ed12c74ecb5a873b84b58f1c82..9c9893e9e61e6feeb38eadf08206c810707a8094 100644 (file)
@@ -138,9 +138,6 @@ def warn_drv_assuming_mfloat_abi_is : Warning<
   "unknown platform, assuming -mfloat-abi=%0">;
 def warn_ignoring_ftabstop_value : Warning<
   "ignoring invalid -ftabstop value '%0', using default value %1">;
-def warn_drv_overriding_joined_option : Warning<
-  "overriding '%0%1' option with '%2%3'">,
-  InGroup<DiagGroup<"overriding-fo-option">>;
 def warn_drv_overriding_flag_option : Warning<
   "overriding '%0' option with '%1'">,
   InGroup<DiagGroup<"overriding-t-option">>;
index 7ad09accd8c73a76508d421046891a01db7ab9a8..a2cf06a20cdc427f462b57be80ddf81d0e5b71d5 100644 (file)
@@ -284,26 +284,6 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
   return DAL;
 }
 
-/// \brief Check whether there are multiple instances of OptionID in Args, and
-/// if so, issue a diagnostics about it.
-static void DiagnoseOptionOverride(const Driver &D, const DerivedArgList &Args,
-                                   unsigned OptionID) {
-  assert(Args.hasArg(OptionID));
-
-  arg_iterator it = Args.filtered_begin(OptionID);
-  arg_iterator ie = Args.filtered_end();
-  Arg *Previous = *it;
-  ++it;
-
-  while (it != ie) {
-    D.Diag(clang::diag::warn_drv_overriding_joined_option)
-        << Previous->getSpelling() << Previous->getValue()
-        << (*it)->getSpelling() << (*it)->getValue();
-    Previous = *it;
-    ++it;
-  }
-}
-
 Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
   llvm::PrettyStackTraceString CrashInfo("Compilation construction");
 
@@ -1158,7 +1138,6 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
 
   // Diagnose misuse of /Fo.
   if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fo)) {
-    DiagnoseOptionOverride(*this, Args, options::OPT__SLASH_Fo);
     StringRef V = A->getValue();
     if (V.empty()) {
       // It has to have a value.
@@ -1174,7 +1153,6 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
 
   // Diagnose misuse of /Fe.
   if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fe)) {
-    DiagnoseOptionOverride(*this, Args, options::OPT__SLASH_Fe);
     if (A->getValue()[0] == '\0') {
       // It has to have a value.
       Diag(clang::diag::err_drv_missing_argument) << A->getSpelling() << 1;
index a728b4dc81ca5bbbbcd677ed06687abcfa39334c..c71514064f79da68b167ca88f6d00c7406c8619c 100644 (file)
@@ -3724,21 +3724,9 @@ void Clang::AddClangCLArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
     // but defining _DEBUG is sticky.
     RTOptionID = options::OPT__SLASH_MTd;
 
-  if (Arg *A = Args.getLastArg(options::OPT__SLASH_M_Group)) {
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_M_Group))
     RTOptionID = A->getOption().getID();
 
-    // Diagnose overrides.
-    arg_iterator it = Args.filtered_begin(options::OPT__SLASH_M_Group);
-    Arg *Previous = *it++;
-    const arg_iterator ie = Args.filtered_end();
-    while (it != ie) {
-      const Driver &D = getToolChain().getDriver();
-      D.Diag(clang::diag::warn_drv_overriding_flag_option)
-        << Previous->getSpelling() << (*it)->getSpelling();
-      Previous = *it++;
-    }
-  }
-
   switch(RTOptionID) {
     case options::OPT__SLASH_MD:
       if (Args.hasArg(options::OPT__SLASH_LDd))
index 636ef96f60da73c46cc50d12dcc9a05fd93dea8d..82134b05626f9bb4a2a9514cb459af08751acc12 100644 (file)
@@ -11,7 +11,6 @@
 // FoNAME:  "-o" "a.obj"
 
 // RUN: %clang_cl /Foa.ext /Fob.ext -### -- %s 2>&1 | FileCheck -check-prefix=FoNAMEEXT %s
-// FoNAMEEXT:  warning: overriding '/Foa.ext' option with '/Fob.ext'
 // FoNAMEEXT:  "-o" "b.ext"
 
 // RUN: %clang_cl /Fofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FoDIR %s
@@ -88,5 +87,4 @@
 // FeMISSINGARG: error: argument to '/Fe' is missing (expected 1 value)
 
 // RUN: %clang_cl /Fefoo /Febar -### -- %s 2>&1 | FileCheck -check-prefix=FeOVERRIDE %s
-// FeOVERRIDE: warning: overriding '/Fefoo' option with '/Febar'
 // FeOVERRIDE: "-out:bar.exe"
index 11a5e94876773216532da0a782abb4d86ca0baf0..8367531f9ccb1849b24507782971bd89b3faf481 100644 (file)
@@ -86,5 +86,4 @@
 // CHECK-LDMDd: "--dependent-lib=msvcrtd"
 
 // RUN: %clang_cl /MD /MT -### -- %s 2>&1 | FileCheck -check-prefix=MTOVERRIDE %s
-// MTOVERRIDE: warning: overriding '/MD' option with '/MT'
 // MTOVERRIDE: "--dependent-lib=libcmt"