DeclExtractor: use BuildReturnStmt() instead

Do not use `ActOnReturnStmt()`, given that the scope returned by
`m_Sema->getCurScope()` might be == m_Sema->TUScope which obviously is
not a function scope.

This fixes the following crash:
```
1:  #3 0x0000556b6a50389e clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0x225389e)
1:  #4 0x0000556b69215c56 cling::DeclExtractor::EnforceInitOrder(llvm::SmallVector<clang::Stmt*>&) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf65c56)
1:  #5 0x0000556b69216788 cling::DeclExtractor::ExtractDecl(clang::FunctionDecl*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf66788)
1:  #6 0x0000556b69216a75 cling::DeclExtractor::Transform(clang::Decl*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf66a75)
```
This commit is contained in:
Javier Lopez-Gomez 2023-05-30 11:29:59 +02:00 committed by jenkins
parent f23f0ed9ca
commit 09fe1fd2b3

View File

@ -262,9 +262,8 @@ namespace cling {
IntegerLiteral* ZeroLit IntegerLiteral* ZeroLit
= IntegerLiteral::Create(*m_Context, ZeroInt, m_Context->IntTy, = IntegerLiteral::Create(*m_Context, ZeroInt, m_Context->IntTy,
SourceLocation()); SourceLocation());
Stmts.push_back(m_Sema->ActOnReturnStmt(ZeroLit->getExprLoc(), Stmts.push_back(
ZeroLit, m_Sema->BuildReturnStmt(ZeroLit->getExprLoc(), ZeroLit).get());
m_Sema->getCurScope()).get());
} }
// Wrap Stmts into a function body. // Wrap Stmts into a function body.