]> granicus.if.org Git - clang/commitdiff
Work around an MSVC2017 update 3 codegen bug.
authorNico Weber <nicolasweber@gmx.de>
Mon, 24 Jul 2017 16:54:11 +0000 (16:54 +0000)
committerNico Weber <nicolasweber@gmx.de>
Mon, 24 Jul 2017 16:54:11 +0000 (16:54 +0000)
C2017 update 3 produces a clang that crashes when compiling clang. Disabling
optimizations for StmtProfiler::VisitCXXOperatorCallExpr() makes the crash go
away.

Patch from Bruce Dawson <brucedawson@chromium.org>!
https://reviews.llvm.org/D35757

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

lib/AST/StmtProfile.cpp

index a86fded2a2c47cdec6373b568dea0b7ef01a571a..72efca00403b411beb9f97d073aad3d44ebe67ef 100644 (file)
@@ -1412,6 +1412,15 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
   llvm_unreachable("Invalid overloaded operator expression");
 }
 
+#if defined(_MSC_VER)
+#if _MSC_VER == 1911
+// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
+// MSVC 2017 update 3 miscompiles this function, and a clang built with it
+// will crash in stage 2 of a bootstrap build.
+#pragma optimize("", off)
+#endif
+#endif
+
 void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
   if (S->isTypeDependent()) {
     // Type-dependent operator calls are profiled like their underlying
@@ -1444,6 +1453,12 @@ void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
   ID.AddInteger(S->getOperator());
 }
 
+#if defined(_MSC_VER)
+#if _MSC_VER == 1911
+#pragma optimize("", on)
+#endif
+#endif
+
 void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
   VisitCallExpr(S);
 }