@@ -74,6 +74,9 @@ let _type_arg_mode_compare (m1: type_arg_mode_t) (m2: type_arg_mode_t): int =
7474 | (ArgScalarValue, _ ) -> - 1
7575 | (_ , ArgScalarValue) -> 1
7676 | (ArgOutputFormatString, ArgOutputFormatString) -> 0
77+ | (ArgOutputFormatString, _ ) -> - 1
78+ | (_ , ArgOutputFormatString) -> 1
79+ | (ArgInputFormatString, ArgInputFormatString) -> 0
7780
7881
7982let type_cap_label_compare (c1 : type_cap_label_t ) (c2 : type_cap_label_t ) =
@@ -134,6 +137,12 @@ let type_cap_label_compare (c1: type_cap_label_t) (c2: type_cap_label_t) =
134137 | (_ , OffsetAccess _ ) -> 1
135138 | (OffsetAccessA (n1 , m1 ), OffsetAccessA (n2 , m2 )) ->
136139 Stdlib. compare (n1, m1) (n2, m2)
140+ | (OffsetAccessA _ , _ ) -> - 1
141+ | (_ , OffsetAccessA _ ) -> 1
142+ | (FOutputFormatString, FOutputFormatString) -> 0
143+ | (FOutputFormatString, _ ) -> - 1
144+ | (_ , FOutputFormatString) -> 1
145+ | (FInputFormatString, FInputFormatString) -> 0
137146
138147
139148let type_arg_mode_to_string (m : type_arg_mode_t ) =
@@ -149,6 +158,7 @@ let type_arg_mode_to_string (m: type_arg_mode_t) =
149158 | ArgFunctionPointer -> " fp"
150159 | ArgScalarValue -> " sv"
151160 | ArgOutputFormatString -> " ofs"
161+ | ArgInputFormatString -> " ifs"
152162
153163
154164let type_operation_kind_to_string (op : type_operation_kind_t ) =
@@ -180,6 +190,8 @@ let type_cap_label_to_string (c: type_cap_label_t) =
180190 ^ (type_operation_kind_to_string op)
181191 ^ (optbterm_to_string t)
182192 | FlowsFrom t -> " flowsfrom" ^ (optbterm_to_string t)
193+ | FOutputFormatString -> " output-format-string"
194+ | FInputFormatString -> " input-format-string"
183195 | Load -> " load"
184196 | Store -> " store"
185197 | Deref -> " deref"
@@ -469,6 +481,14 @@ let add_stack_address_capability (offset: int) (tv: type_variable_t)
469481 add_capability [FLocStackAddress offset] tv
470482
471483
484+ let add_output_format_string_capability (tv : type_variable_t ): type_variable_t =
485+ add_capability [FOutputFormatString ] tv
486+
487+
488+ let add_input_format_string_capability (tv : type_variable_t ): type_variable_t =
489+ add_capability [FInputFormatString ] tv
490+
491+
472492let convert_function_capabilities_to_attributes
473493 (paramindex : int ) (caps : type_cap_label_t list ): b_attributes_t =
474494 let type_arg_mode_to_cons_attrparam (m : type_arg_mode_t ) =
@@ -484,6 +504,7 @@ let convert_function_capabilities_to_attributes
484504 | ArgFunctionPointer -> ACons (" fp" , [] )
485505 | ArgScalarValue -> ACons (" sv" , [] )
486506 | ArgOutputFormatString -> ACons (" printf_format_string" , [] )
507+ | ArgInputFormatString -> ACons (" scanf_format_string" , [] )
487508 in
488509 let result = new CHUtils.IntCollections. set_t in
489510 let _ =
@@ -498,6 +519,14 @@ let convert_function_capabilities_to_attributes
498519 AInt argindex;
499520 type_arg_mode_to_cons_attrparam mode]) in
500521 result#add (bcd#index_attribute attr)
522+ | FOutputFormatString ->
523+ let attr =
524+ Attr (" format" , [ACons (" printf" , [] ); AInt paramindex; AInt 0 ]) in
525+ result#add (bcd#index_attribute attr)
526+ | FInputFormatString ->
527+ let attr =
528+ Attr (" format" , [ACons (" scanf" , [] ); AInt paramindex; AInt 0 ]) in
529+ result#add (bcd#index_attribute attr)
501530 | _ -> () ) caps in
502531 List. map bcd#get_attribute result#toList
503532
0 commit comments