]> granicus.if.org Git - clang/commitdiff
clang-cl: Hook up /Za to prevent adding oldnames.lib dependency
authorHans Wennborg <hans@hanshq.net>
Thu, 8 Aug 2013 16:54:31 +0000 (16:54 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 8 Aug 2013 16:54:31 +0000 (16:54 +0000)
The /Za flag should probably do more, but let's start with this.

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

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

include/clang/Driver/CLCompatOptions.td
lib/Driver/Tools.cpp
test/Driver/cl-Za.c [new file with mode: 0644]

index e98d8e851649752c870ae9ccd55fbf0574d2f4b4..197ae9ebe5fa7037c95195e33a77d2ff2feafdfe 100644 (file)
@@ -98,6 +98,7 @@ def _SLASH_TC : CLFlag<"TC">, HelpText<"Treat all source files as C">;
 def _SLASH_Tp : CLJoinedOrSeparate<"Tp">, HelpText<"Specify a C++ source file">,
   MetaVarName<"<filename>">;
 def _SLASH_TP : CLFlag<"TP">, HelpText<"Treat all source files as C++">;
+def _SLASH_Za : CLFlag<"Za">;
 
 
 // Ignored:
index fb27bfde628cb04081e640ec3da5b5ea7c2d1ca1..a1193f547336c0ca5699bae08dee6443b7f2b166 100644 (file)
@@ -3719,10 +3719,11 @@ void Clang::AddClangCLArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
       llvm_unreachable("Unexpected option ID.");
   }
 
-  // This provides POSIX compatibility (maps 'open' to '_open'), which most users
-  // want.  MSVC has a switch to turn off this autolinking, but it's not
-  // implemented in clang yet.
-  CmdArgs.push_back("--dependent-lib=oldnames");
+  if (!Args.hasArg(options::OPT__SLASH_Za)) {
+    // This provides POSIX compatibility (maps 'open' to '_open'),
+    // which most users want.
+    CmdArgs.push_back("--dependent-lib=oldnames");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
diff --git a/test/Driver/cl-Za.c b/test/Driver/cl-Za.c
new file mode 100644 (file)
index 0000000..b1cb0b7
--- /dev/null
@@ -0,0 +1,11 @@
+// Don't attempt slash switches on msys bash.
+// REQUIRES: shell-preserves-root
+
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
+// DEFAULT: "--dependent-lib=oldnames"
+
+// RUN: %clang_cl /Za -### -- %s 2>&1 | FileCheck -check-prefix=Za %s
+// Za-NOT: "--dependent-lib=oldnames"