[clang] support `SubstNonTypeTemplateParmExpr`

Summary:
These just point to expressions that we know how to translate.

Fixes #950

Reviewed By: mbouaziz

Differential Revision: D8713784

fbshipit-source-id: 9eafa39
master
Jules Villard 6 years ago committed by Facebook Github Bot
parent 718f81ac77
commit 2c8d7a2046

@ -3417,10 +3417,11 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
sub-expressions *) sub-expressions *)
| ObjCAvailabilityCheckExpr (_, _, expr_info, _) -> | ObjCAvailabilityCheckExpr (_, _, expr_info, _) ->
undefined_expr trans_state expr_info undefined_expr trans_state expr_info
| SubstNonTypeTemplateParmExpr (_, stmts, _) | SubstNonTypeTemplateParmPackExpr (_, stmts, _) ->
let[@warning "-8"] [expr] = stmts in
instruction trans_state expr
(* Infer somehow ended up in templated non instantiated code - right now (* Infer somehow ended up in templated non instantiated code - right now
it's not supported and failure in those cases is expected. *) it's not supported and failure in those cases is expected. *)
| SubstNonTypeTemplateParmExpr ({Clang_ast_t.si_source_range}, _, _)
| SubstNonTypeTemplateParmPackExpr ({Clang_ast_t.si_source_range}, _, _)
| CXXDependentScopeMemberExpr ({Clang_ast_t.si_source_range}, _, _) -> | CXXDependentScopeMemberExpr ({Clang_ast_t.si_source_range}, _, _) ->
CFrontend_config.unimplemented __POS__ si_source_range CFrontend_config.unimplemented __POS__ si_source_range
~ast_node:(Clang_ast_proj.get_stmt_kind_string instr) ~ast_node:(Clang_ast_proj.get_stmt_kind_string instr)

@ -17,3 +17,5 @@ codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus2_bad, 2, DEAD
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus3_bad, 2, DEAD_STORE, no_bucket, ERROR, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus3_bad, 2, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::reassign_param_bad, 0, DEAD_STORE, no_bucket, ERROR, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::reassign_param_bad, 0, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::use_then_dead_bad, 3, DEAD_STORE, no_bucket, ERROR, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::use_then_dead_bad, 3, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/non_type_template_param.cpp, X<3>_isZeroBad, 1, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/non_type_template_param.cpp, instanciateTemplateBad, 3, DEAD_STORE, no_bucket, ERROR, [Write of unused value]

@ -0,0 +1,22 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// see also https://github.com/facebook/infer/issues/950
template <int T>
struct X {
bool isZeroBad() {
int unused = 1;
return T == 0;
}
};
int instanciateTemplateBad() {
X<3> x;
x.isZeroBad();
int unused = 1;
return 0;
}
Loading…
Cancel
Save