mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-21 22:34:34 +00:00
spirt_passes/diagnostics: track uses of global variables more accurately.
This commit is contained in:
parent
7d99248b29
commit
08371d3264
@ -56,10 +56,12 @@ pub(crate) fn report_diagnostics(
|
|||||||
inst_attrs: AttrSet::default(),
|
inst_attrs: AttrSet::default(),
|
||||||
origin: IntraFuncUseOrigin::Other,
|
origin: IntraFuncUseOrigin::Other,
|
||||||
});
|
});
|
||||||
export_key.inner_visit_with(&mut reporter);
|
|
||||||
if reporter.seen_funcs.insert(func) {
|
if reporter.seen_funcs.insert(func) {
|
||||||
reporter.visit_func_decl(func_decl);
|
reporter.visit_func_decl(func_decl);
|
||||||
}
|
}
|
||||||
|
// NOTE(eddyb) this is visited last, so that uses of the interface
|
||||||
|
// variables don't lack relevant context from the function body.
|
||||||
|
export_key.inner_visit_with(&mut reporter);
|
||||||
reporter.use_stack.pop();
|
reporter.use_stack.pop();
|
||||||
}
|
}
|
||||||
export_key.inner_visit_with(&mut reporter);
|
export_key.inner_visit_with(&mut reporter);
|
||||||
@ -486,12 +488,20 @@ impl<'a> Visitor<'a> for DiagnosticReporter<'a> {
|
|||||||
fn visit_const_use(&mut self, ct: Const) {
|
fn visit_const_use(&mut self, ct: Const) {
|
||||||
if self.seen_consts.insert(ct) {
|
if self.seen_consts.insert(ct) {
|
||||||
let ct_def = &self.cx[ct];
|
let ct_def = &self.cx[ct];
|
||||||
self.use_stack.push(UseOrigin::Global {
|
match ct_def.ctor {
|
||||||
kind: &"constant",
|
// HACK(eddyb) don't push an `UseOrigin` for `GlobalVar` pointers.
|
||||||
attrs: ct_def.attrs,
|
ConstCtor::PtrToGlobalVar(_) if ct_def.attrs == AttrSet::default() => {
|
||||||
});
|
self.visit_const_def(ct_def);
|
||||||
self.visit_const_def(ct_def);
|
}
|
||||||
self.use_stack.pop();
|
_ => {
|
||||||
|
self.use_stack.push(UseOrigin::Global {
|
||||||
|
kind: &"constant",
|
||||||
|
attrs: ct_def.attrs,
|
||||||
|
});
|
||||||
|
self.visit_const_def(ct_def);
|
||||||
|
self.use_stack.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user