[clang] fix order of parameters in some inherited constructors

Summary:
Some funky C++ way of calling the parent's constructor triggers a
function in the frontend that used to reverse the order of parameters.

Reviewed By: skcho

Differential Revision: D28832500

fbshipit-source-id: 1032de2ca
master
Jules Villard 4 years ago committed by Facebook GitHub Bot
parent d285ee900b
commit f0741626a1

@ -223,8 +223,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let attr = Procdesc.get_attributes pdesc in
let procname = Procdesc.get_proc_name pdesc in
attr.formals (* remove this, which should always be the first formal parameter *) |> List.tl_exn
|> List.fold_left ~init:([], [])
~f:(fun (forwarded_params, forwarded_init_exps) (formal, typ) ->
|> List.fold_right ~init:([], [])
~f:(fun (formal, typ) (forwarded_params, forwarded_init_exps) ->
let pvar = Pvar.mk formal procname in
let id = Ident.create_fresh Ident.knormal in
( (Exp.Var id, typ) :: forwarded_params

@ -241,4 +241,19 @@ void FP_init_single_field_struct_ok() {
}
}
struct Base {
Base(int* p1, int* p2) { *p1 = 42; }
};
struct ForwardConstructorParams : Base {
// check that the parameters are forwarded in the correct order by the
// frontend
using Base::Base;
};
void derived_constructor_forwards_param_ok() {
int x;
ForwardConstructorParams A{&x, NULL};
}
} // namespace frontend

Loading…
Cancel
Save