]> granicus.if.org Git - clang/commitdiff
clang-cl: ignore /showIncludes when combined with /E (PR20336)
authorHans Wennborg <hans@hanshq.net>
Mon, 21 Jul 2014 23:42:07 +0000 (23:42 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 21 Jul 2014 23:42:07 +0000 (23:42 +0000)
Both /showIncludes and /E write to stdout. Allowing both results
in interleaved output and an error when double-closing the file
descriptor, intended to catch issues like this.

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

lib/Driver/Tools.cpp
test/Driver/cl-options.c

index e9d740bdc7b40c2e9b71e41047f102a1801f4605..f62cb851966c1a2fdcab7d0df154733ed84f0006 100644 (file)
@@ -4640,8 +4640,11 @@ void Clang::AddClangCLArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
   // implemented in clang.
   CmdArgs.push_back("--dependent-lib=oldnames");
 
-  if (Arg *A = Args.getLastArg(options::OPT_show_includes))
-    A->render(Args, CmdArgs);
+  // Both /showIncludes and /E (and /EP) write to stdout. Allowing both
+  // would produce interleaved output, so ignore /showIncludes in such cases.
+  if (!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP))
+    if (Arg *A = Args.getLastArg(options::OPT_show_includes))
+      A->render(Args, CmdArgs);
 
   // This controls whether or not we emit RTTI data for polymorphic types.
   if (Args.hasFlag(options::OPT__SLASH_GR_, options::OPT__SLASH_GR,
index b5e9722066e6d5befac4962c47f2ba6444243620..26cd7e9eb4c6b4a41f05c8e155d8d0b21ec24ef3 100644 (file)
 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
 // showIncludes: --show-includes
 
+// RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
+// RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
+// showIncludes_E: warning: argument unused during compilation: '--show-includes'
+
 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"