Skip to content

Commit

Permalink
qptr/lift: do not add redundant errors to qptr::analyze bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Apr 21, 2023
1 parent afebdee commit c5eefca
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/qptr/lift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::qptr::{shapes, QPtrAttr, QPtrMemUsage, QPtrMemUsageKind, QPtrOp, QPtr
use crate::transform::{InnerInPlaceTransform, InnerTransform, Transformed, Transformer};
use crate::{
spv, AddrSpace, Attr, AttrSet, AttrSetDef, Const, ConstCtor, ConstDef, Context, ControlNode,
ControlNodeKind, DataInst, DataInstDef, DataInstKind, DeclDef, Diag, EntityDefs,
ControlNodeKind, DataInst, DataInstDef, DataInstKind, DeclDef, Diag, DiagLevel, EntityDefs,
EntityOrientedDenseMap, Func, FuncDecl, FxIndexMap, GlobalVar, GlobalVarDecl, Module, Type,
TypeCtor, TypeCtorArg, TypeDef, Value,
};
Expand Down Expand Up @@ -1156,7 +1156,28 @@ impl Transformer for LiftToSpvPtrInstsInFunc<'_> {
self.add_value_uses(&data_inst_def.inputs);
}
Err(LiftError(e)) => {
func_at_inst.def().attrs.push_diag(&self.lifter.cx, e);
let data_inst_def = func_at_inst.def();

// HACK(eddyb) do not add redundant errors to `qptr::analyze` bugs.
let has_qptr_analysis_bug_diags = self.lifter.cx[data_inst_def.attrs]
.attrs
.iter()
.any(|attr| match attr {
Attr::Diagnostics(diags) => {
diags.0.iter().any(|diag| match diag.level {
DiagLevel::Bug(loc) => {
loc.file().ends_with("qptr/analyze.rs")
|| loc.file().ends_with("qptr\\analyze.rs")
}
_ => false,
})
}
_ => false,
});

if !has_qptr_analysis_bug_diags {
data_inst_def.attrs.push_diag(&self.lifter.cx, e);
}
}
}
}
Expand Down

0 comments on commit c5eefca

Please sign in to comment.