@@ -982,9 +982,40 @@ def __gen_var_function(self, func_param_name: str, func):
982
982
param_id += 1
983
983
param_list .append (curr_name )
984
984
985
- function_call = "//GEN_VAR_FUNCTION\n " + func ["return_type" ] + " " + func_param_name + \
986
- " = " + func ["qname" ] + \
987
- "(" + "," .join (param_list )+ ");\n "
985
+ found_parent = None
986
+ if func ["func_type" ] in [FUNC_CXXMETHOD , FUNC_CONSTRUCTOR , FUNC_DEFAULT_CONSTRUCTOR ]:
987
+ # Find parent class
988
+ for r in self .target_library ["records" ]:
989
+ if r ["hash" ] == func ["parent_hash" ]:
990
+ found_parent = r
991
+ break
992
+ if not found_parent :
993
+ self .gen_this_function = False
994
+ class_name = found_parent ["qname" ]
995
+ if func ["func_type" ] in [FUNC_CONSTRUCTOR , FUNC_DEFAULT_CONSTRUCTOR ]:
996
+ function_call = " //declare the RECORD and call constructor\n "
997
+ function_call += " " + class_name .replace ("::(anonymous namespace)" , "" ) + func_param_name + "(" + "," .join (param_list )+ ");\n "
998
+ else :
999
+ # Find default constructor
1000
+ # TODO: add code for other constructors
1001
+ found_default_constructor = False
1002
+ for fu in self .target_library ["functions" ]:
1003
+ if fu ["parent_hash" ] == func ["parent_hash" ] and fu ["func_type" ] == FUNC_DEFAULT_CONSTRUCTOR :
1004
+ found_default_constructor = True
1005
+
1006
+ # TODO: add code for other constructors!!!
1007
+ if not found_default_constructor :
1008
+ self .gen_this_function = False
1009
+ function_call = " //declare the RECORD first\n "
1010
+ function_call += " " + class_name .replace ("::(anonymous namespace)" , "" ) + " " + func_param_name + ";\n "
1011
+ # call the method
1012
+ function_call += " //METHOD CALL\n "
1013
+ function_call += " " + func_param_name + "." + func ["name" ]+ "(" + "," .join (param_list )+ ");\n "
1014
+
1015
+ else :
1016
+ function_call = "//GEN_VAR_FUNCTION\n " + func ["return_type" ] + " " + func_param_name + \
1017
+ " = " + func ["qname" ] + \
1018
+ "(" + "," .join (param_list )+ ");\n "
988
1019
989
1020
gen_dict ["gen_lines" ] += [function_call ]
990
1021
return gen_dict
@@ -2208,7 +2239,11 @@ def gen_targets(self, anonymous: bool = False):
2208
2239
self .param_list = []
2209
2240
self .curr_function = func
2210
2241
self .curr_func_log = ""
2211
- self .__gen_target_function (func , 0 )
2242
+ if "(anonymous" in func ["qname" ]:
2243
+ self .__gen_anonymous_function (func , 0 )
2244
+ else :
2245
+ self .__gen_target_function (func , 0 )
2246
+ # self.__gen_target_function(func, 0)
2212
2247
2213
2248
# For C++, Declare object of class and then call the method
2214
2249
if func ["access_type" ] == AS_PUBLIC and func ["fuzz_it" ] and func ["func_type" ] in [FUNC_CXXMETHOD , FUNC_CONSTRUCTOR , FUNC_DEFAULT_CONSTRUCTOR , FUNC_GLOBAL , FUNC_STATIC ] and (not "::operator" in func ["qname" ]):
@@ -2518,7 +2553,7 @@ def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_inc
2518
2553
+ " fuzz-driver(s)\n "
2519
2554
)
2520
2555
2521
- def compile_targets_new (self , workers : int = 4 , keep_failed : bool = False , extra_include : str = "" , extra_dynamiclink : str = "" , flags : str = "" , coverage : bool = False ):
2556
+ def compile_all_targets (self , workers : int = 4 , keep_failed : bool = False , extra_include : str = "" , extra_dynamiclink : str = "" , flags : str = "" , coverage : bool = False ):
2522
2557
"""_summary_
2523
2558
2524
2559
Args:
0 commit comments