summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/docs/ReleaseNotes.rst3
-rw-r--r--clang/include/clang/Driver/CLCompatOptions.td4
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp12
-rw-r--r--clang/test/Driver/cl-options.c18
4 files changed, 24 insertions, 13 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f3291137bca..0585438d751 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -90,6 +90,9 @@ Attribute Changes in Clang
Windows Support
---------------
+- clang-cl now defaults to ``/Zc:twoPhase`` if targeting MSVC2017 update 3 or
+ later (``_MSC_VER`` >= 1911). This matches MSVC's behavior. Explicitly pass
+ ``/Zc:twoPhase-`` to restore the old behavior.
- ...
C Language Changes in Clang
diff --git a/clang/include/clang/Driver/CLCompatOptions.td b/clang/include/clang/Driver/CLCompatOptions.td
index bb51c3aa11d..bf5addb8548 100644
--- a/clang/include/clang/Driver/CLCompatOptions.td
+++ b/clang/include/clang/Driver/CLCompatOptions.td
@@ -235,10 +235,10 @@ def _SLASH_Zc_trigraphs : CLFlag<"Zc:trigraphs">,
def _SLASH_Zc_trigraphs_off : CLFlag<"Zc:trigraphs-">,
HelpText<"Disable trigraphs (default)">, Alias<fno_trigraphs>;
def _SLASH_Zc_twoPhase : CLFlag<"Zc:twoPhase">,
- HelpText<"Enable two-phase name lookup in templates">,
+ HelpText<"Enable two-phase name lookup in templates (default)">,
Alias<fno_delayed_template_parsing>;
def _SLASH_Zc_twoPhase_ : CLFlag<"Zc:twoPhase-">,
- HelpText<"Disable two-phase name lookup in templates (default)">,
+ HelpText<"Disable two-phase name lookup in templates">,
Alias<fdelayed_template_parsing>;
def _SLASH_Z7 : CLFlag<"Z7">,
HelpText<"Enable CodeView debug information in object files">;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 690d4fa3fa4..c0f914bf989 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4883,12 +4883,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
!IsWindowsMSVC || IsMSVC2015Compatible))
CmdArgs.push_back("-fno-threadsafe-statics");
- // -fno-delayed-template-parsing is default, except when targeting MSVC.
- // Many old Windows SDK versions require this to parse.
- // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
- // compiler. We should be able to disable this by default at some point.
+ // -fno-delayed-template-parsing is default, except when targeting MSVC
+ // earlier than MSVC 2017 15.3 (_MSC_VER 1911). Windows SDK versions
+ // 10.0.15063.0 (Creators Update or Redstone 2) and earlier require this to
+ // parse.
+ bool IsMSVCBefore2017Update3 = !MSVT.empty() && MSVT < VersionTuple(19, 11);
if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
- options::OPT_fno_delayed_template_parsing, IsWindowsMSVC))
+ options::OPT_fno_delayed_template_parsing,
+ IsMSVCBefore2017Update3))
CmdArgs.push_back("-fdelayed-template-parsing");
// -fgnu-keywords default varies depending on language; only pass if
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 68f08b0c18c..cb3be9ad7ea 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -316,13 +316,19 @@
// We recognize -f[no-]delayed-template-parsing.
// /Zc:twoPhase[-] has the opposite meaning.
-// RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT %s
-// DELAYEDDEFAULT: "-fdelayed-template-parsing"
-// RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
-// RUN: %clang_cl -c /Zc:twoPhase- -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
+// RUN: %clang_cl -c -fmsc-version=1910 -### -- %s 2>&1 | FileCheck -check-prefix=OLDDELAYEDDEFAULT %s
+// OLDDELAYEDDEFAULT: "-fdelayed-template-parsing"
+// RUN: %clang_cl -fmsc-version=1911 -c -### -- %s 2>&1 | FileCheck -check-prefix=NEWDELAYEDDEFAULT %s
+// NEWDELAYEDDEFAULT-NOT: "-fdelayed-template-parsing"
+// RUN: %clang_cl -c -fmsc-version=1910 -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
+// RUN: %clang_cl -c -fmsc-version=1911 -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
+// RUN: %clang_cl -c -fmsc-version=1910 /Zc:twoPhase- -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
+// RUN: %clang_cl -c -fmsc-version=1911 /Zc:twoPhase- -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
// DELAYEDON: "-fdelayed-template-parsing"
-// RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
-// RUN: %clang_cl -c /Zc:twoPhase -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
+// RUN: %clang_cl -c -fmsc-version=1910 -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
+// RUN: %clang_cl -c -fmsc-version=1911 -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
+// RUN: %clang_cl -c -fmsc-version=1910 /Zc:twoPhase -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
+// RUN: %clang_cl -c -fmsc-version=1911 /Zc:twoPhase -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
// DELAYEDOFF-NOT: "-fdelayed-template-parsing"
// RUN: %clang_cl -c -### /std:c++latest -- %s 2>&1 | FileCheck -check-prefix CHECK-LATEST-CHAR8_T %s
OpenPOWER on IntegriCloud