From 5d5b7c31acb18eeda81486a8c80f8a7956559e3d Mon Sep 17 00:00:00 2001 From: Osama Abdelkader Date: Thu, 6 Nov 2025 22:04:00 +0200 Subject: [PATCH 1/2] Remove commented-out dead code in cases_generator/analyzer.py Remove the unused analyze_deferred_refs() function that was completely commented out. This function is not referenced anywhere in the codebase and removing it improves code cleanliness. Signed-off-by: Osama Abdelkader --- Tools/cases_generator/analyzer.py | 57 ------------------------------- 1 file changed, 57 deletions(-) diff --git a/Tools/cases_generator/analyzer.py b/Tools/cases_generator/analyzer.py index 9dd7e5dbfbae7b..c6c69bc3a57cec 100644 --- a/Tools/cases_generator/analyzer.py +++ b/Tools/cases_generator/analyzer.py @@ -456,63 +456,6 @@ def error(tkn: lexer.Token) -> None: return res -#def analyze_deferred_refs(node: parser.InstDef) -> dict[lexer.Token, str | None]: - #"""Look for PyStackRef_FromPyObjectNew() calls""" - - #def in_frame_push(idx: int) -> bool: - #for tkn in reversed(node.block.tokens[: idx - 1]): - #if tkn.kind in {"SEMI", "LBRACE", "RBRACE"}: - #return False - #if tkn.kind == "IDENTIFIER" and tkn.text == "_PyFrame_PushUnchecked": - #return True - #return False - - #refs: dict[lexer.Token, str | None] = {} - #for idx, tkn in enumerate(node.block.tokens): - #if tkn.kind != "IDENTIFIER" or tkn.text != "PyStackRef_FromPyObjectNew": - #continue - - #if idx == 0 or node.block.tokens[idx - 1].kind != "EQUALS": - #if in_frame_push(idx): - ## PyStackRef_FromPyObjectNew() is called in _PyFrame_PushUnchecked() - #refs[tkn] = None - #continue - #raise analysis_error("Expected '=' before PyStackRef_FromPyObjectNew", tkn) - - #lhs = find_assignment_target(node, idx - 1) - #if len(lhs) == 0: - #raise analysis_error( - #"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn - #) - - #if lhs[0].kind == "TIMES" or any( - #t.kind == "ARROW" or t.kind == "LBRACKET" for t in lhs[1:] - #): - ## Don't handle: *ptr = ..., ptr->field = ..., or ptr[field] = ... - ## Assume that they are visible to the GC. - #refs[tkn] = None - #continue - - #if len(lhs) != 1 or lhs[0].kind != "IDENTIFIER": - #raise analysis_error( - #"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn - #) - - #name = lhs[0].text - #match = ( - #any(var.name == name for var in node.inputs) - #or any(var.name == name for var in node.outputs) - #) - #if not match: - #raise analysis_error( - #f"PyStackRef_FromPyObjectNew() must be assigned to an input or output, not '{name}'", - #tkn, - #) - - #refs[tkn] = name - - #return refs - def variable_used(node: parser.CodeDef, name: str) -> bool: """Determine whether a variable with a given name is used in a node.""" From 056b8e6726f1a6748c40c807758e4477bd3c494a Mon Sep 17 00:00:00 2001 From: Osama Abdelkader <78818069+osamakader@users.noreply.github.com> Date: Thu, 6 Nov 2025 22:18:40 +0200 Subject: [PATCH 2/2] add new line Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Tools/cases_generator/analyzer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Tools/cases_generator/analyzer.py b/Tools/cases_generator/analyzer.py index c6c69bc3a57cec..5a2d4f0f1053e8 100644 --- a/Tools/cases_generator/analyzer.py +++ b/Tools/cases_generator/analyzer.py @@ -456,7 +456,6 @@ def error(tkn: lexer.Token) -> None: return res - def variable_used(node: parser.CodeDef, name: str) -> bool: """Determine whether a variable with a given name is used in a node.""" return any(