Support passing Carbon Optional(T*) to C++ T* parameter. (#6422)

We already did this translation in the other direction, but we had no
mapping from `Optional(T)` to anything, so round-tripping a nullable
pointer from C++ through Carbon and back to C++ was previously rejected.
This commit is contained in:
Richard Smith
2025-11-25 22:30:14 +00:00
committed by GitHub
parent 6b775b3014
commit ec8c999bb1
8 changed files with 472 additions and 120 deletions
+6 -4
View File
@@ -302,8 +302,9 @@ class Stringifier {
const auto& class_info = sem_ir_->classes().Get(inst.class_id);
if (auto type_info = RecognizedTypeInfo::ForType(*sem_ir_, inst);
type_info.is_valid()) {
type_info.PrintLiteral(*sem_ir_, *out_);
return;
if (type_info.PrintLiteral(*sem_ir_, *out_)) {
return;
}
}
step_stack_->PushEntityName(class_info, inst.specific_id);
}
@@ -793,8 +794,9 @@ auto StringifySpecific(const File& sem_ir, SpecificId specific_id)
.specific_id = specific_id});
type_info.is_valid()) {
RawStringOstream out;
type_info.PrintLiteral(sem_ir, out);
return out.TakeStr();
if (type_info.PrintLiteral(sem_ir, out)) {
return out.TakeStr();
}
}
step_stack.PushEntityName(class_info, specific_id);
break;