diff --git a/infer/src/llvm/lLexer.mll b/infer/src/llvm/lLexer.mll index 64d872558..4213b65a1 100644 --- a/infer/src/llvm/lLexer.mll +++ b/infer/src/llvm/lLexer.mll @@ -166,10 +166,12 @@ rule token = parse | '%' (nonneg_int as i) { NUMBERED_LOCAL (int_of_string i) } | id as str { IDENT str } + (* METADATA *) | "!dbg" { DEBUG_ANNOTATION } | '!' (id as str) { NAMED_METADATA str } | '!' (nonneg_int as i) { NUMBERED_METADATA (int_of_string i) } - | '!' '{' [^ '\n']* '}' { METADATA_NODE } + | '!' '"' ([^ '"']* as str) '"' { METADATA_STRING str } + | "!{" { METADATA_NODE_BEGIN } (* attribute groups *) | '#' (nonneg_int as i) { ATTRIBUTE_GROUP (int_of_string i) } diff --git a/infer/src/llvm/lParser.mly b/infer/src/llvm/lParser.mly index 3d32c39ed..eea33c03b 100644 --- a/infer/src/llvm/lParser.mly +++ b/infer/src/llvm/lParser.mly @@ -138,7 +138,8 @@ %token DEBUG_ANNOTATION %token NAMED_METADATA %token NUMBERED_METADATA -%token METADATA_NODE +%token METADATA_STRING +%token METADATA_NODE_BEGIN %token ATTRIBUTE_GROUP @@ -169,12 +170,23 @@ target_triple: | TARGET TRIPLE EQUALS str = CONSTANT_STRING { str } metadata_def: - | metadata_var EQUALS METADATA? METADATA_NODE { () } + | metadata_var EQUALS metadata_node { () } metadata_var: | NAMED_METADATA { () } | NUMBERED_METADATA { () } +metadata_node: + | METADATA? METADATA_NODE_BEGIN separated_list(COMMA, metadata_component) RBRACE { () } + +metadata_component: + | tp = typ? op = operand { () } + | METADATA? metadata_value { () } + +metadata_value: + | metadata_var { () } + | METADATA_STRING { () } + func_def: | DEFINE ret_tp = ret_typ name = variable LPAREN params = separated_list(COMMA, pair(typ, IDENT)) RPAREN attribute_group*