aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ExprConstant.cpp16
-rw-r--r--lib/Driver/Tools.cpp8
-rw-r--r--lib/Frontend/CompilerInvocation.cpp8
3 files changed, 22 insertions, 10 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index d602be4581..81fe7e3a4e 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -257,9 +257,6 @@ namespace {
/// CurrentCall - The top of the constexpr call stack.
CallStackFrame *CurrentCall;
- /// NumCalls - The number of calls we've evaluated so far.
- unsigned NumCalls;
-
/// CallStackDepth - The number of calls in the call stack right now.
unsigned CallStackDepth;
@@ -282,7 +279,7 @@ namespace {
EvalInfo(const ASTContext &C, Expr::EvalStatus &S)
- : Ctx(C), EvalStatus(S), CurrentCall(0), NumCalls(0), CallStackDepth(0),
+ : Ctx(C), EvalStatus(S), CurrentCall(0), CallStackDepth(0),
BottomFrame(*this, 0, 0), EvaluatingDecl(0), EvaluatingDeclValue(0) {}
const CCValue *getOpaqueValue(const OpaqueValueExpr *e) const {
@@ -296,7 +293,11 @@ namespace {
EvaluatingDeclValue = &Value;
}
- const LangOptions &getLangOpts() { return Ctx.getLangOptions(); }
+ const LangOptions &getLangOpts() const { return Ctx.getLangOptions(); }
+
+ bool atCallLimit() const {
+ return CallStackDepth > getLangOpts().ConstexprCallDepth;
+ }
};
CallStackFrame::CallStackFrame(EvalInfo &Info, const LValue *This,
@@ -1278,8 +1279,7 @@ static bool EvaluateArgs(ArrayRef<const Expr*> Args, ArgVector &ArgValues,
static bool HandleFunctionCall(const LValue *This, ArrayRef<const Expr*> Args,
const Stmt *Body, EvalInfo &Info,
CCValue &Result) {
- // FIXME: Implement a proper call limit, along with a command-line flag.
- if (Info.NumCalls >= 1000000 || Info.CallStackDepth >= 512)
+ if (Info.atCallLimit())
return false;
ArgVector ArgValues(Args.size());
@@ -1296,7 +1296,7 @@ static bool HandleConstructorCall(const LValue &This,
const CXXConstructorDecl *Definition,
EvalInfo &Info,
APValue &Result) {
- if (Info.NumCalls >= 1000000 || Info.CallStackDepth >= 512)
+ if (Info.atCallLimit())
return false;
ArgVector ArgValues(Args.size());
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 4229987f52..918b4551c5 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1619,11 +1619,17 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}
}
- if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_)) {
+ if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_,
+ options::OPT_ftemplate_depth_EQ)) {
CmdArgs.push_back("-ftemplate-depth");
CmdArgs.push_back(A->getValue(Args));
}
+ if (Arg *A = Args.getLastArg(options::OPT_fconstexpr_depth_EQ)) {
+ CmdArgs.push_back("-fconstexpr-depth");
+ CmdArgs.push_back(A->getValue(Args));
+ }
+
if (Arg *A = Args.getLastArg(options::OPT_Wlarge_by_value_copy_EQ,
options::OPT_Wlarge_by_value_copy_def)) {
CmdArgs.push_back("-Wlarge-by-value-copy");
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 738facf069..34080908c0 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -789,6 +789,10 @@ static void LangOptsToArgs(const LangOptions &Opts,
Res.push_back("-ftemplate-depth");
Res.push_back(llvm::utostr(Opts.InstantiationDepth));
}
+ if (Opts.ConstexprCallDepth != DefaultLangOpts.ConstexprCallDepth) {
+ Res.push_back("-fconstexpr-depth");
+ Res.push_back(llvm::utostr(Opts.ConstexprCallDepth));
+ }
if (!Opts.ObjCConstantStringClass.empty()) {
Res.push_back("-fconstant-string-class");
Res.push_back(Opts.ObjCConstantStringClass);
@@ -1777,7 +1781,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
Opts.MathErrno = Args.hasArg(OPT_fmath_errno);
Opts.InstantiationDepth = Args.getLastArgIntValue(OPT_ftemplate_depth, 1024,
- Diags);
+ Diags);
+ Opts.ConstexprCallDepth = Args.getLastArgIntValue(OPT_fconstexpr_depth, 512,
+ Diags);
Opts.DelayedTemplateParsing = Args.hasArg(OPT_fdelayed_template_parsing);
Opts.NumLargeByValueCopy = Args.getLastArgIntValue(OPT_Wlarge_by_value_copy,
0, Diags);