@@ -291,7 +291,7 @@ bool ConverterRefCount::VisitReferenceType(clang::ReferenceType *type) {
291291 PushConversionKind push (*this , ConversionKind::Unboxed);
292292 return Convert (ctx_.getPointerType (pointee_type));
293293 }
294- if (pointee_type->isArrayType ()) {
294+ if (pointee_type->isArrayType () && ! IsVaListType (pointee_type) ) {
295295 // A reference to an array decays straight to a pointer to its first
296296 // element, the same way a by-value array parameter would, instead of
297297 // going through a pointer to the whole boxed array.
@@ -335,10 +335,11 @@ bool ConverterRefCount::VisitPointerType(clang::PointerType *type) {
335335 }
336336
337337 auto pointee_type = type->getPointeeType ();
338- PushConversionKind push1 (*this , ConversionKind::Ptr,
339- !pointee_type->isArrayType ());
338+ bool pointee_is_array =
339+ pointee_type->isArrayType () && !IsVaListType (pointee_type);
340+ PushConversionKind push1 (*this , ConversionKind::Ptr, !pointee_is_array);
340341 PushConversionKind push2 (*this , ConversionKind::FullRefCount,
341- pointee_type-> isArrayType () );
342+ pointee_is_array );
342343 if (pointee_type->isRecordType () &&
343344 abstract_structs_.contains (GetID (pointee_type->getAsRecordDecl ()))) {
344345 StrCat (" PtrDyn<dyn" );
@@ -2462,13 +2463,18 @@ bool ConverterRefCount::VisitVAArgExpr(clang::VAArgExpr *expr) {
24622463 if (auto *cast = clang::dyn_cast<clang::ImplicitCastExpr>(va_list_expr)) {
24632464 va_list_expr = cast->getSubExpr ();
24642465 }
2465- StrCat ( ConvertLValue (va_list_expr) );
2466- StrCat ( " .arg::< " ) ;
2466+ auto str = ConvertLValue (va_list_expr);
2467+ std::string arg_type ;
24672468 {
24682469 PushConversionKind push (*this , ConversionKind::Unboxed);
2469- StrCat (ToString (expr->getType ()));
2470+ arg_type = ToString (expr->getType ());
2471+ }
2472+ if (!pending_deref_.empty ()) {
2473+ StrCat (pending_deref_.take (), " .with_mut(|__v| __v.arg::<" , arg_type,
2474+ " >())" );
2475+ } else {
2476+ StrCat (str, " .arg::<" , arg_type, " >()" );
24702477 }
2471- StrCat (" >()" );
24722478 SetFreshType (expr->getType ());
24732479 return false ;
24742480}
0 commit comments