C++ inteop: Set type source info for a generated C++ thunk function (#6049)

This prevents a null pointer access crash when generating a thunk with
an automatically deduced trivial return type.
In this case, Clang calls `Sema::DeduceFunctionTypeFromReturnExpr()`
which calls `Sema::getReturnTypeLoc()`, which requires this information.

Part of #5514.
This commit is contained in:
Boaz Brickner
2025-09-12 07:11:36 +00:00
committed by GitHub
parent d60900cbeb
commit 508a88e2a9
2 changed files with 267 additions and 1 deletions
+4
View File
@@ -335,6 +335,10 @@ static auto CreateThunkFunctionDecl(
*callee_info.decl),
clang_loc));
// Set function declaration type source info.
thunk_function_decl->setTypeSourceInfo(ast_context.getTrivialTypeSourceInfo(
thunk_function_decl->getType(), clang_loc));
return thunk_function_decl;
}