From 6d7b8099f70d79cb9051b448fc05224c9952886c Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Tue, 13 Dec 2016 17:20:16 -0800 Subject: [PATCH] [java] treat all var names containing $ as temporaries Summary: We've had some issues with names like `arr$` appearing in error reports. Any identifier name that contains $ cannot have come from source code because it is not a legal Java identifier. This change should stop these reports because Errdesc.ml refuses to use temporary var names in error reports. Reviewed By: jeremydubreil Differential Revision: D4322305 fbshipit-source-id: 16237fe --- infer/src/IR/Pvar.re | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/infer/src/IR/Pvar.re b/infer/src/IR/Pvar.re index 54a75a576..86b829ea3 100644 --- a/infer/src/IR/Pvar.re +++ b/infer/src/IR/Pvar.re @@ -251,17 +251,15 @@ let tmp_prefix = "0$?%__sil_tmp"; /** return true if [pvar] is a temporary variable generated by the frontend */ let is_frontend_tmp pvar => { - /* Check whether the program variable is a temporary one generated by sawja */ - let is_sawja_tmp name => - String.is_prefix prefix::"$irvar" name || - String.is_prefix prefix::"$T" name || - String.is_prefix prefix::"$bc" name || String.is_prefix prefix::"CatchVar" name; + /* Check whether the program variable is a temporary one generated by Sawja, javac, or some other + bytecode/name generation pass. valid java identifiers cannot contain `$` */ + let is_bytecode_tmp name => String.contains name '$' || String.is_prefix prefix::"CatchVar" name; /* Check whether the program variable is generated by [mk_tmp] */ let is_sil_tmp name => String.is_prefix prefix::tmp_prefix name; let name = to_string pvar; is_sil_tmp name || ( switch pvar.pv_kind { - | Local_var pname => Procname.is_java pname && is_sawja_tmp name + | Local_var pname => Procname.is_java pname && is_bytecode_tmp name | _ => false } )