From a31658a9b89a466e04c691b22cfebb24ca691788 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 25 Oct 2016 06:24:58 -0700 Subject: [PATCH] [clang] treat constexpr as const too Summary: The frontend replaces global variables that are constant with their values as a quick hack to improve the precision of the analysis. This should apply to `constexpr` too. Reviewed By: dulmarod Differential Revision: D4058097 fbshipit-source-id: be4fea6 --- infer/src/clang/cTrans.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index afd8b225d..f40b647be 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -631,8 +631,11 @@ struct when not (General_utils.is_cpp_translation context.translation_unit_context) -> (* Do not convert a global struct to a local because SIL values do not include structs, they must all be heap-allocated *) - false, None - | _ -> vdi.vdi_is_global && qual_type.qt_is_const, vdi.vdi_init_expr) + (false, None) + | _ -> + (vdi.vdi_is_global && (vdi.vdi_is_const_expr || qual_type.qt_is_const), + vdi.vdi_init_expr) + ) | _ -> false, None in if is_global_const then init_expr_trans trans_state (var_exp, typ) stmt_info init_expr