Browse Source

clif: Fix parsing the `cold` calling convention (#8854)

The identifier for the `cold` calling convention overlaps with the
`cold` keyword for basic blocks so handle another kind of token when
parsing signatures.
pull/8858/head
Alex Crichton 5 months ago
committed by GitHub
parent
commit
6b892131d3
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      cranelift/filetests/filetests/parser/cold.clif
  2. 10
      cranelift/reader/src/parser.rs

12
cranelift/filetests/filetests/parser/cold.clif

@ -0,0 +1,12 @@
test cat
function %cold() cold {
sig0 = () cold
sig1 = () -> i8 cold
block1:
return
}
; sameln: function %cold() cold {
; nextln: sig0 = () cold
; nextln: sig1 = () -> i8 cold

10
cranelift/reader/src/parser.rs

@ -1347,14 +1347,20 @@ impl<'a> Parser<'a> {
} }
// The calling convention is optional. // The calling convention is optional.
if let Some(Token::Identifier(text)) = self.token() { match self.token() {
match text.parse() { Some(Token::Identifier(text)) => match text.parse() {
Ok(cc) => { Ok(cc) => {
self.consume(); self.consume();
sig.call_conv = cc; sig.call_conv = cc;
} }
_ => return err!(self.loc, "unknown calling convention: {}", text), _ => return err!(self.loc, "unknown calling convention: {}", text),
},
Some(Token::Cold) => {
self.consume();
sig.call_conv = CallConv::Cold;
} }
_ => {}
} }
Ok(sig) Ok(sig)

Loading…
Cancel
Save