let lvalXformClass action data sid fd nofrm = object
  inherit nopCilVisitor

  method vexpr e =
    let castrm e =
      stripCastsDeepForPtrArith e
    in
    match e.enode with
    | Lval((Mem e', off) as lv)-> begin
        match action data sid lv fd nofrm with
        | None ->
            (* don't substitute constants in memory lvals *)
            let post e =
              match e.enode with
              | Lval(Mem({enode = Const _}),off') ->
                  new_exp ~loc:e.eloc (Lval(Mem e', off'))
              | _ -> stripCastsDeepForPtrArith e
            in
            ChangeDoChildrenPost(new_exp ~loc:e.eloc (Lval(Mem e', off)), post)
        | Some e ->
            let newt = typeOf(new_exp ~loc:e.eloc (Lval lv)) in
            let e'' = mkCast ~e ~newt in
            ChangeDoChildrenPost(e'', castrm)
    end
    | Lval lv -> begin
        match action data sid lv fd nofrm with
        | None -> DoChildren
        | Some e' -> begin
            (* Cast e' to the correct type. *)
            let e'' = mkCast ~e:e' ~newt:(typeOf(dummy_exp(Lval lv))) in
            ChangeDoChildrenPost(e'', castrm)
        end
    end
    | _ -> ChangeDoChildrenPost(castrm e, castrm)

end