Summary: This diff fixes the clang translation for switch statement. It assumed that `default:` comes always at last, which introduced some unreachable nodes inadvertently, e.g. when `default:` comes at first. Reviewed By: dulmarod Differential Revision: D19793138 fbshipit-source-id: 1e8b52c0dmaster
parent
a864823f38
commit
92e7aeeb3e
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void default_last(int i) {
|
||||||
|
switch (i) {
|
||||||
|
case 1:
|
||||||
|
i = 2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
i = 3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
i = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void default_first(int i) {
|
||||||
|
switch (i) {
|
||||||
|
default:
|
||||||
|
i = 0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
i = 2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
i = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void default_middle(int i) {
|
||||||
|
switch (i) {
|
||||||
|
case 1:
|
||||||
|
i = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
i = 0;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
i = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void default_middle_no_break(int i) {
|
||||||
|
switch (i) {
|
||||||
|
case 1:
|
||||||
|
i = 2;
|
||||||
|
default:
|
||||||
|
i = 0;
|
||||||
|
case 2:
|
||||||
|
i = 3;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,167 @@
|
|||||||
|
/* @generated */
|
||||||
|
digraph cfg {
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_1" [label="1: Start default_first\nFormals: i:int\nLocals: \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_1" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_3" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_2" [label="2: Exit default_first \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_3" [label="3: SwitchStmt \n n$0=*&i:int [line 23, column 11]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_3" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_9" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_3" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_10" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_4" [label="4: BinaryOperatorStmt: Assign \n *&i:int=3 [line 31, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_4" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_2" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_5" [label="5: BinaryOperatorStmt: Assign \n *&i:int=2 [line 28, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_5" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_2" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_6" [label="6: BinaryOperatorStmt: Assign \n *&i:int=0 [line 25, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_6" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_2" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_7" [label="7: Prune (true branch, switch) \n PRUNE((n$0 == 2), true); [line 30, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_7" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_4" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_8" [label="8: Prune (false branch, switch) \n PRUNE(!(n$0 == 2), false); [line 30, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_8" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_6" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_9" [label="9: Prune (true branch, switch) \n PRUNE((n$0 == 1), true); [line 27, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_9" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_5" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_10" [label="10: Prune (false branch, switch) \n PRUNE(!(n$0 == 1), false); [line 27, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_10" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_7" ;
|
||||||
|
"default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_10" -> "default_first#6846905812772168043.4ef6682b69256b2600b845667cf73cc5_8" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_1" [label="1: Start default_last\nFormals: i:int\nLocals: \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_1" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_3" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_2" [label="2: Exit default_last \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_3" [label="3: SwitchStmt \n n$0=*&i:int [line 9, column 11]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_3" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_9" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_3" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_10" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_4" [label="4: BinaryOperatorStmt: Assign \n *&i:int=0 [line 17, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_4" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_2" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_5" [label="5: BinaryOperatorStmt: Assign \n *&i:int=3 [line 14, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_5" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_2" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_6" [label="6: BinaryOperatorStmt: Assign \n *&i:int=2 [line 11, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_6" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_2" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_7" [label="7: Prune (true branch, switch) \n PRUNE((n$0 == 2), true); [line 13, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_7" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_5" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_8" [label="8: Prune (false branch, switch) \n PRUNE(!(n$0 == 2), false); [line 13, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_8" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_4" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_9" [label="9: Prune (true branch, switch) \n PRUNE((n$0 == 1), true); [line 10, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_9" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_6" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_10" [label="10: Prune (false branch, switch) \n PRUNE(!(n$0 == 1), false); [line 10, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_10" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_7" ;
|
||||||
|
"default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_10" -> "default_last#16530854322231458976.ca2a177e8abc1894ef39d12e3b93b5ce_8" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_1" [label="1: Start default_middle\nFormals: i:int\nLocals: \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_1" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_3" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_2" [label="2: Exit default_middle \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_3" [label="3: SwitchStmt \n n$0=*&i:int [line 37, column 11]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_3" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_9" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_3" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_10" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_4" [label="4: BinaryOperatorStmt: Assign \n *&i:int=3 [line 45, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_4" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_2" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_5" [label="5: BinaryOperatorStmt: Assign \n *&i:int=0 [line 42, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_5" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_2" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_6" [label="6: BinaryOperatorStmt: Assign \n *&i:int=2 [line 39, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_6" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_2" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_7" [label="7: Prune (true branch, switch) \n PRUNE((n$0 == 2), true); [line 44, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_7" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_4" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_8" [label="8: Prune (false branch, switch) \n PRUNE(!(n$0 == 2), false); [line 44, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_8" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_5" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_9" [label="9: Prune (true branch, switch) \n PRUNE((n$0 == 1), true); [line 38, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_9" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_6" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_10" [label="10: Prune (false branch, switch) \n PRUNE(!(n$0 == 1), false); [line 38, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_10" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_7" ;
|
||||||
|
"default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_10" -> "default_middle#6704148577752077233.063f27b3bbfd847c375c1fb990fa5aff_8" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_1" [label="1: Start default_middle_no_break\nFormals: i:int\nLocals: \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_1" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_3" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_2" [label="2: Exit default_middle_no_break \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_3" [label="3: SwitchStmt \n n$0=*&i:int [line 51, column 11]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_3" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_9" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_3" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_10" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_4" [label="4: BinaryOperatorStmt: Assign \n *&i:int=3 [line 57, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_4" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_2" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_5" [label="5: BinaryOperatorStmt: Assign \n *&i:int=0 [line 55, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_5" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_4" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_6" [label="6: BinaryOperatorStmt: Assign \n *&i:int=2 [line 53, column 7]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_6" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_5" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_7" [label="7: Prune (true branch, switch) \n PRUNE((n$0 == 2), true); [line 56, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_7" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_4" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_8" [label="8: Prune (false branch, switch) \n PRUNE(!(n$0 == 2), false); [line 56, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_8" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_5" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_9" [label="9: Prune (true branch, switch) \n PRUNE((n$0 == 1), true); [line 52, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_9" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_6" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_10" [label="10: Prune (false branch, switch) \n PRUNE(!(n$0 == 1), false); [line 52, column 5]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_10" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_7" ;
|
||||||
|
"default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_10" -> "default_middle_no_break#4834754287745914325.bb66b5ddc891f61f192c15c288bc776c_8" ;
|
||||||
|
}
|
Loading…
Reference in new issue