Skip to content

Commit

Permalink
semdiff: drop metadata directive on the floor
Browse files Browse the repository at this point in the history
Summary:
the .metadata directive allows us to persist
arbitrary information into the repo. This is used for things
like storing the compiler version (and possibly other things)

Reviewed By: nbenton

Differential Revision: D6982353

fbshipit-source-id: f8c580ca512202043608f40400597ac93c2095fa
  • Loading branch information
Greg Nisbet authored and hhvm-bot committed Feb 14, 2018
1 parent 7c3f922 commit dadce53
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions hphp/hack/src/hhbc/hhas_lexer.mll
Expand Up @@ -93,6 +93,7 @@ rule read =
| ".require" {REQUIREDIRECTIVE} | ".require" {REQUIREDIRECTIVE}
| ".srcloc" {SRCLOCDIRECTIVE} | ".srcloc" {SRCLOCDIRECTIVE}
| assertconstraint {ASSERTCONSTRAINT (Lexing.lexeme lexbuf)} | assertconstraint {ASSERTCONSTRAINT (Lexing.lexeme lexbuf)}
| ".metadata" {METADATADIRECTIVE}
| id {ID (Lexing.lexeme lexbuf)} | id {ID (Lexing.lexeme lexbuf)}
| triplequoted as lxm {TRIPLEQUOTEDSTRING (String.sub lxm 3 (String.length lxm - 6))} | triplequoted as lxm {TRIPLEQUOTEDSTRING (String.sub lxm 3 (String.length lxm - 6))}
| escapequote {read_php_escaped_string (Buffer.create 17) lexbuf} | escapequote {read_php_escaped_string (Buffer.create 17) lexbuf}
Expand Down
9 changes: 9 additions & 0 deletions hphp/hack/src/hhbc/hhas_parser.mly
Expand Up @@ -29,6 +29,7 @@ open Hhas_parser_actions
%token TRYFAULTDIRECTIVE PROPERTYDIRECTIVE FILEPATHDIRECTIVE %token TRYFAULTDIRECTIVE PROPERTYDIRECTIVE FILEPATHDIRECTIVE
%token ISMEMOIZEWRAPPERDIRECTIVE STATICDIRECTIVE REQUIREDIRECTIVE %token ISMEMOIZEWRAPPERDIRECTIVE STATICDIRECTIVE REQUIREDIRECTIVE
%token SRCLOCDIRECTIVE %token SRCLOCDIRECTIVE
%token METADATADIRECTIVE
%token LANGLE %token LANGLE
%token RANGLE %token RANGLE
%token COLONCOLON %token COLONCOLON
Expand Down Expand Up @@ -290,6 +291,13 @@ srcloc:
| SRCLOCDIRECTIVE INT COLON INT COMMA INT COLON INT SEMI | SRCLOCDIRECTIVE INT COLON INT COMMA INT COLON INT SEMI
{ (($2, $4), ($6, $8)) } { (($2, $4), ($6, $8)) }
; ;

metadata:
| METADATADIRECTIVE ID EQUALS ID SEMI nl { (* do nothing *) }
| METADATADIRECTIVE ID EQUALS STRING SEMI nl { (* do nothing *) }
| METADATADIRECTIVE ID EQUALS TRIPLEQUOTEDSTRING SEMI nl { (* do nothing *) }
;

staticdirective: staticdirective:
| STATICDIRECTIVE VNAME EQUALS ID | STATICDIRECTIVE VNAME EQUALS ID
{ ($2, $4) } { ($2, $4) }
Expand Down Expand Up @@ -561,6 +569,7 @@ decllist:
| FILEPATHDIRECTIVE STRING SEMI nl decllist {$5} | FILEPATHDIRECTIVE STRING SEMI nl decllist {$5}
| STRICTDIRECTIVE INT SEMI nl decllist { StrictTypes_decl ($2 = 1L) :: $5} | STRICTDIRECTIVE INT SEMI nl decllist { StrictTypes_decl ($2 = 1L) :: $5}
| HHFILE INT SEMI nl decllist { HHFile_decl ($2 = 1L) :: $5 } | HHFILE INT SEMI nl decllist { HHFile_decl ($2 = 1L) :: $5 }
| metadata decllist { $2 }
; ;
includesdecl: includesdecl:
| INCLUDESDIRECTIVE { | INCLUDESDIRECTIVE {
Expand Down
14 changes: 14 additions & 0 deletions hphp/hack/test/semdiff/ignore_metadata_directive.1.hhas
@@ -0,0 +1,14 @@
# starts here

.filepath "/data/users/gregorynisbet/fbsource/fbcode/hphp/hack/test/semdiff/ignore_metadata_directive.1.hhas";

.metadata a = b;

.hh_file 1;

.main {
Int 1
RetC
}

# /data/users/gregorynisbet/fbsource/fbcode/hphp/hack/test/semdiff/ignore_metadata_directive.1.hhas
12 changes: 12 additions & 0 deletions hphp/hack/test/semdiff/ignore_metadata_directive.2.hhas
@@ -0,0 +1,12 @@
# starts here

.filepath "/data/users/gregorynisbet/fbsource/fbcode/hphp/hack/test/semdiff/ignore_metadata_directive.2.hhas";

.hh_file 1;

.main {
Int 1
RetC
}

# /data/users/gregorynisbet/fbsource/fbcode/hphp/hack/test/semdiff/ignore_metadata_directive.2.hhas

0 comments on commit dadce53

Please sign in to comment.