@@ -259,7 +259,7 @@ std::string ConverterRefCount::BoxValue(std::string &&str) const {
259259bool ConverterRefCount::Convert (clang::QualType qual_type) {
260260 // Catch va_list before desugaring
261261 if (IsVaListType (qual_type)) {
262- StrCat (BoxType (" VaList " ));
262+ StrCat (BoxType (" Ptr<VaArg> " ));
263263 return false ;
264264 }
265265
@@ -325,7 +325,7 @@ bool ConverterRefCount::VisitPointerType(clang::PointerType *type) {
325325 }
326326
327327 if (IsVaListType (clang::QualType (type, 0 ))) {
328- StrCat (" VaList " );
328+ StrCat (" Ptr<VaArg> " );
329329 return false ;
330330 }
331331
@@ -792,6 +792,10 @@ void ConverterRefCount::EmitFunctionPreamble(clang::FunctionDecl *decl) {
792792 // name_2)'. We want to get the parameters from the definition if possible,
793793 // i.e. name_2.
794794 PushConversionKind push (*this , ConversionKind::FullRefCount);
795+ if (decl->isVariadic ()) {
796+ StrCat (" let __args: Value<Box<[VaArg]>> = "
797+ " Rc::new(RefCell::new(__args.into()));" );
798+ }
795799 auto params = decl->getDefinition () ? decl->getDefinition ()->parameters ()
796800 : decl->parameters ();
797801 for (auto *param : params) {
@@ -854,7 +858,7 @@ void ConverterRefCount::ConvertVaListVarDecl(clang::VarDecl *decl) {
854858 StrCat (keyword::kLet );
855859 }
856860
857- StrCat (GetNamedDeclAsString (decl), token::kColon , " Value<VaList >" );
861+ StrCat (GetNamedDeclAsString (decl), token::kColon , " Value<Ptr<VaArg> >" );
858862}
859863
860864bool ConverterRefCount::ConvertVarDeclSkipInit (clang::VarDecl *decl) {
@@ -1283,7 +1287,12 @@ void ConverterRefCount::ConvertPrintf(clang::CallExpr *expr) {
12831287}
12841288
12851289bool ConverterRefCount::VisitCallExpr (clang::CallExpr *expr) {
1286- if (IsBuiltinVaStart (expr) || IsBuiltinVaEnd (expr) || IsBuiltinVaCopy (expr)) {
1290+ if (IsBuiltinVaStart (expr)) {
1291+ StrCat (ToString (expr->getArg (0 )->IgnoreImpCasts ()),
1292+ " = __args.as_pointer()" );
1293+ return false ;
1294+ }
1295+ if (IsBuiltinVaEnd (expr) || IsBuiltinVaCopy (expr)) {
12871296 ConvertVAArgCall (expr);
12881297 return false ;
12891298 }
@@ -2526,7 +2535,7 @@ std::string ConverterRefCount::GetDefaultAsString(clang::QualType qual_type) {
25262535
25272536 if (IsVaListType (qual_type)) {
25282537 computed_expr_type_ = ComputedExprType::FreshValue;
2529- return BoxValue (" VaList ::default()" );
2538+ return BoxValue (" Ptr::<VaArg> ::default()" );
25302539 }
25312540
25322541 if (auto arr = GetArrayDefaultAsString (qual_type); !arr.empty ()) {
0 commit comments