File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Tools/c-analyzer/c_analyzer/common Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 9
9
10
10
UNKNOWN = '???'
11
11
12
- NAME_RE = re .compile (r'^([a-zA-Z]|_\w*[a-zA-Z]\w*|[a-zA-Z]\w*)$' )
12
+ # Does not start with digit and contains at least one letter.
13
+ NAME_RE = re .compile (r'(?!\d)(?=.*?[A-Za-z])\w+' , re .ASCII )
13
14
14
15
15
16
class ID (_NTBase , namedtuple ('ID' , 'filename funcname name' )):
@@ -50,17 +51,16 @@ def validate(self):
50
51
"""Fail if the object is invalid (i.e. init with bad data)."""
51
52
if not self .name :
52
53
raise TypeError ('missing name' )
53
- else :
54
- if not NAME_RE .match (self .name ):
55
- raise ValueError (
56
- f'name must be an identifier, got { self .name !r} ' )
54
+ if not NAME_RE .fullmatch (self .name ):
55
+ raise ValueError (
56
+ f'name must be an identifier, got { self .name !r} ' )
57
57
58
58
# Symbols from a binary might not have filename/funcname info.
59
59
60
60
if self .funcname :
61
61
if not self .filename :
62
62
raise TypeError ('missing filename' )
63
- if not NAME_RE .match (self .funcname ) and self .funcname != UNKNOWN :
63
+ if not NAME_RE .fullmatch (self .funcname ) and self .funcname != UNKNOWN :
64
64
raise ValueError (
65
65
f'name must be an identifier, got { self .funcname !r} ' )
66
66
You can’t perform that action at this time.
0 commit comments