C#: Represent all expressions in post-order in the CFG#4646
Conversation
9cc2cb7 to
967a834
Compare
967a834 to
94deed3
Compare
| @@ -35,7 +35,23 @@ class ConstantBooleanCondition extends ConstantCondition { | |||
|
|
|||
| override predicate isWhiteListed() { | |||
There was a problem hiding this comment.
Why do we need white listing of some constant conditions?
Also, we might want to change the name of the predicate to something more inclusive.
There was a problem hiding this comment.
For example, if x is constantly false, then we do not also want to report that x && y is constantly false.
| ) | ||
| // Operand exits abnormally | ||
| result = cfe.(LogicalNotExpr).getOperand() and | ||
| c = TRec(TLastRecAbnormalCompletion()) |
There was a problem hiding this comment.
Why do we need to list this many cases for the abnormal completion? Isn't it the case that any child (of tyoe Expr) can exit abnormally?
There was a problem hiding this comment.
This should be better in an upcoming refactoring.
| result = this.(JumpStmt).getChild(0) or | ||
| result = this.(ThrowExpr).getExpr() or | ||
| result = getObjectCreationArgument(this, 0) | ||
| result = this.(StandardExpr).getFirstChildElement() |
There was a problem hiding this comment.
I had the feeling so far that we're building the child/parent relationships in the AST in the order of execution. Why do we need to handle individually these types?
Also, JumpStmt feels odd to be mixed with expressions.
There was a problem hiding this comment.
Again, should be better in the follow-up refactoring.
This PR changes the CFG construction for expressions so they are all visited in post order. The motivation for doing this is consistency, as well as to eliminate false positives (see https://github.com/github/codeql-csharp-team/issues/87).
https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/618/ (excluding last commit).
https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/621/ (including last commit).
Example 1
Before
After
Example 2
Before
After