Translate CXXDefaultInitExpr

Summary:public
Do same thing we do to CXXDefaultArgExpr

Reviewed By: dulmarod

Differential Revision: D2954128

fb-gh-sync-id: 2c92c16
shipit-source-id: 2c92c16
master
Andrzej Kotulski 9 years ago committed by facebook-github-bot-1
parent 2b1558af6d
commit e4a0e9bbf7

@ -1 +1 @@
Subproject commit 60b10ef73606e814cf87c08e5c0d263dc1f9fb8c Subproject commit cadf02f4f3918062d8c51870af1beadca6140af8

@ -2034,8 +2034,8 @@ struct
stmt_info all_res_trans in stmt_info all_res_trans in
{ res_trans_to_parent with exps = [(res_ex, cast_type)] } { res_trans_to_parent with exps = [(res_ex, cast_type)] }
and cxxDefaultArgExpr_trans trans_state default_arg_info = and cxxDefaultExpr_trans trans_state default_expr_info =
match default_arg_info.Clang_ast_t.xdaei_init_expr with match default_expr_info.Clang_ast_t.xdaei_init_expr with
| Some exp -> instruction trans_state exp | Some exp -> instruction trans_state exp
| None -> assert false | None -> assert false
@ -2278,8 +2278,9 @@ struct
| CXXDynamicCastExpr (stmt_info, stmts, _, _, type_ptr, _) -> | CXXDynamicCastExpr (stmt_info, stmts, _, _, type_ptr, _) ->
cxxDynamicCastExpr_trans trans_state stmt_info stmts type_ptr cxxDynamicCastExpr_trans trans_state stmt_info stmts type_ptr
| CXXDefaultArgExpr (_, _, _, default_arg_info) -> | CXXDefaultArgExpr (_, _, _, default_expr_info)
cxxDefaultArgExpr_trans trans_state default_arg_info | CXXDefaultInitExpr (_, _, _, default_expr_info) ->
cxxDefaultExpr_trans trans_state default_expr_info
| s -> (Printing.log_stats | s -> (Printing.log_stats
"\n!!!!WARNING: found statement %s. \nACTION REQUIRED: Translation need to be defined. Statement ignored.... \n" "\n!!!!WARNING: found statement %s. \nACTION REQUIRED: Translation need to be defined. Statement ignored.... \n"

@ -0,0 +1,25 @@
/*
* Copyright (c) 2016 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
struct X {
int a = -1;
int b{-2};
int c{}; // doesn't work yet
int d;
X() = default;
X(int a, int b) : a(a + b) {}
};
struct Y {
X x1{1, 2};
X x2{};
X x3;
};
void test() { Y y; }

@ -0,0 +1,70 @@
digraph iCFG {
18 [label="18: DeclStmt \n _fun_Y_Y(&y:class Y *) [line 25]\n NULLIFY(&y,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"]
18 -> 17 ;
17 [label="17: Exit test \n " color=yellow style=filled]
16 [label="16: Start test\nFormals: \nLocals: y:class Y \n DECLARE_LOCALS(&return,&y); [line 25]\n " color=yellow style=filled]
16 -> 18 ;
15 [label="15: Constructor Init \n n$2=*&this:class Y * [line 20]\n _fun_X_X(n$2.x1:class X *,1:int ,2:int ) [line 20]\n REMOVE_TEMPS(n$2); [line 20]\n " shape="box"]
15 -> 14 ;
14 [label="14: Constructor Init \n n$1=*&this:class Y * [line 21]\n _fun_X_X(n$1.x2:class X *) [line 21]\n REMOVE_TEMPS(n$1); [line 21]\n " shape="box"]
14 -> 13 ;
13 [label="13: Constructor Init \n n$0=*&this:class Y * [line 19]\n _fun_X_X(n$0.x3:class X *) [line 19]\n REMOVE_TEMPS(n$0); [line 19]\n NULLIFY(&this,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"]
13 -> 12 ;
12 [label="12: Exit Y_Y \n " color=yellow style=filled]
11 [label="11: Start Y_Y\nFormals: this:class Y *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled]
11 -> 15 ;
10 [label="10: Constructor Init \n n$2=*&this:class X * [line 16]\n n$3=*&a:int [line 16]\n n$4=*&b:int [line 16]\n *n$2.a:int =(n$3 + n$4) [line 16]\n REMOVE_TEMPS(n$2,n$3,n$4); [line 16]\n NULLIFY(&a,false); [line 16]\n NULLIFY(&b,false); [line 16]\n " shape="box"]
10 -> 9 ;
9 [label="9: Constructor Init \n n$1=*&this:class X * [line 12]\n *n$1.b:int =-2 [line 12]\n REMOVE_TEMPS(n$1); [line 12]\n " shape="box"]
9 -> 8 ;
8 [label="8: Constructor Init \n n$0=*&this:class X * [line 13]\n *n$0.c:int =-1 [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&this,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"]
8 -> 7 ;
7 [label="7: Exit X_X \n " color=yellow style=filled]
6 [label="6: Start X_X\nFormals: this:class X * a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled]
6 -> 10 ;
5 [label="5: Constructor Init \n n$2=*&this:class X * [line 11]\n *n$2.a:int =-1 [line 15]\n REMOVE_TEMPS(n$2); [line 15]\n " shape="box"]
5 -> 4 ;
4 [label="4: Constructor Init \n n$1=*&this:class X * [line 12]\n *n$1.b:int =-2 [line 12]\n REMOVE_TEMPS(n$1); [line 12]\n " shape="box"]
4 -> 3 ;
3 [label="3: Constructor Init \n n$0=*&this:class X * [line 13]\n *n$0.c:int =-1 [line 15]\n REMOVE_TEMPS(n$0); [line 15]\n NULLIFY(&this,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"]
3 -> 2 ;
2 [label="2: Exit X_X \n " color=yellow style=filled]
1 [label="1: Start X_X\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled]
1 -> 5 ;
}

@ -58,4 +58,10 @@ public class ConstructorsTest {
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
frontendTest("copy_move_constructor.cpp"); frontendTest("copy_move_constructor.cpp");
} }
@Test
public void testDefaultFieldInitDotFilesMatch()
throws InterruptedException, IOException, InferException {
frontendTest("default_field_init.cpp");
}
} }

Loading…
Cancel
Save