Fixed constexpr false positive

Reviewed By: ngorogiannis

Differential Revision: D14775559

fbshipit-source-id: 032bd4937
master
Dino Distefano 6 years ago committed by Facebook Github Bot
parent cf6ced0580
commit e2caf19d4f

@ -148,8 +148,8 @@ DEFINE-CHECKER STRONG_DELEGATE_WARNING = {
DEFINE-CHECKER GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL = {
LET is_global_variable =
is_objc_extension() AND is_global_var() AND (NOT is_const_var());
LET is_global_but_not_const_variable =
is_objc_extension() AND is_global_var() AND (NOT is_const_expr_var()) AND (NOT is_init_integral_constant_expr());
LET makes_an_expensive_call =
(is_node("CallExpr") AND NOT call_function("CGPointMake"))
@ -165,7 +165,7 @@ DEFINE-CHECKER GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL = {
SET report_when =
WHEN
(is_global_variable AND is_initialized_with_expensive_call)
(is_global_but_not_const_variable AND is_initialized_with_expensive_call)
HOLDS-IN-NODE VarDecl;
SET message =

@ -523,6 +523,14 @@ let is_const_expr_var an =
match an with Ctl_parser_types.Decl d -> CAst_utils.is_const_expr_var d | _ -> false
let is_init_integral_constant_expr an =
match an with
| Ctl_parser_types.Decl d -> (
match d with Clang_ast_t.VarDecl (_, _, _, vdi) -> vdi.vdi_is_init_ice | _ -> false )
| _ ->
false
let is_qual_type_const an =
match an with
| Ctl_parser_types.Stmt s -> (

@ -45,6 +45,9 @@ val is_static_local_var : Ctl_parser_types.ast_node -> bool
val is_const_expr_var : Ctl_parser_types.ast_node -> bool
(** 'is_const_expr_var an' is true iff an is a 'const' variable declaration *)
val is_init_integral_constant_expr : Ctl_parser_types.ast_node -> bool
(** 'is_init_integra_constant_expr an' is true iff it is an initializer and an integral constant expression, or in C++11, whether the initializer is a constant expression. *)
val is_qual_type_const : Ctl_parser_types.ast_node -> bool
(** 'is_qual_type_const an' is true iff an is a qual_type 'const' expression *)

@ -1004,8 +1004,10 @@ let rec eval_Atomic pred_name_ args an lcxt =
CPredicates.is_binop_with_kind an kind
| "is_class", [cname], an ->
CPredicates.is_class an cname
| "is_const_var", [], an ->
| "is_const_expr_var", [], an ->
CPredicates.is_const_expr_var an
| "is_init_integral_constant_expr", [], an ->
CPredicates.is_init_integral_constant_expr an
| "is_qual_type_const", [], an ->
CPredicates.is_qual_type_const an
| "has_init_list_const_expr", [], an ->

Loading…
Cancel
Save