Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: support logical assignment in code path analysis (refs #13569)
- Loading branch information
1 parent
091e52a
commit faa0094
Showing
64 changed files
with
1,393 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/fixtures/code-path-analysis/assignment--do-while-and.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_2->s1_4; | ||
s1_3->s1_4->final; | ||
*/ | ||
do { | ||
foo(); | ||
} while (a &&= b); | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nDoWhileStatement:enter"]; | ||
s1_2[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit\nAssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="DoWhileStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_2->s1_4; | ||
s1_3->s1_4->final; | ||
} | ||
*/ |
21 changes: 21 additions & 0 deletions
21
tests/fixtures/code-path-analysis/assignment--do-while-or.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_2->s1_2; | ||
s1_3->s1_4->final; | ||
*/ | ||
do { | ||
foo(); | ||
} while (a ||= b); | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nDoWhileStatement:enter"]; | ||
s1_2[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit\nAssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="DoWhileStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_2->s1_2; | ||
s1_3->s1_4->final; | ||
} | ||
*/ |
23 changes: 23 additions & 0 deletions
23
tests/fixtures/code-path-analysis/assignment--do-while-qq.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_2->s1_2; | ||
s1_3->s1_4; | ||
s1_2->s1_4->final; | ||
*/ | ||
do { | ||
foo(); | ||
} while (a ??= b); | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nDoWhileStatement:enter"]; | ||
s1_2[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit\nAssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="DoWhileStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_2->s1_2; | ||
s1_3->s1_4; | ||
s1_2->s1_4->final; | ||
} | ||
*/ |
23 changes: 23 additions & 0 deletions
23
tests/fixtures/code-path-analysis/assignment--for-and-1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_2->s1_6; | ||
s1_3->s1_6->final; | ||
*/ | ||
for (init; a &&= b; update) { | ||
foo(); | ||
} | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nForStatement:enter\nIdentifier (init)"]; | ||
s1_2[label="AssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_5[label="Identifier (update)"]; | ||
s1_6[label="ForStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_2->s1_6; | ||
s1_3->s1_6->final; | ||
} | ||
*/ |
22 changes: 22 additions & 0 deletions
22
tests/fixtures/code-path-analysis/assignment--for-and-2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_2->s1_5; | ||
s1_3->s1_5->final; | ||
*/ | ||
for (init; a &&= b;) { | ||
foo(); | ||
} | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nForStatement:enter\nIdentifier (init)"]; | ||
s1_2[label="AssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_5[label="ForStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_2->s1_5; | ||
s1_3->s1_5->final; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_2->s1_4; | ||
s1_3->s1_6->final; | ||
*/ | ||
for (init; a ||= b; update) { | ||
foo(); | ||
} | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nForStatement:enter\nIdentifier (init)"]; | ||
s1_2[label="AssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_5[label="Identifier (update)"]; | ||
s1_6[label="ForStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_2->s1_4; | ||
s1_3->s1_6->final; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_2->s1_4; | ||
s1_3->s1_5->final; | ||
*/ | ||
for (init; a ||= b;) { | ||
foo(); | ||
} | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nForStatement:enter\nIdentifier (init)"]; | ||
s1_2[label="AssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_5[label="ForStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_2->s1_4; | ||
s1_3->s1_5->final; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_2->s1_4; | ||
s1_3->s1_6; | ||
s1_2->s1_6->final; | ||
*/ | ||
for (init; a ??= b; update) { | ||
foo(); | ||
} | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nForStatement:enter\nIdentifier (init)"]; | ||
s1_2[label="AssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_5[label="Identifier (update)"]; | ||
s1_6[label="ForStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_2->s1_4; | ||
s1_3->s1_6; | ||
s1_2->s1_6->final; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_2->s1_4; | ||
s1_3->s1_5; | ||
s1_2->s1_5->final; | ||
*/ | ||
for (init; a ??= b;) { | ||
foo(); | ||
} | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nForStatement:enter\nIdentifier (init)"]; | ||
s1_2[label="AssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_3[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_4[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_5[label="ForStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_2->s1_4; | ||
s1_3->s1_5; | ||
s1_2->s1_5->final; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_4; | ||
s1_1->s1_4; | ||
s1_2->s1_4->final; | ||
*/ | ||
if (a &&= b) { | ||
foo(); | ||
} | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nIfStatement:enter\nAssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_2[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_3[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_4[label="IfStatement:exit\nProgram:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_4; | ||
s1_1->s1_4; | ||
s1_2->s1_4->final; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_5; | ||
s1_1->s1_4->s1_5; | ||
s1_2->s1_4; | ||
s1_5->final; | ||
*/ | ||
if (a &&= b) { | ||
foo(); | ||
} else { | ||
bar(); | ||
} | ||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nIfStatement:enter\nAssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_2[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_3[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (foo)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_5[label="IfStatement:exit\nProgram:exit"]; | ||
s1_4[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (bar)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_5; | ||
s1_1->s1_4->s1_5; | ||
s1_2->s1_4; | ||
s1_5->final; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*expected | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_7->s1_9; | ||
s1_1->s1_8->s1_9; | ||
s1_2->s1_8; | ||
s1_3->s1_8; | ||
s1_4->s1_6->s1_7; | ||
s1_9->final; | ||
*/ | ||
if ((a &&= b) && c) { | ||
d ? foo() : bar(); | ||
} else { | ||
baz(); | ||
} | ||
|
||
|
||
/*DOT | ||
digraph { | ||
node[shape=box,style="rounded,filled",fillcolor=white]; | ||
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; | ||
s1_1[label="Program:enter\nIfStatement:enter\nLogicalExpression:enter\nAssignmentExpression:enter\nIdentifier (a)"]; | ||
s1_2[label="Identifier (b)\nAssignmentExpression:exit"]; | ||
s1_3[label="Identifier (c)\nLogicalExpression:exit"]; | ||
s1_4[label="BlockStatement:enter\nExpressionStatement:enter\nConditionalExpression:enter\nIdentifier (d)"]; | ||
s1_5[label="CallExpression:enter\nIdentifier (foo)\nCallExpression:exit"]; | ||
s1_7[label="ConditionalExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_9[label="IfStatement:exit\nProgram:exit"]; | ||
s1_8[label="BlockStatement:enter\nExpressionStatement:enter\nCallExpression:enter\nIdentifier (baz)\nCallExpression:exit\nExpressionStatement:exit\nBlockStatement:exit"]; | ||
s1_6[label="CallExpression:enter\nIdentifier (bar)\nCallExpression:exit"]; | ||
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_7->s1_9; | ||
s1_1->s1_8->s1_9; | ||
s1_2->s1_8; | ||
s1_3->s1_8; | ||
s1_4->s1_6->s1_7; | ||
s1_9->final; | ||
} | ||
*/ |
Oops, something went wrong.