diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-12-10 19:03:12 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-12-10 19:03:12 +0000 |
commit | 5c1399a5823790710a6480301d9bdcae9025af59 (patch) | |
tree | 2d2023d622de2909cb5a1ca81557d9b47bbe0f83 /clang/lib/AST/ExprConstant.cpp | |
parent | 5ec146046cbb1a69850d2712f40e9ea273e2a257 (diff) | |
download | bcm5719-llvm-5c1399a5823790710a6480301d9bdcae9025af59.tar.gz bcm5719-llvm-5c1399a5823790710a6480301d9bdcae9025af59.zip |
[constexpr][c++2a] Try-catch blocks in constexpr functions
Implement support for try-catch blocks in constexpr functions, as
proposed in http://wg21.link/P1002 and voted in San Diego for c++20.
The idea is that we can still never throw inside constexpr, so the catch
block is never entered. A try-catch block like this:
try { f(); } catch (...) { }
is then morally equivalent to just
{ f(); }
Same idea should apply for function/constructor try blocks.
rdar://problem/45530773
Differential Revision: https://reviews.llvm.org/D55097
llvm-svn: 348789
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 4150a2454a5..eb690dcfabc 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -4279,6 +4279,9 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info, case Stmt::CaseStmtClass: case Stmt::DefaultStmtClass: return EvaluateStmt(Result, Info, cast<SwitchCase>(S)->getSubStmt(), Case); + case Stmt::CXXTryStmtClass: + // Evaluate try blocks by evaluating all sub statements. + return EvaluateStmt(Result, Info, cast<CXXTryStmt>(S)->getTryBlock(), Case); } } |