-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C#: Instantiate shared Guards and shared ControlFlowReachability and replace nullness #20558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aschackmull
wants to merge
14
commits into
github:main
Choose a base branch
from
aschackmull:csharp/guards3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+6,979
−14,283
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
64caae5
Guards: Refactor representation of false.
aschackmull ca7d560
ControlFlow: Rename getAPhiInput to getAnInput.
aschackmull c01ac30
Guards: Disregard more trivial guards.
aschackmull b52a9a8
C#: Instantiate shared Guards.
aschackmull 449059f
C#: Disable FinallySplit, BooleanSplit, and LoopSplit
aschackmull c2d21e9
C#: Instantiate ControlFlowReachability and implement new nullness.
aschackmull 6cfadbf
C#: Clean up.
aschackmull 587901b
C#: Replace NullMaybe.ql implementation.
aschackmull 64810f6
C#: Improve ConstantCondition.ql
aschackmull df6172b
C#: Update nullness qltest
aschackmull b392767
C#: Accept qltest changes.
aschackmull 613c789
C#: Remove some obsolete tests.
aschackmull fad49ff
C++: Accept qltest change (useless guard tautology removed).
aschackmull 84a65be
C#: Add change note.
aschackmull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,4 @@ | ||
--- | ||
category: majorAnalysis | ||
--- | ||
* The representation of the C# control-flow graph has been significantly changed. This has minor effects on a wide range of queries including both minor improvements and minor regressions, for example, improved precision has been observed for `cs/inefficient-containskey` and `cs/stringbuilder-creation-in-loop`. Two queries stand out as being significantly affected with great improvements: `cs/dereferenced-value-may-be-null` has been completely rewritten which removes a very significant number of false positives. Furthermore, `cs/constant-condition` has been updated to report many new results - these new results are primarily expected to be true positives, but a few new false positives are expected as well. As part of these changes, `cs/dereferenced-value-may-be-null` has been changed from a `path-problem` query to a `problem` query, so paths are no longer reported for this query. |
This file contains hidden or 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 hidden or 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
57 changes: 57 additions & 0 deletions
57
csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowReachability.qll
This file contains hidden or 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,57 @@ | ||
/** | ||
* Provides an implementation of local (intraprocedural) control flow reachability. | ||
*/ | ||
|
||
import csharp | ||
private import codeql.controlflow.ControlFlow | ||
private import semmle.code.csharp.controlflow.BasicBlocks | ||
private import semmle.code.csharp.controlflow.Guards as Guards | ||
private import semmle.code.csharp.ExprOrStmtParent | ||
|
||
private module ControlFlowInput implements | ||
InputSig<Location, ControlFlow::Node, ControlFlow::BasicBlock> | ||
{ | ||
private import csharp as CS | ||
|
||
AstNode getEnclosingAstNode(ControlFlow::Node node) { | ||
node.getAstNode() = result | ||
or | ||
not exists(node.getAstNode()) and result = node.getEnclosingCallable() | ||
} | ||
|
||
class AstNode = ExprOrStmtParent; | ||
|
||
AstNode getParent(AstNode node) { result = node.getParent() } | ||
|
||
class FinallyBlock extends AstNode { | ||
FinallyBlock() { any(TryStmt try).getFinally() = this } | ||
} | ||
|
||
class Expr = CS::Expr; | ||
|
||
class SourceVariable = Ssa::SourceVariable; | ||
|
||
class SsaDefinition = Ssa::Definition; | ||
|
||
class SsaWriteDefinition extends SsaDefinition instanceof Ssa::ExplicitDefinition { | ||
Expr getDefinition() { result = super.getADefinition().getSource() } | ||
} | ||
|
||
class SsaPhiNode = Ssa::PhiNode; | ||
|
||
class SsaUncertainDefinition = Ssa::UncertainDefinition; | ||
|
||
class GuardValue = Guards::GuardValue; | ||
|
||
predicate ssaControlsBranchEdge(SsaDefinition def, BasicBlock bb1, BasicBlock bb2, GuardValue v) { | ||
Guards::Guards::ssaControlsBranchEdge(def, bb1, bb2, v) | ||
} | ||
|
||
predicate ssaControls(SsaDefinition def, BasicBlock bb, GuardValue v) { | ||
Guards::Guards::ssaControls(def, bb, v) | ||
} | ||
|
||
import Guards::Guards::InternalUtil | ||
} | ||
|
||
module ControlFlowReachability = Make<Location, Cfg, ControlFlowInput>; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Names only differing by case Warning