@@ -1571,13 +1571,28 @@ def get_config_options():
15711571 "MLK_BREAK_PCT" , # Use in PCT breakage test]
15721572 "MLK_CONFIG_NO_ASM_VALUE_BARRIER" , # TODO: Add to config?
15731573 "MLK_CHECK_APIS" ,
1574- "MLK_CONFIG_API_XXX" ,
1575- "MLK_USE_NATIVE_XXX" ,
15761574 ]
15771575
15781576 return configs
15791577
15801578
1579+ def is_macro_pattern (m ):
1580+ if not m .endswith ("_XXX" ):
1581+ return None
1582+ return m [:- 4 ]
1583+
1584+
1585+ def is_valid_macro_pattern (m , macros ):
1586+ pattern = is_macro_pattern (m )
1587+ if pattern is None :
1588+ return False
1589+ # Check that there is at least one macro following the pattern
1590+ for mp in macros :
1591+ if mp .startswith (pattern ):
1592+ return True
1593+ return False
1594+
1595+
15811596def check_macro_typos_in_file (filename , macro_check ):
15821597 """Checks for typos in MLK_XXX and MLKEM_XXX identifiers."""
15831598 status_update ("check-macros" , filename )
@@ -1590,9 +1605,14 @@ def check_macro_typos_in_file(filename, macro_check):
15901605 rest = m .group (2 )
15911606 if macro_check (txt , rest , filename ) is False :
15921607 line_no = content [: m .start ()].count ("\n " ) + 1
1593- raise Exception (
1594- f"Likely typo { txt } in { filename } :{ line_no } ? Not a defined macro."
1595- )
1608+ if is_macro_pattern (txt ):
1609+ raise Exception (
1610+ f"Likely typo { txt } in { filename } :{ line_no } ? No macro following the pattern exists"
1611+ )
1612+ else :
1613+ raise Exception (
1614+ f"Likely typo { txt } in { filename } :{ line_no } ? Not a defined macro nor valid pattern"
1615+ )
15961616
15971617
15981618def check_macro_typos ():
@@ -1603,7 +1623,7 @@ def check_macro_typos():
16031623 macros .update (get_config_options ())
16041624
16051625 def macro_check (m , rest , filename ):
1606- if m in macros :
1626+ if m in macros or is_valid_macro_pattern ( m , macros ) :
16071627 return True
16081628
16091629 is_autogen = filename == "scripts/autogen"
@@ -1627,12 +1647,7 @@ def check_macro_typos():
16271647 if filename .endswith (".ml" ):
16281648 return True
16291649
1630- # 4. Exclude regexp patterns in `autogen`
1631- if is_autogen :
1632- if rest .startswith ("\\ " ) or m in ["MLK_XXX" , "MLK_SOURCE_XXX" ]:
1633- return True
1634-
1635- # 5. AWS-LC importer patch
1650+ # 4. AWS-LC importer patch
16361651 if is_autogen or filename == "integration/awslc/awslc.patch" :
16371652 return True
16381653
0 commit comments