Skip to content

Commit 0084c1f

Browse files
committed
[cling] 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) ```
1 parent a135909 commit 0084c1f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

interpreter/cling/lib/Interpreter/DeclExtractor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,8 @@ namespace cling {
257257
IntegerLiteral* ZeroLit
258258
= IntegerLiteral::Create(*m_Context, ZeroInt, m_Context->IntTy,
259259
SourceLocation());
260-
Stmts.push_back(m_Sema->ActOnReturnStmt(ZeroLit->getExprLoc(),
261-
ZeroLit,
262-
m_Sema->getCurScope()).get());
260+
Stmts.push_back(m_Sema->BuildReturnStmt(ZeroLit->getExprLoc(),
261+
ZeroLit).get());
263262
}
264263

265264
// Wrap Stmts into a function body.

0 commit comments

Comments
 (0)