1919import argparse
2020import json
2121import re
22+ import sys
2223from collections import defaultdict
2324from dataclasses import dataclass
2425from enum import Enum
2526from itertools import product
2627from pathlib import Path
27- from typing import Dict , Iterable , List , Sequence , Tuple
28+ from typing import Any , Dict , Iterable , List , Sequence , Tuple
29+
30+ assert sys .version_info >= (3 , 10 ), "Only Python 3.10+ is supported."
2831
2932
3033# Are we testing arm_sve.h or arm_sme.h based builtins.
@@ -156,7 +159,7 @@ def make_arg_for_type(ty: str) -> Tuple[str, str]:
156159# Specifically the expected input is of the form:
157160# feat1,feat2,...(feat3 | feat4 | ...),...
158161def expand_feature_guard (
159- guard : str , flags : str , base_feature : str = None
162+ guard : str , flags : Sequence [ str ] , base_feature : str = ""
160163) -> list [set [str ]]:
161164 """
162165 Expand a guard expression where ',' = AND and '|' = OR, with parentheses
@@ -389,7 +392,7 @@ def build_calls_for_group(builtins: Iterable[str]) -> Tuple[List[str], List[str]
389392 """
390393 var_decls : List [str ] = []
391394 seen_types : set [str ] = set ()
392- calls : List [Tuple [ str , str ] ] = []
395+ calls : List [str ] = []
393396
394397 for decl in builtins :
395398 fn , param_types = parse_builtin_declaration (decl )
@@ -411,14 +414,15 @@ def build_calls_for_group(builtins: Iterable[str]) -> Tuple[List[str], List[str]
411414 return var_decls , calls
412415
413416
414- def gen_streaming_guard_tests (mode : MODE , json_path : Path , out_dir : Path ) -> None :
417+ def gen_streaming_guard_tests (mode : Mode , json_path : Path , out_dir : Path ) -> None :
415418 """Generate a set of Clang Sema test files to ensure SVE/SME builtins are
416419 callable based on the function type, or the required diagnostic is emitted.
417420 """
418421 try :
419422 data = json .loads (json_path .read_text ())
420423 except json .JSONDecodeError as e :
421- ap .error (f"Failed to parse JSON { args .json } : { e } " )
424+ print (f"Failed to parse JSON { json_path } : { e } " , file = sys .stderr )
425+ return
422426
423427 # Group by (guard, streaming_guard)
424428 by_guard : Dict [BuiltinContext , List [str ]] = defaultdict (list )
@@ -468,7 +472,7 @@ def gen_streaming_guard_tests(mode: MODE, json_path: Path, out_dir: Path) -> Non
468472 else :
469473 print (output )
470474
471- return 0
475+ return
472476
473477
474478# --- Main -------------------------------------------------------------------
0 commit comments