From e24749290174bc6da56bce13e8433b046c24efd8 Mon Sep 17 00:00:00 2001 From: Martino Luca Date: Thu, 7 Sep 2017 10:29:17 -0700 Subject: [PATCH] [AL] Validate AST node names in AL source files Summary: This will prevent trivial errors like misspelling node names, e.g. when those are typed as part of the operators `IN-NODE ` or `HOLDS-IN-NODE ` Reviewed By: dulmarod Differential Revision: D5680411 fbshipit-source-id: e241c1c --- infer/src/clang/ctl_parser.mly | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/infer/src/clang/ctl_parser.mly b/infer/src/clang/ctl_parser.mly index 23a8d2443..53ed5e4aa 100644 --- a/infer/src/clang/ctl_parser.mly +++ b/infer/src/clang/ctl_parser.mly @@ -28,6 +28,11 @@ raise (CTLExceptions.ALParserInvariantViolationException ("ERROR: Variable '" ^ id ^ "' is undefined")) + let is_valid_astnode node_name = + if Clang_ast_proj.is_valid_astnode_kind node_name then () + else + raise (CTLExceptions.ALParserInvariantViolationException ("Invalid AST node " ^ node_name)) + %} %token EU @@ -97,8 +102,8 @@ var_list: ; node_list: - | identifier { [ALVar.Const $1] } - | identifier COMMA node_list { ALVar.Const($1) :: $3 } + | identifier { is_valid_astnode $1; [ALVar.Const $1] } + | identifier COMMA node_list { is_valid_astnode $1; ALVar.Const($1) :: $3 } ; formal_params: