diff --git a/automates/program_analysis/GCC2GrFN/gcc_ast_to_cast.py b/automates/program_analysis/GCC2GrFN/gcc_ast_to_cast.py index 83400dd90..e50daa500 100644 --- a/automates/program_analysis/GCC2GrFN/gcc_ast_to_cast.py +++ b/automates/program_analysis/GCC2GrFN/gcc_ast_to_cast.py @@ -31,6 +31,7 @@ UnaryOperator, VarType, Var, + loop, source_ref, subscript, ) @@ -64,6 +65,7 @@ def __init__(self, gcc_asts): self.parsed_basic_blocks = [] self.current_basic_block = None self.type_ids_to_defined_types = {} + self.loop_exits = {} def to_cast(self): modules = [] @@ -489,6 +491,10 @@ def parse_conditional_statement(self, stmt, statements): condition_expr = self.parse_conditional_expr(stmt) if is_loop: + + src_index = self.current_basic_block["index"] + self.loop_exits[src_index] = (src_index,stmt["trueLabel"]) + temp = self.current_basic_block loop_body = self.parse_body(false_edge, true_edge) self.current_basic_block = temp @@ -514,12 +520,62 @@ def parse_conditional_statement(self, stmt, statements): # this second condition. Otherwise, we only have one condition and # the "false block" is the normal block of code following the if, # so do not evaluate it here. + # In the case that a block has a break in it, the first check won't work + # because the break changes the exit target of the block it's in, so we check + # to see if the current block will break out the loop by seeing if the target is further + # down if true_exit_target == false_exit_target: false_res = self.parse_basic_block(false_block) + elif true_exit_target > true_block["edges"][0]["source"]: + false_res = self.parse_basic_block(false_block) + self.current_basic_block = temp return [ModelIf(expr=condition_expr, body=true_res, orelse=false_res)] + def parse_predict_stmt(self, stmt): + if stmt["name"] == "continue": + return [ModelContinue()] + if "early return" in stmt["name"]: + curr_b = self.current_basic_block + + # Fetch all the statements in this node except + # for the early return predict and the goto that follows it + all_stmts = curr_b["statements"][0:-2] + + # Use the line number information to get only the + # statements involved in the return computation + return_pieces = [curr for curr in all_stmts if curr["line_start"] == stmt["line_start"]] + + # Parse all the SSA statements involved in the return expression (could be 1 or more than 1) + for piece in return_pieces: + self.parse_statement(piece,return_pieces) + + # The last thing in piece contains the full return expression + val = self.variables_ids_to_expression[piece["lhs"]["id"]] + + return [ModelReturn(value=val)] + else: + return [] + + def parse_goto_stmt(self, stmt): + + # Attempt to find which block this goto statement is from + if len(self.loop_exits) > 0: + loop_indices = list(self.loop_exits.keys()) + curr = self.loop_exits[loop_indices[0]] + target = stmt["target"] + + for loop_index, loop_block in self.loop_exits.items(): + if target >= loop_block[0] and target <= loop_block[1]: + if loop_block[0] > curr[0] and loop_block[0] < curr[1]: + curr = loop_block + if target == curr[1]: + return [ModelBreak()] + + return [] + + def parse_body(self, start_block, end_block): blocks = [ bb @@ -541,12 +597,14 @@ def parse_statement(self, stmt, statements): result = self.parse_call_statement(stmt) elif stmt_type == "conditional": result = self.parse_conditional_statement(stmt, statements) + elif stmt_type == "predict": + result = self.parse_predict_stmt(stmt) elif ( # Already handled in the conditional stmt type, just skip stmt_type == "goto" or stmt_type == "resx" # Doesnt concern us ): - return [] + result = self.parse_goto_stmt(stmt) else: # TODO custom exception raise Exception(f"Error: Unknown statement type {stmt_type}") diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c new file mode 100644 index 000000000..c8daffa9e --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c @@ -0,0 +1,21 @@ +int main() +{ + int x = 10; + int y = 0; + while (y < x) + { + y = y + 1; + + if (y == 5) + { + x = x - 1; + break; + } + else + y = 5; + + y = y - x; + } + + return 1; +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1_gcc_ast.json new file mode 100644 index 000000000..feb718b07 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1_gcc_ast.json @@ -0,0 +1,529 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "line_start": 2, + "line_end": 21, + "variableDeclarations": [ + { + "name": "y", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "x", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964996, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 10 + } + ] + }, + { + "type": "assign", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "ge_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + } + ], + "trueLabel": 7, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 7 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 7, + "col_start": 11, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "conditional", + "line_start": 9, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "eq_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 5 + } + ], + "trueLabel": 5, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 4, + "target": 5 + }, + { + "flags": 512, + "source": 4, + "target": 6 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "assign", + "line_start": 11, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": -1 + } + ] + }, + { + "type": "goto", + "target": 7 + } + ], + "edges": [ + { + "flags": 1, + "source": 5, + "target": 7 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 15, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 5 + } + ] + }, + { + "type": "assign", + "line_start": 17, + "col_start": 11, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "minus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 6, + "target": 3 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 20, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964996, + "line_start": 20, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 8 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964996, + "line_start": 20, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_1.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 8, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c new file mode 100644 index 000000000..abc60d29d --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c @@ -0,0 +1,19 @@ +int func1(int x){ + for(int i = 0; i < 5; i++) + { + for(int j = 0; j < 5; j++) + { + if(((i + j + x) % 2) == 1) + { + j = j + 1; + break; + } + } + } + return 0; +} + +int main() +{ + int x = func1(10); +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2_gcc_ast.json new file mode 100644 index 000000000..7dde4b3f9 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2_gcc_ast.json @@ -0,0 +1,911 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "functions": [ + { + "id": 4294965005, + "name": "func1", + "mangledName": "_Z5func1i", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "line_start": 1, + "line_end": 14, + "parameters": [ + { + "name": "x", + "id": 4294965006, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "line_start": 1, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + } + ], + "variableDeclarations": [ + { + "name": "j", + "id": 4294965002, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "i", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964988, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 2, + "col_start": 22, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 4 + } + ], + "trueLabel": 10, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 10 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "conditional", + "line_start": 4, + "col_start": 26, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 4 + } + ], + "trueLabel": 9, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 5, + "target": 9 + }, + { + "flags": 512, + "source": 5, + "target": 6 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 6, + "col_start": 20, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "plus_expr", + "lhs": { + "ssa_id": 1, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + } + ] + }, + { + "type": "assign", + "line_start": 6, + "col_start": 24, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "plus_expr", + "lhs": { + "ssa_id": 2, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + "operands": [ + { + "code": "parm_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965006, + "name": "x", + "line_start": 1, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + { + "ssa_id": 1, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ] + }, + { + "type": "assign", + "line_start": 6, + "col_start": 29, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "trunc_mod_expr", + "lhs": { + "ssa_id": 3, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + "operands": [ + { + "ssa_id": 2, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ] + }, + { + "type": "conditional", + "line_start": 6, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "eq_expr", + "operands": [ + { + "ssa_id": 3, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ], + "trueLabel": 7, + "falseLabel": 8 + } + ], + "edges": [ + { + "flags": 256, + "source": 6, + "target": 7 + }, + { + "flags": 512, + "source": 6, + "target": 8 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 8, + "col_start": 19, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 9 + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 9 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "assign", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 5 + } + ], + "edges": [ + { + "flags": 1, + "source": 8, + "target": 5 + } + ] + }, + { + "index": 9, + "statements": [ + { + "type": "assign", + "line_start": 2, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 9, + "target": 3 + } + ] + }, + { + "index": 10, + "statements": [ + { + "type": "assign", + "line_start": 13, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964988, + "line_start": 13, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 10, + "target": 11 + } + ] + }, + { + "index": 11, + "statements": [ + { + "type": "return", + "line_start": 13, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964988, + "line_start": 13, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 11, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964997, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 16, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "line_start": 17, + "line_end": 19, + "variableDeclarations": [ + { + "name": "x", + "id": 4294964995, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964986, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "call", + "line_start": 18, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964995, + "name": "x", + "line_start": 18, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + "function": { + "code": "addr_expr", + "type": { + "type": "pointer_type", + "size": 64, + "baseType": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + { + "type": "integer_type", + "size": 32, + "unsigned": false + } + ], + "variableArguments": false + } + }, + "value": { + "code": "function_decl", + "type": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + { + "type": "integer_type", + "size": 32, + "unsigned": false + } + ], + "variableArguments": false + }, + "id": 4294965005, + "mangledName": "_Z5func1i", + "name": "func1", + "line_start": 1, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + } + }, + "arguments": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 10 + } + ] + }, + { + "type": "assign", + "line_start": 19, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964986, + "line_start": 19, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "return", + "line_start": 19, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c", + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964986, + "line_start": 19, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_2.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 3, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c new file mode 100644 index 000000000..f9ca8503f --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c @@ -0,0 +1,23 @@ +int main() +{ + int x = 10; + int y = 0; + while (y < x) + { + y = y + 1; + + if (y == 5) + { + x = x - 1; + } + else + { + y = 5; + break; + } + + y = y - x; + } + + return 1; +} diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3_gcc_ast.json new file mode 100644 index 000000000..8931a7a29 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3_gcc_ast.json @@ -0,0 +1,545 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "line_start": 2, + "line_end": 23, + "variableDeclarations": [ + { + "name": "y", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "x", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964995, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 10 + } + ] + }, + { + "type": "assign", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "ge_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + } + ], + "trueLabel": 8, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 8 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 7, + "col_start": 11, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "conditional", + "line_start": 9, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "eq_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 5 + } + ], + "trueLabel": 5, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 4, + "target": 5 + }, + { + "flags": 512, + "source": 4, + "target": 6 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "assign", + "line_start": 11, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": -1 + } + ] + }, + { + "type": "goto", + "target": 7 + } + ], + "edges": [ + { + "flags": 1, + "source": 5, + "target": 7 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 15, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 5 + } + ] + }, + { + "type": "goto", + "target": 8 + } + ], + "edges": [ + { + "flags": 1, + "source": 6, + "target": 8 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 19, + "col_start": 11, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "minus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 3 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "assign", + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964995, + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 8, + "target": 9 + } + ] + }, + { + "index": 9, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964995, + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_break_3.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 9, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c new file mode 100644 index 000000000..bc2bc430d --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c @@ -0,0 +1,23 @@ +int main() +{ + int x = 10; + int y = 0; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + y = y + 1; + + if (y == 2) + { + x = x - 1; + continue; + } + else + y = 5; + + y = y - x; + } + } + return 1; +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1_gcc_ast.json new file mode 100644 index 000000000..284c10537 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1_gcc_ast.json @@ -0,0 +1,793 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "line_start": 2, + "line_end": 23, + "variableDeclarations": [ + { + "name": "j", + "id": 4294965001, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "i", + "id": 4294965002, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "y", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "x", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964990, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 10 + } + ] + }, + { + "type": "assign", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + }, + { + "type": "assign", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "i", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 5, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "i", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ], + "trueLabel": 11, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 11 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965001, + "name": "j", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "conditional", + "line_start": 7, + "col_start": 27, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965001, + "name": "j", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ], + "trueLabel": 10, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 5, + "target": 10 + }, + { + "flags": 512, + "source": 5, + "target": 6 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 9, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "conditional", + "line_start": 11, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "eq_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ], + "trueLabel": 7, + "falseLabel": 8 + } + ], + "edges": [ + { + "flags": 256, + "source": 6, + "target": 7 + }, + { + "flags": 512, + "source": 6, + "target": 8 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 13, + "col_start": 19, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": -1 + } + ] + }, + { + "type": "predict", + "line_start": 11, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "hassub": 0, + "name": "continue" + }, + { + "type": "goto", + "target": 9 + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 9 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "assign", + "line_start": 17, + "col_start": 19, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 5 + } + ] + }, + { + "type": "assign", + "line_start": 19, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "minus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 8, + "target": 9 + } + ] + }, + { + "index": 9, + "statements": [ + { + "type": "assign", + "line_start": 7, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965001, + "name": "j", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965001, + "name": "j", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 5 + } + ], + "edges": [ + { + "flags": 1, + "source": 9, + "target": 5 + } + ] + }, + { + "index": 10, + "statements": [ + { + "type": "assign", + "line_start": 5, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "i", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "i", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 10, + "target": 3 + } + ] + }, + { + "index": 11, + "statements": [ + { + "type": "assign", + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964990, + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 11, + "target": 12 + } + ] + }, + { + "index": 12, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964990, + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/complex_continue_1.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 12, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c new file mode 100644 index 000000000..43e385b4d --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c @@ -0,0 +1,11 @@ + int main(){ + // Tests continue in nested conditional + for (int i = 0; i < 1; i++) + { + if (i == 1) + { + continue; + } + } + return 1; +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue_gcc_ast.json new file mode 100644 index 000000000..cc7f766bd --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue_gcc_ast.json @@ -0,0 +1,365 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 6, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c", + "line_start": 1, + "line_end": 11, + "variableDeclarations": [ + { + "name": "i", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964997, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 3, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ], + "trueLabel": 7, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 7 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "conditional", + "line_start": 5, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c", + "operator": "eq_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ], + "trueLabel": 5, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 4, + "target": 5 + }, + { + "flags": 512, + "source": 4, + "target": 6 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "predict", + "line_start": 5, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c", + "hassub": 0, + "name": "continue" + } + ], + "edges": [ + { + "flags": 1, + "source": 5, + "target": 6 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 6, + "target": 3 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964997, + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 8 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964997, + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/cond_continue.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 8, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c new file mode 100644 index 000000000..c8fd79c30 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c @@ -0,0 +1,8 @@ +int func1() +{ + return 1; +} + +int main(){ + return func1(); +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1_gcc_ast.json new file mode 100644 index 000000000..330cd7b2c --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1_gcc_ast.json @@ -0,0 +1,282 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c", + "functions": [ + { + "id": 4294965006, + "name": "func1", + "mangledName": "_Z5func1v", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c", + "line_start": 2, + "line_end": 4, + "variableDeclarations": [ + { + "id": 4294965002, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "line_start": 3, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "return", + "line_start": 3, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c", + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "line_start": 3, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 3, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294965004, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 6, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c", + "line_start": 6, + "line_end": 8, + "variableDeclarations": [ + { + "id": 4294965000, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "call", + "line_start": 7, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965000, + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c" + }, + "function": { + "code": "addr_expr", + "type": { + "type": "pointer_type", + "size": 64, + "baseType": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + ], + "variableArguments": false + } + }, + "value": { + "code": "function_decl", + "type": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + ], + "variableArguments": false + }, + "id": 4294965006, + "mangledName": "_Z5func1v", + "name": "func1", + "line_start": 1, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c" + } + } + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965000, + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_1.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 3, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c new file mode 100644 index 000000000..5d1fed180 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c @@ -0,0 +1,13 @@ +int func2() +{ + if (1) + { + return 2; + } + return 1; +} + +int main() +{ + return func2(); +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2_gcc_ast.json new file mode 100644 index 000000000..32ea97d6c --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2_gcc_ast.json @@ -0,0 +1,281 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c", + "functions": [ + { + "id": 4294965006, + "name": "func2", + "mangledName": "_Z5func2v", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c", + "line_start": 2, + "line_end": 8, + "variableDeclarations": [ + { + "id": 4294965002, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 5, + "col_start": 16, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "line_start": 5, + "col_start": 16, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "line_start": 5, + "col_start": 16, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 3, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294965004, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 10, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c", + "line_start": 11, + "line_end": 13, + "variableDeclarations": [ + { + "id": 4294965000, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "call", + "line_start": 12, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965000, + "line_start": 12, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c" + }, + "function": { + "code": "addr_expr", + "type": { + "type": "pointer_type", + "size": 64, + "baseType": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + ], + "variableArguments": false + } + }, + "value": { + "code": "function_decl", + "type": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + ], + "variableArguments": false + }, + "id": 4294965006, + "mangledName": "_Z5func2v", + "name": "func2", + "line_start": 1, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c" + } + } + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965000, + "line_start": 12, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_2.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 3, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c new file mode 100644 index 000000000..6a7cafa2a --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c @@ -0,0 +1,13 @@ +int func2(int a) +{ + if (a == 1) + { + return 2; + } + return 1; +} + +int main() +{ + return func2(10); +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3_gcc_ast.json new file mode 100644 index 000000000..b7bcdc0d9 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3_gcc_ast.json @@ -0,0 +1,420 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c", + "functions": [ + { + "id": 4294965005, + "name": "func2", + "mangledName": "_Z5func2i", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c", + "line_start": 2, + "line_end": 8, + "parameters": [ + { + "name": "a", + "id": 4294965006, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "line_start": 1, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c" + } + ], + "variableDeclarations": [ + { + "id": 4294964999, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "conditional", + "line_start": 3, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c", + "operator": "eq_expr", + "operands": [ + { + "code": "parm_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965006, + "name": "a", + "line_start": 1, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ], + "trueLabel": 3, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 2, + "target": 3 + }, + { + "flags": 512, + "source": 2, + "target": 4 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "assign", + "line_start": 5, + "col_start": 16, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964999, + "line_start": 5, + "col_start": 16, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ] + }, + { + "type": "predict", + "line_start": 5, + "col_start": 16, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c", + "hassub": 0, + "name": "early return (on trees)" + }, + { + "type": "goto", + "target": 5 + } + ], + "edges": [ + { + "flags": 1, + "source": 3, + "target": 5 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 7, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964999, + "line_start": 5, + "col_start": 16, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964999, + "line_start": 5, + "col_start": 16, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 5, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294965003, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 10, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c", + "line_start": 11, + "line_end": 13, + "variableDeclarations": [ + { + "id": 4294964997, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "call", + "line_start": 12, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964997, + "line_start": 12, + "col_start": 20, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c" + }, + "function": { + "code": "addr_expr", + "type": { + "type": "pointer_type", + "size": 64, + "baseType": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + { + "type": "integer_type", + "size": 32, + "unsigned": false + } + ], + "variableArguments": false + } + }, + "value": { + "code": "function_decl", + "type": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + { + "type": "integer_type", + "size": 32, + "unsigned": false + } + ], + "variableArguments": false + }, + "id": 4294965005, + "mangledName": "_Z5func2i", + "name": "func2", + "line_start": 1, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c" + } + }, + "arguments": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 10 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964997, + "line_start": 12, + "col_start": 20, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_3.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 3, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c new file mode 100644 index 000000000..63a0c9722 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c @@ -0,0 +1,18 @@ +int func1(int x){ + for(int i = 0; i < 5; i++) + { + for(int j = 0; j < 5; j++) + { + if(((i + j + x) % 2) == 1) + { + return -1; + } + } + } + return 0; +} + +int main() +{ + int x = func1(10); +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4_gcc_ast.json new file mode 100644 index 000000000..d79fd9844 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4_gcc_ast.json @@ -0,0 +1,904 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "functions": [ + { + "id": 4294965005, + "name": "func1", + "mangledName": "_Z5func1i", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "line_start": 1, + "line_end": 13, + "parameters": [ + { + "name": "x", + "id": 4294965006, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "line_start": 1, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + } + ], + "variableDeclarations": [ + { + "name": "j", + "id": 4294965002, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "i", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964988, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 2, + "col_start": 22, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 4 + } + ], + "trueLabel": 10, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 10 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "conditional", + "line_start": 4, + "col_start": 26, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 4 + } + ], + "trueLabel": 9, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 5, + "target": 9 + }, + { + "flags": 512, + "source": 5, + "target": 6 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 6, + "col_start": 20, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "plus_expr", + "lhs": { + "ssa_id": 1, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + } + ] + }, + { + "type": "assign", + "line_start": 6, + "col_start": 24, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "plus_expr", + "lhs": { + "ssa_id": 2, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + "operands": [ + { + "code": "parm_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965006, + "name": "x", + "line_start": 1, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + { + "ssa_id": 1, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ] + }, + { + "type": "assign", + "line_start": 6, + "col_start": 29, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "trunc_mod_expr", + "lhs": { + "ssa_id": 3, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + "operands": [ + { + "ssa_id": 2, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ] + }, + { + "type": "conditional", + "line_start": 6, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "eq_expr", + "operands": [ + { + "ssa_id": 3, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ], + "trueLabel": 7, + "falseLabel": 8 + } + ], + "edges": [ + { + "flags": 256, + "source": 6, + "target": 7 + }, + { + "flags": 512, + "source": 6, + "target": 8 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 8, + "col_start": 25, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964988, + "line_start": 8, + "col_start": 25, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": -1 + } + ] + }, + { + "type": "predict", + "line_start": 8, + "col_start": 25, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "hassub": 0, + "name": "early return (on trees)" + }, + { + "type": "goto", + "target": 11 + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 11 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "assign", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "j", + "line_start": 4, + "col_start": 17, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 5 + } + ], + "edges": [ + { + "flags": 1, + "source": 8, + "target": 5 + } + ] + }, + { + "index": 9, + "statements": [ + { + "type": "assign", + "line_start": 2, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 2, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 9, + "target": 3 + } + ] + }, + { + "index": 10, + "statements": [ + { + "type": "assign", + "line_start": 12, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964988, + "line_start": 8, + "col_start": 25, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 10, + "target": 11 + } + ] + }, + { + "index": 11, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964988, + "line_start": 8, + "col_start": 25, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 11, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964997, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 15, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "line_start": 16, + "line_end": 18, + "variableDeclarations": [ + { + "name": "x", + "id": 4294964995, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964986, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "call", + "line_start": 17, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964995, + "name": "x", + "line_start": 17, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + "function": { + "code": "addr_expr", + "type": { + "type": "pointer_type", + "size": 64, + "baseType": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + { + "type": "integer_type", + "size": 32, + "unsigned": false + } + ], + "variableArguments": false + } + }, + "value": { + "code": "function_decl", + "type": { + "type": "function_type", + "size": 8, + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "argumentTypes": [ + { + "type": "integer_type", + "size": 32, + "unsigned": false + } + ], + "variableArguments": false + }, + "id": 4294965005, + "mangledName": "_Z5func1i", + "name": "func1", + "line_start": 1, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + } + }, + "arguments": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 10 + } + ] + }, + { + "type": "assign", + "line_start": 18, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964986, + "line_start": 18, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "return", + "line_start": 18, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c", + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964986, + "line_start": 18, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/early_return_4.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 3, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c new file mode 100644 index 000000000..955ac40a9 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c @@ -0,0 +1,20 @@ +int main(){ + int x = 0; + for(int i = 0; i < 10; i++){ + if((x + i) == 2){ + x++; + continue; + } + if(x == 1){ + break; + } + if(x + i == 3){ + if (i % 2 == 0) + continue; + else + break; + } + x = x + 1; + } + +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1_gcc_ast.json new file mode 100644 index 000000000..45fe049a3 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1_gcc_ast.json @@ -0,0 +1,860 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "line_start": 1, + "line_end": 20, + "variableDeclarations": [ + { + "name": "i", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "x", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964990, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + }, + { + "type": "assign", + "line_start": 3, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 3, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 3, + "col_start": 22, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 3, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 9 + } + ], + "trueLabel": 14, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 14 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 4, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "plus_expr", + "lhs": { + "ssa_id": 1, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 3, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + } + ] + }, + { + "type": "conditional", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "eq_expr", + "operands": [ + { + "ssa_id": 1, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ], + "trueLabel": 5, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 4, + "target": 5 + }, + { + "flags": 512, + "source": 4, + "target": 6 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "assign", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "predict", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "hassub": 0, + "name": "continue" + }, + { + "type": "goto", + "target": 13 + } + ], + "edges": [ + { + "flags": 1, + "source": 5, + "target": 13 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "conditional", + "line_start": 8, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "eq_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ], + "trueLabel": 7, + "falseLabel": 8 + } + ], + "edges": [ + { + "flags": 256, + "source": 6, + "target": 7 + }, + { + "flags": 512, + "source": 6, + "target": 8 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "goto", + "target": 14 + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 14 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "assign", + "line_start": 11, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "plus_expr", + "lhs": { + "ssa_id": 2, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 3, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + } + ] + }, + { + "type": "conditional", + "line_start": 11, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "eq_expr", + "operands": [ + { + "ssa_id": 2, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 3 + } + ], + "trueLabel": 9, + "falseLabel": 12 + } + ], + "edges": [ + { + "flags": 256, + "source": 8, + "target": 9 + }, + { + "flags": 512, + "source": 8, + "target": 12 + } + ] + }, + { + "index": 9, + "statements": [ + { + "type": "assign", + "line_start": 12, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "nop_expr", + "lhs": { + "ssa_id": 3, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": true + } + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 3, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + } + ] + }, + { + "type": "assign", + "line_start": 12, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "bit_and_expr", + "lhs": { + "ssa_id": 4, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": true + } + }, + "operands": [ + { + "ssa_id": 3, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": true + } + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": true + }, + "value": 1 + } + ] + }, + { + "type": "conditional", + "line_start": 12, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "eq_expr", + "operands": [ + { + "ssa_id": 4, + "code": "ssa_name", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": true + } + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": true + }, + "value": 0 + } + ], + "trueLabel": 10, + "falseLabel": 11 + } + ], + "edges": [ + { + "flags": 256, + "source": 9, + "target": 10 + }, + { + "flags": 512, + "source": 9, + "target": 11 + } + ] + }, + { + "index": 10, + "statements": [ + { + "type": "predict", + "line_start": 12, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "hassub": 0, + "name": "continue" + }, + { + "type": "goto", + "target": 13 + } + ], + "edges": [ + { + "flags": 1, + "source": 10, + "target": 13 + } + ] + }, + { + "index": 11, + "statements": [ + { + "type": "goto", + "target": 14 + } + ], + "edges": [ + { + "flags": 1, + "source": 11, + "target": 14 + } + ] + }, + { + "index": 12, + "statements": [ + { + "type": "assign", + "line_start": 17, + "col_start": 11, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 2, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 12, + "target": 13 + } + ] + }, + { + "index": 13, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 3, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "i", + "line_start": 3, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 13, + "target": 3 + } + ] + }, + { + "index": 14, + "statements": [ + { + "type": "assign", + "line_start": 20, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964990, + "line_start": 20, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 14, + "target": 15 + } + ] + }, + { + "index": 15, + "statements": [ + { + "type": "return", + "line_start": 20, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c", + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964990, + "line_start": 20, + "col_start": 1, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/mixed_break_continue_1.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 15, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c new file mode 100644 index 000000000..9e2103974 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c @@ -0,0 +1,11 @@ +int main() +{ + for (int i = 0; i < 1; i++) + { + for (int j = 0; j < 1; j++) + { + break; + } + } + return 1; +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c new file mode 100644 index 000000000..81b5adb38 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c @@ -0,0 +1,23 @@ +int main() +{ + int x = 10; + int y = 0; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + y = y + 1; + + if (y == 5) + { + x = x - 1; + break; + } + else + y = 5; + + y = y - x; + } + } + return 1; +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2_gcc_ast.json new file mode 100644 index 000000000..ac210b6da --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2_gcc_ast.json @@ -0,0 +1,773 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "line_start": 2, + "line_end": 23, + "variableDeclarations": [ + { + "name": "j", + "id": 4294965001, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "i", + "id": 4294965002, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "y", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "x", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964990, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 10 + } + ] + }, + { + "type": "assign", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + }, + { + "type": "assign", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "i", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 5, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "i", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ], + "trueLabel": 10, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 10 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965001, + "name": "j", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "conditional", + "line_start": 7, + "col_start": 27, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965001, + "name": "j", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 2 + } + ], + "trueLabel": 9, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 5, + "target": 9 + }, + { + "flags": 512, + "source": 5, + "target": 6 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 9, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "conditional", + "line_start": 11, + "col_start": 13, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "eq_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 5 + } + ], + "trueLabel": 7, + "falseLabel": 8 + } + ], + "edges": [ + { + "flags": 256, + "source": 6, + "target": 7 + }, + { + "flags": 512, + "source": 6, + "target": 8 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 13, + "col_start": 19, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": -1 + } + ] + }, + { + "type": "goto", + "target": 9 + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 9 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "assign", + "line_start": 17, + "col_start": 19, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 5 + } + ] + }, + { + "type": "assign", + "line_start": 19, + "col_start": 15, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "minus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "y", + "line_start": 4, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "x", + "line_start": 3, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + } + ] + }, + { + "type": "assign", + "line_start": 7, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965001, + "name": "j", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965001, + "name": "j", + "line_start": 7, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 5 + } + ], + "edges": [ + { + "flags": 1, + "source": 8, + "target": 5 + } + ] + }, + { + "index": 9, + "statements": [ + { + "type": "assign", + "line_start": 5, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "i", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965002, + "name": "i", + "line_start": 5, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 9, + "target": 3 + } + ] + }, + { + "index": 10, + "statements": [ + { + "type": "assign", + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964990, + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 10, + "target": 11 + } + ] + }, + { + "index": 11, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964990, + "line_start": 22, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_2.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 11, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_gcc_ast.json new file mode 100644 index 000000000..0b6a32e0a --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break_gcc_ast.json @@ -0,0 +1,398 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c", + "line_start": 2, + "line_end": 11, + "variableDeclarations": [ + { + "name": "j", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "i", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964994, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 3, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ], + "trueLabel": 7, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 7 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 5, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "j", + "line_start": 5, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + }, + { + "type": "conditional", + "line_start": 5, + "col_start": 27, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "j", + "line_start": 5, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ], + "trueLabel": 6, + "falseLabel": 5 + } + ], + "edges": [ + { + "flags": 256, + "source": 4, + "target": 6 + }, + { + "flags": 512, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 5, + "target": 6 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 6, + "target": 3 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964994, + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 8 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964994, + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_break.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 8, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c new file mode 100644 index 000000000..e93dbcd18 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c @@ -0,0 +1,11 @@ +int main() +{ + for (int i = 0; i < 1; i++) + { + for (int j = 0; j < 1; j++) + { + continue; + } + } + return 1; +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue_gcc_ast.json new file mode 100644 index 000000000..02f9d684b --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue_gcc_ast.json @@ -0,0 +1,478 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "line_start": 2, + "line_end": 11, + "variableDeclarations": [ + { + "name": "j", + "id": 4294965003, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "name": "i", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964994, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 3, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ], + "trueLabel": 9, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 9 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 5, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "j", + "line_start": 5, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "conditional", + "line_start": 5, + "col_start": 27, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "j", + "line_start": 5, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ], + "trueLabel": 8, + "falseLabel": 6 + } + ], + "edges": [ + { + "flags": 256, + "source": 5, + "target": 8 + }, + { + "flags": 512, + "source": 5, + "target": 6 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "predict", + "line_start": 5, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "hassub": 0, + "name": "continue" + } + ], + "edges": [ + { + "flags": 1, + "source": 6, + "target": 7 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "assign", + "line_start": 5, + "col_start": 9, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "j", + "line_start": 5, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965003, + "name": "j", + "line_start": 5, + "col_start": 18, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 5 + } + ], + "edges": [ + { + "flags": 1, + "source": 7, + "target": 5 + } + ] + }, + { + "index": 8, + "statements": [ + { + "type": "assign", + "line_start": 3, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 3, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 8, + "target": 3 + } + ] + }, + { + "index": 9, + "statements": [ + { + "type": "assign", + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964994, + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 9, + "target": 10 + } + ] + }, + { + "index": 10, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964994, + "line_start": 10, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/nested_continue.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 10, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c new file mode 100644 index 000000000..0c95507e6 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c @@ -0,0 +1,9 @@ +int main() +{ + // Tests break in root level + for (int i = 0; i < 1; i++) + { + break; + } + return 1; +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break_gcc_ast.json new file mode 100644 index 000000000..c898adad6 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break_gcc_ast.json @@ -0,0 +1,235 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c", + "line_start": 2, + "line_end": 9, + "variableDeclarations": [ + { + "name": "i", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964999, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 4, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 4, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + }, + { + "type": "conditional", + "line_start": 4, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 4, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ], + "trueLabel": 4, + "falseLabel": 3 + } + ], + "edges": [ + { + "flags": 256, + "source": 2, + "target": 4 + }, + { + "flags": 512, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "assign", + "line_start": 8, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964999, + "line_start": 8, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964999, + "line_start": 8, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_break.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 5, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c b/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c new file mode 100644 index 000000000..ba9931976 --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c @@ -0,0 +1,9 @@ +int main() +{ + // Tests continue in root level + for (int i = 0; i < 1; i++) + { + continue; + } + return 1; +} \ No newline at end of file diff --git a/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue_gcc_ast.json b/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue_gcc_ast.json new file mode 100644 index 000000000..a03e6a93e --- /dev/null +++ b/tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue_gcc_ast.json @@ -0,0 +1,315 @@ +{ + "mainInputFilename": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c", + "functions": [ + { + "id": 4294965006, + "name": "main", + "mangledName": "main", + "weak": false, + "inline": false, + "public": true, + "decl_line_start": 1, + "decl_col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c", + "line_start": 2, + "line_end": 9, + "variableDeclarations": [ + { + "name": "i", + "id": 4294965004, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + }, + { + "id": 4294964999, + "static": false, + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "basicBlocks": [ + { + "index": 0, + "statements": [ + ], + "edges": [ + { + "flags": 1, + "source": 0, + "target": 2 + } + ] + }, + { + "index": 2, + "statements": [ + { + "type": "assign", + "line_start": 4, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 4, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 2, + "target": 3 + } + ] + }, + { + "index": 3, + "statements": [ + { + "type": "conditional", + "line_start": 4, + "col_start": 23, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c", + "operator": "gt_expr", + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 4, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 0 + } + ], + "trueLabel": 6, + "falseLabel": 4 + } + ], + "edges": [ + { + "flags": 256, + "source": 3, + "target": 6 + }, + { + "flags": 512, + "source": 3, + "target": 4 + } + ] + }, + { + "index": 4, + "statements": [ + { + "type": "predict", + "line_start": 4, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c", + "hassub": 0, + "name": "continue" + } + ], + "edges": [ + { + "flags": 1, + "source": 4, + "target": 5 + } + ] + }, + { + "index": 5, + "statements": [ + { + "type": "assign", + "line_start": 4, + "col_start": 5, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c", + "operator": "plus_expr", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 4, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c" + }, + "operands": [ + { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294965004, + "name": "i", + "line_start": 4, + "col_start": 14, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c" + }, + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + }, + { + "type": "goto", + "target": 3 + } + ], + "edges": [ + { + "flags": 1, + "source": 5, + "target": 3 + } + ] + }, + { + "index": 6, + "statements": [ + { + "type": "assign", + "line_start": 8, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c", + "operator": "integer_cst", + "lhs": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964999, + "line_start": 8, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c" + }, + "operands": [ + { + "code": "integer_cst", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "value": 1 + } + ] + } + ], + "edges": [ + { + "flags": 1, + "source": 6, + "target": 7 + } + ] + }, + { + "index": 7, + "statements": [ + { + "type": "return", + "line_start": 0, + "col_start": 0, + "value": { + "code": "var_decl", + "type": { + "type": "integer_type", + "size": 32, + "unsigned": false + }, + "id": 4294964999, + "line_start": 8, + "col_start": 12, + "file": "../../../../tests/data/program_analysis/language_tests/c/control_flow_interruption/simple_continue.c" + } + } + ], + "edges": [ + { + "flags": 0, + "source": 7, + "target": 1 + } + ] + }, + { + "index": 1, + "statements": [ + ], + "edges": [ + ] + } + ], + "returnType": { + "type": "integer_type", + "size": 32, + "unsigned": false + } + } + ], + "aliases": [ + ], + "globalVariables": [ + ], + "recordTypes": [ + ] +} \ No newline at end of file diff --git a/tests/program_analysis/GCC2GrFN/test_gcc_plugin_c.py b/tests/program_analysis/GCC2GrFN/test_gcc_plugin_c.py index 7fbb4b1eb..7d891dcf3 100644 --- a/tests/program_analysis/GCC2GrFN/test_gcc_plugin_c.py +++ b/tests/program_analysis/GCC2GrFN/test_gcc_plugin_c.py @@ -15,7 +15,7 @@ GCC_10_BIN_DIRECTORY = "/usr/local/gcc-10.1.0/bin/" GCC_PLUGIN_IMAGE = "automates/program_analysis/gcc_plugin/plugin/ast_dump.so" GCC_TEST_DATA_DIRECTORY = "tests/data/program_analysis/GCC2GrFN" - +GCC_CAST_TEST_DATA = "tests/data/program_analysis/language_tests/c/" def cleanup(): if os.path.exists("./ast.json"): @@ -462,6 +462,327 @@ def test_function_call_nested(): expected_result = {"onesixtyeight": np.array([168])} evaluate_execution_results(expected_result, result) +def test_complex_break_1(): + test_name = "complex_break_1" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_complex_break_2(): + test_name = "complex_break_2" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_complex_continue_1(): + test_name = "complex_continue_1" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_cond_continue(): + test_name = "cond_continue" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_early_return_1(): + test_name = "early_return_1" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_early_return_2(): + test_name = "early_return_2" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_early_return_3(): + test_name = "early_return_3" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_early_return_4(): + test_name = "early_return_4" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_mixed_break_continue_1(): + test_name = "mixed_break_continue_1" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_nested_break_2(): + test_name = "nested_break_2" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_nested_break(): + test_name = "nested_break" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_nested_continue(): + test_name = "nested_continue" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_simple_break(): + test_name = "simple_break" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + + +def test_simple_continue(): + test_name = "simple_continue" + + # Generate gcc ast + run_gcc_plugin_with_c_file(f"{GCC_CAST_TEST_DATA}/{test_name}.c") + + assert os.path.exists(f"./{test_name}_gcc_ast.json") + + # Generate the test CAST using the GCC AST json + gcc_ast_obj = json.load(open(f"./{test_name}_gcc_ast.json")) + cast = GCC2CAST([gcc_ast_obj]).to_cast() + + # Load the expected_cast from json + assert os.path.exists(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json") + expected_cast_json = json.load(open(f"{GCC_CAST_TEST_DATA}/{test_name}_gcc_ast_expected--CAST.json")) + expected_cast = CAST.from_json_data(expected_cast_json) + + # Check the cast works + assert expected_cast == cast + + # TODO: Go to GrFN (Later) + @pytest.mark.skip(reason="Developing still") def test_if_statement(): @@ -609,3 +930,5 @@ def test_GE_simple_PI_controller(): @pytest.mark.skip(reason="Developing still") def test_simple_controller_bhpm(): pass + +