Skip to content

Commit 1c75034

Browse files
gh-131498: Remove commented-out dead code in cases_generator/analyzer.py (#141168)
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 <osama.abdelkader@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent 9a4187a commit 1c75034

1 file changed

Lines changed: 0 additions & 58 deletions

File tree

‎Tools/cases_generator/analyzer.py‎

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -480,64 +480,6 @@ def error(tkn: lexer.Token) -> None:
480480
return res
481481

482482

483-
#def analyze_deferred_refs(node: parser.InstDef) -> dict[lexer.Token, str | None]:
484-
#"""Look for PyStackRef_FromPyObjectNew() calls"""
485-
486-
#def in_frame_push(idx: int) -> bool:
487-
#for tkn in reversed(node.block.tokens[: idx - 1]):
488-
#if tkn.kind in {"SEMI", "LBRACE", "RBRACE"}:
489-
#return False
490-
#if tkn.kind == "IDENTIFIER" and tkn.text == "_PyFrame_PushUnchecked":
491-
#return True
492-
#return False
493-
494-
#refs: dict[lexer.Token, str | None] = {}
495-
#for idx, tkn in enumerate(node.block.tokens):
496-
#if tkn.kind != "IDENTIFIER" or tkn.text != "PyStackRef_FromPyObjectNew":
497-
#continue
498-
499-
#if idx == 0 or node.block.tokens[idx - 1].kind != "EQUALS":
500-
#if in_frame_push(idx):
501-
## PyStackRef_FromPyObjectNew() is called in _PyFrame_PushUnchecked()
502-
#refs[tkn] = None
503-
#continue
504-
#raise analysis_error("Expected '=' before PyStackRef_FromPyObjectNew", tkn)
505-
506-
#lhs = find_assignment_target(node, idx - 1)
507-
#if len(lhs) == 0:
508-
#raise analysis_error(
509-
#"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn
510-
#)
511-
512-
#if lhs[0].kind == "TIMES" or any(
513-
#t.kind == "ARROW" or t.kind == "LBRACKET" for t in lhs[1:]
514-
#):
515-
## Don't handle: *ptr = ..., ptr->field = ..., or ptr[field] = ...
516-
## Assume that they are visible to the GC.
517-
#refs[tkn] = None
518-
#continue
519-
520-
#if len(lhs) != 1 or lhs[0].kind != "IDENTIFIER":
521-
#raise analysis_error(
522-
#"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn
523-
#)
524-
525-
#name = lhs[0].text
526-
#match = (
527-
#any(var.name == name for var in node.inputs)
528-
#or any(var.name == name for var in node.outputs)
529-
#)
530-
#if not match:
531-
#raise analysis_error(
532-
#f"PyStackRef_FromPyObjectNew() must be assigned to an input or output, not '{name}'",
533-
#tkn,
534-
#)
535-
536-
#refs[tkn] = name
537-
538-
#return refs
539-
540-
541483
def variable_used(node: parser.CodeDef, name: str) -> bool:
542484
"""Determine whether a variable with a given name is used in a node."""
543485
return any(

0 commit comments

Comments
 (0)