diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-21 19:36:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-21 19:36:32 +0000 |
commit | c18c42345636e2866fed75c7e434fb659d747672 (patch) | |
tree | 31a128be6a47b71082d8ca0dea883dd19a4b77be /lib/AST/ExprConstant.cpp | |
parent | 1052c1dc52447643dac5484d3a22ab836c781f47 (diff) |
Add driver arguments -ftemplate-depth=N and -fconstexpr-depth=N, with the same
semantics and defaults as the corresponding g++ arguments. The historical g++
argument -ftemplate-depth-N is kept for compatibility, but modern g++ versions
no longer document that option.
Add -cc1 argument -fconstexpr-depth N to implement the corresponding
functionality.
The -ftemplate-depth=N part of this fixes PR9890.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145045 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 16 |
1 files changed, 8 insertions, 8 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()); |