[clang] ded2490 - Workaround for EvalInfo ctor for MSVC 2017
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 26 18:44:22 PST 2019
Author: Yaxun (Sam) Liu
Date: 2019-11-26T21:43:29-05:00
New Revision: ded249049429a26d3748926c04bd7169f0170714
URL: https://github.com/llvm/llvm-project/commit/ded249049429a26d3748926c04bd7169f0170714
DIFF: https://github.com/llvm/llvm-project/commit/ded249049429a26d3748926c04bd7169f0170714.diff
LOG: Workaround for EvalInfo ctor for MSVC 2017
Current EvalInfo ctor causes EnableNewConstInterp to be true even though
it is supposed to be false on MSVC 2017. This is because a virtual function
getLangOpts() is called in member initializer lists, whereas on MSVC
member ctors are called before function virtual function pointers are
initialized.
This patch fixes that.
Differential Revision: https://reviews.llvm.org/D70729
Added:
clang/test/Sema/eval-info.c
Modified:
clang/lib/AST/ExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 79659261388b..eec9bbdaef80 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -921,10 +921,10 @@ namespace {
EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
: Ctx(const_cast<ASTContext &>(C)), EvalStatus(S), CurrentCall(nullptr),
CallStackDepth(0), NextCallIndex(1),
- StepsLeft(getLangOpts().ConstexprStepLimit),
- ForceNewConstInterp(getLangOpts().ForceNewConstInterp),
+ StepsLeft(C.getLangOpts().ConstexprStepLimit),
+ ForceNewConstInterp(C.getLangOpts().ForceNewConstInterp),
EnableNewConstInterp(ForceNewConstInterp ||
- getLangOpts().EnableNewConstInterp),
+ C.getLangOpts().EnableNewConstInterp),
BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
EvaluatingDecl((const ValueDecl *)nullptr),
EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
diff --git a/clang/test/Sema/eval-info.c b/clang/test/Sema/eval-info.c
new file mode 100644
index 000000000000..7f4de4b90820
--- /dev/null
+++ b/clang/test/Sema/eval-info.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-windows-msvc -verify
+
+// expected-no-diagnostics
+
+// Make sure the new constant interpolator is not enabled unintentionally
+// to cause assertion.
+typedef enum x {
+ a = 1,
+} x;
More information about the cfe-commits
mailing list