aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/StmtCXX.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2023-03-23 13:38:16 -0700
committerMatthias Braun <matze@braunis.de>2023-03-30 11:16:32 -0700
commite00a8d081d789cac606cf0749c332c4632132820 (patch)
tree106e860177fc49d85df5146eda1ba1576193bdef /clang/lib/AST/StmtCXX.cpp
parent3b919a5e01ef35caa24fe3a4ccc3dd459e56449b (diff)
downloadllvm-e00a8d081d789cac606cf0749c332c4632132820.zip
llvm-e00a8d081d789cac606cf0749c332c4632132820.tar.gz
llvm-e00a8d081d789cac606cf0749c332c4632132820.tar.bz2
Fix codegen for coroutine with function-try-block
This fixes an assertion error when writing a coroutine with a function-try-block. In this case the function body is not a `CompoundStmt` so the code constructing an artificial CXXTryStmt must also construct a `CompoundStmt` for it. While on it adjust the `CXXStmt::Create` function to only accept `CompoundStmt*`. Differential Revision: https://reviews.llvm.org/D146758
Diffstat (limited to 'clang/lib/AST/StmtCXX.cpp')
-rw-r--r--clang/lib/AST/StmtCXX.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/AST/StmtCXX.cpp b/clang/lib/AST/StmtCXX.cpp
index a3ae539..0d6fc84 100644
--- a/clang/lib/AST/StmtCXX.cpp
+++ b/clang/lib/AST/StmtCXX.cpp
@@ -23,7 +23,8 @@ QualType CXXCatchStmt::getCaughtType() const {
}
CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, SourceLocation tryLoc,
- Stmt *tryBlock, ArrayRef<Stmt *> handlers) {
+ CompoundStmt *tryBlock,
+ ArrayRef<Stmt *> handlers) {
const size_t Size = totalSizeToAlloc<Stmt *>(handlers.size() + 1);
void *Mem = C.Allocate(Size, alignof(CXXTryStmt));
return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers);
@@ -36,7 +37,7 @@ CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, EmptyShell Empty,
return new (Mem) CXXTryStmt(Empty, numHandlers);
}
-CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock,
+CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, CompoundStmt *tryBlock,
ArrayRef<Stmt *> handlers)
: Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) {
Stmt **Stmts = getStmts();