[clang frontend] Translate BinaryOperators in ifs equally whether they are part of a ExprWithCleanups or not
Summary: I noticed when looking into a false positive of strongSelf Not Checked, that there were some inconsistencies in the translation of if statements with an and, with an extra redundant join only if using a method in the condition that returned an object. So I could repro the problem and investigate and found the place of the inconsistency in the translation. This diff fixes it without changing things too much. Reviewed By: jvillard Differential Revision: D19518368 fbshipit-source-id: 47a6a778cmaster
parent
5a1641d319
commit
430727519b
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
#include <Foundation/NSObject.h>
|
||||
|
||||
id foo();
|
||||
|
||||
bool foo_bool();
|
||||
|
||||
int call_bool_function_in_and_cond_in_if() {
|
||||
int* p;
|
||||
if (p && foo_bool()) {
|
||||
return 5;
|
||||
} else
|
||||
return 4;
|
||||
}
|
||||
|
||||
int call_object_function_in_and_cond_in_if() {
|
||||
int* p;
|
||||
if (p && foo()) {
|
||||
return 5;
|
||||
} else
|
||||
return 4;
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/* @generated */
|
||||
digraph cfg {
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_1" [label="1: Start call_bool_function_in_and_cond_in_if\nFormals: \nLocals: p:int* \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_1" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_5" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_1" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_6" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_2" [label="2: Exit call_bool_function_in_and_cond_in_if \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_3" [label="3: + \n " ]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_3" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_4" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_4" [label="4: between_join_and_exit \n " shape="box"]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_4" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_2" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_5" [label="5: Prune (true branch, if) \n n$0=*&p:int* [line 15, column 7]\n PRUNE(n$0, true); [line 15, column 7]\n " shape="invhouse"]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_5" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_7" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_6" [label="6: Prune (false branch, if) \n n$0=*&p:int* [line 15, column 7]\n PRUNE(!n$0, false); [line 15, column 7]\n " shape="invhouse"]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_6" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_11" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_7" [label="7: Call _fun_foo_bool \n n$1=_fun_foo_bool() [line 15, column 12]\n " shape="box"]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_7" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_8" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_7" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_9" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_8" [label="8: Prune (true branch, if) \n PRUNE(n$1, true); [line 15, column 12]\n " shape="invhouse"]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_8" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_10" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_9" [label="9: Prune (false branch, if) \n PRUNE(!n$1, false); [line 15, column 12]\n " shape="invhouse"]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_9" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_11" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_10" [label="10: Return Stmt \n *&return:int=5 [line 16, column 5]\n " shape="box"]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_10" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_2" ;
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_11" [label="11: Return Stmt \n *&return:int=4 [line 18, column 5]\n " shape="box"]
|
||||
|
||||
|
||||
"call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_11" -> "call_bool_function_in_and_cond_in_if.acba4fbddb9f2790bb3c01ace140ce3f_2" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_1" [label="1: Start call_object_function_in_and_cond_in_if\nFormals: \nLocals: p:int* \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_1" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_5" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_1" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_6" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_2" [label="2: Exit call_object_function_in_and_cond_in_if \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_3" [label="3: + \n " ]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_3" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_4" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_4" [label="4: between_join_and_exit \n " shape="box"]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_4" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_2" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_5" [label="5: Prune (true branch, if) \n n$0=*&p:int* [line 23, column 7]\n PRUNE(n$0, true); [line 23, column 7]\n " shape="invhouse"]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_5" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_7" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_6" [label="6: Prune (false branch, if) \n n$0=*&p:int* [line 23, column 7]\n PRUNE(!n$0, false); [line 23, column 7]\n " shape="invhouse"]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_6" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_11" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_7" [label="7: Call _fun_foo \n n$1=_fun_foo() [line 23, column 12]\n " shape="box"]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_7" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_8" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_7" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_9" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_8" [label="8: Prune (true branch, if) \n PRUNE(n$1, true); [line 23, column 12]\n " shape="invhouse"]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_8" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_10" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_9" [label="9: Prune (false branch, if) \n PRUNE(!n$1, false); [line 23, column 12]\n " shape="invhouse"]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_9" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_11" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_10" [label="10: Return Stmt \n *&return:int=5 [line 24, column 5]\n " shape="box"]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_10" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_2" ;
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_11" [label="11: Return Stmt \n *&return:int=4 [line 26, column 5]\n " shape="box"]
|
||||
|
||||
|
||||
"call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_11" -> "call_object_function_in_and_cond_in_if.1ada6e5c400b531e58154167f56912e3_2" ;
|
||||
}
|
Loading…
Reference in new issue