void
OSReportWarn(virt_ptr<const char> fmt,
             var_args args)
{
   if (OSGetAppFlags().debugLevel() >= OSAppFlagsDebugLevel::Warn) {
      auto vaList = make_va_list(args);
      COSVReport(COSReportModule::Unknown0, COSReportLevel::Warn, fmt, vaList);
      free_va_list(vaList);
   }
}
void
OSPanic(virt_ptr<const char> file,
        int32_t line,
        virt_ptr<const char> fmt,
        var_args args)
{
   auto vaList = make_va_list(args);
   auto msg = fmt::memory_buffer { };
   internal::formatStringV(fmt, vaList, msg);
   free_va_list(vaList);

   internal::OSPanic(file.get(), line,
                     std::string_view { msg.data(), msg.size() });
}
exprt make_va_list(const exprt &expr)
{
  // we first strip any typecast
  if(expr.id()==ID_typecast)
    return make_va_list(to_typecast_expr(expr).op());

  // if it's an address of an lvalue, we take that
  if(expr.id()==ID_address_of &&
     expr.operands().size()==1 &&
     is_lvalue(expr.op0()))
    return expr.op0();

  return expr;
}