Compute `AggregatedSpirvAttributes` for use during codegen. Any errors for malformed/duplicate attributes will have been reported prior to codegen, by the `attr` check pass.
(cx: &CodegenCx<'tcx>, attrs: &'tcx [Attribute])
| 146 | /// Any errors for malformed/duplicate attributes will have been reported |
| 147 | /// prior to codegen, by the `attr` check pass. |
| 148 | pub fn parse<'tcx>(cx: &CodegenCx<'tcx>, attrs: &'tcx [Attribute]) -> Self { |
| 149 | let mut aggregated_attrs = Self::default(); |
| 150 | |
| 151 | // NOTE(eddyb) `delay_span_bug` ensures that if attribute checking fails |
| 152 | // to see an attribute error, it will cause an ICE instead. |
| 153 | for parse_attr_result in crate::symbols::parse_attrs_for_checking(&cx.sym, attrs) { |
| 154 | let (span, parsed_attr) = match parse_attr_result { |
| 155 | Ok(span_and_parsed_attr) => span_and_parsed_attr, |
| 156 | Err((span, msg)) => { |
| 157 | cx.tcx.sess.delay_span_bug(span, msg); |
| 158 | continue; |
| 159 | } |
| 160 | }; |
| 161 | match aggregated_attrs.try_insert_attr(parsed_attr, span) { |
| 162 | Ok(()) => {} |
| 163 | Err(MultipleAttrs { |
| 164 | prev_span: _, |
| 165 | category, |
| 166 | }) => { |
| 167 | cx.tcx |
| 168 | .sess |
| 169 | .delay_span_bug(span, format!("multiple {category} attributes")); |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | aggregated_attrs |
| 175 | } |
| 176 | |
| 177 | fn try_insert_attr(&mut self, attr: SpirvAttribute, span: Span) -> Result<(), MultipleAttrs> { |
| 178 | fn try_insert<T>( |
no test coverage detected