]> granicus.if.org Git - clang/commitdiff
clang-cl: Pass /Zc:threadSafeInit through to MSVC with /fallback (PR30948)
authorHans Wennborg <hans@hanshq.net>
Wed, 9 Nov 2016 00:56:42 +0000 (00:56 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 9 Nov 2016 00:56:42 +0000 (00:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286324 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 386b1d3bd2cdedf064ac6156046586710176e73c..45ba6996520c0b1be30b3730a5bb184c493ea97c 100644 (file)
@@ -10978,6 +10978,14 @@ std::unique_ptr<Command> visualstudio::Compiler::GetCommand(
                                options::OPT__SLASH_MT, options::OPT__SLASH_MTd))
     A->render(Args, CmdArgs);
 
+  // Use MSVC's default threadsafe statics behaviour unless there was a flag.
+  if (Arg *A = Args.getLastArg(options::OPT_fthreadsafe_statics,
+                               options::OPT_fno_threadsafe_statics)) {
+    CmdArgs.push_back(A->getOption().getID() == options::OPT_fthreadsafe_statics
+                          ? "/Zc:threadSafeInit"
+                          : "/Zc:threadSafeInit-");
+  }
+
   // Pass through all unknown arguments so that the fallback command can see
   // them too.
   Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
index e73f7c03c26307f386e1babb459886b947c85120..2e5698ce9f9fe6cc7006d2fe8d4fcd4336614a6b 100644 (file)
 // GS: cl.exe
 // GS: "/GS-"
 
+// RUN: %clang_cl /fallback /Zc:threadSafeInit -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafe %s
+// ThreadSafe: /Zc:threadSafeInit
+
+// RUN: %clang_cl /fallback /Zc:threadSafeInit- -### -- %s 2>&1 | FileCheck -check-prefix=NonThreadSafe %s
+// NonThreadSafe: /Zc:threadSafeInit-
+
 // RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s
 // O0: cl.exe
 // O0: "/Od"