diag: preserve factual source atomic-access diagnostics
This commit is contained in:
1 parent
ee09a7a290
commit
edfef82cc6
18 files changed
+346
-9
No files matched your search
@@ -21,7 +21,7 @@ CORPUS = ROOT / 'tests/conformance'
|
||||
MANIFEST = CORPUS / 'reject-twins.json'
|
||||
IDENTITIES = {'function', 'block', 'inst', 'borrow', 'resource', 'task',
|
||||
'conflicts_with', 'scope', 'guard', 'child', 'inner', 'local', 'from',
|
||||
'callee', 'argument', 'task_function'}
|
||||
'callee', 'argument', 'task_function', 'operand'}
|
||||
ENVELOPE = {'code', 'kind', 'severity', 'file', 'line', 'col', 'air_line',
|
||||
'air_col', 'message', 'related_locations'}
|
||||
|
||||
@@ -310,6 +310,19 @@ def swapped_enum_class(air, d, value):
|
||||
|
||||
|
||||
def identity_fact(air, d, field):
|
||||
if field == 'operand':
|
||||
# E4202's operand is an SSA identity, tied to the reported load.
|
||||
# Other ordinary-access forms need their own rule audit.
|
||||
if d['code'] != 'E4202' or d.get('use') != 'atomic.load':
|
||||
raise ValueError('unsupported atomic operand identity rule')
|
||||
line = air.splitlines()[d['line'] - 1].split(';', 1)[0]
|
||||
rhs = line.split('=', 1)[-1].strip()
|
||||
if not re.fullmatch(r'load\s+' + re.escape(d[field]), rhs):
|
||||
raise ValueError('atomic operand is not the offending load operand')
|
||||
root = identity_class(air, d, d[field])
|
||||
if root != 'borrow':
|
||||
raise ValueError('ordinary atomic load operand lacks a borrow definition')
|
||||
return root
|
||||
if field == 'callee':
|
||||
# Parameter/result types do not decide the flat-effect rule.
|
||||
if d['code'] != 'E3101':
|
||||
|
||||
Reference in new issue
Block a user