mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 09:15:49 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user