Skip to content

Commit

Permalink
Update bootstrap for function that can return nullptr (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumarak authored Mar 11, 2024
1 parent f6e0e9f commit bb065e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions bin/BootstrapTypes/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@ std::set<std::pair<std::string, std::string>> kCanReturnNullptr{
{"OpaqueValueExpr", "SourceExpression"},
{"DependentSizedArrayType", "SizeExpression"},
{"CXXRecordDecl", "LambdaStaticInvoker"},
{"CoroutineBodyStmt", "ResultDeclaration"},

// {"FunctionProtoType", "EllipsisToken"},
// {"FunctionDecl", "EllipsisToken"},
Expand Down
2 changes: 1 addition & 1 deletion include/pasta/AST/Stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ class CoroutineBodyStmt : public Stmt {
std::vector<::pasta::Stmt> ParameterMoves(void) const;
::pasta::VarDecl PromiseDeclaration(void) const;
::pasta::Stmt PromiseDeclarationStatement(void) const;
::pasta::Stmt ResultDeclaration(void) const;
std::optional<::pasta::Stmt> ResultDeclaration(void) const;
::pasta::Stmt ReturnStatement(void) const;
::pasta::Stmt ReturnStatementOnAllocFailure(void) const;
::pasta::Expr ReturnValue(void) const;
Expand Down
6 changes: 4 additions & 2 deletions lib/AST/Stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2861,13 +2861,15 @@ ::pasta::Stmt CoroutineBodyStmt::PromiseDeclarationStatement(void) const {
throw std::runtime_error("CoroutineBodyStmt::PromiseDeclarationStatement can return nullptr!");
}

::pasta::Stmt CoroutineBodyStmt::ResultDeclaration(void) const {
std::optional<::pasta::Stmt> CoroutineBodyStmt::ResultDeclaration(void) const {
auto &self = *const_cast<clang::CoroutineBodyStmt *>(u.CoroutineBodyStmt);
decltype(auto) val = self.getResultDecl();
if (!val) {
return std::nullopt;
}
if (val) {
return StmtBuilder::Create<::pasta::Stmt>(ast, val);
}
throw std::runtime_error("CoroutineBodyStmt::ResultDeclaration can return nullptr!");
}

::pasta::Stmt CoroutineBodyStmt::ReturnStatement(void) const {
Expand Down

0 comments on commit bb065e3

Please sign in to comment.