@@ -360,15 +360,22 @@ def parse(level: int = 0) -> set[bool]:
360360
361361
362362def _apple_fdatasync (text : str ) -> tuple [int , list [int ]]:
363- """Count lexical calls and locate those not provably excluded on Apple."""
363+ """Count direct lexical calls not provably excluded on Apple.
364+
365+ Check bare fdatasync(...) and ::fdatasync(...), excluding member calls.
366+ Indirect calls through function pointers and token-pasted calls are
367+ outside this lexical check.
368+ """
364369 # Splice before masking, as C++ does, including continued // comments.
365370 # Keep enough offset information to report physical source line numbers.
366371 splices = [match .start () - 2 * index for index , match in
367372 enumerate (re .finditer (r"\\\n" , text ))]
368373 masked = _mask_cpp (text .replace ("\\ \n " , "" ))
369374 calls : dict [int , list [int ]] = {}
370375 count = 0
371- for match in re .finditer (r"::\s*fdatasync\s*\(" , masked ):
376+ for match in re .finditer (r"(?:::\s*|(?<!\w))fdatasync\s*\(" , masked ):
377+ if masked [:match .start ()].rstrip ().endswith (("." , "->" )):
378+ continue
372379 logical_line = masked .count ("\n " , 0 , match .start ()) + 1
373380 physical_offset = match .start () + 2 * bisect_right (splices , match .start ())
374381 calls .setdefault (logical_line , []).append (
@@ -382,7 +389,7 @@ def _apple_fdatasync(text: str) -> tuple[int, list[int]]:
382389 stack : list [tuple [bool , bool , bool ]] = []
383390 reachable = True
384391 exposed : list [int ] = []
385- for line_number , line in enumerate (masked .splitlines ( ), 1 ):
392+ for line_number , line in enumerate (masked .split ( " \n " ), 1 ):
386393 directive = re .match (r"^\s*#\s*(if|ifdef|ifndef|elif|else|endif)\b(.*)" , line )
387394 if directive :
388395 kind , expression = directive .groups ()
0 commit comments