Skip to content

C#: Fix CFG for unknown expressions #11

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

Merged
merged 2 commits into from
Sep 10, 2018

Conversation

calumgrant
Copy link
Contributor

  1. Fix the CFG for unknown expressions, which were previously excluded from the control flow graph, which could lead to an incomplete graph.
  2. Add a test for this change, and also test the extraction of initializer-lists with unknown expressions. This test will currently fail on this branch as it tests extractor changes.

@calumgrant calumgrant added the C# label Aug 3, 2018
@calumgrant calumgrant self-assigned this Aug 3, 2018
@calumgrant calumgrant requested a review from hvitved August 3, 2018 15:26
@calumgrant calumgrant force-pushed the cs/standalone-cfg-fixes branch from 8e311a2 to 3658185 Compare August 13, 2018 10:58
@calumgrant calumgrant requested a review from a team as a code owner August 13, 2018 10:58
* Returns the `i`th child of an expression, with
* children ranked from 0.
*/
private ControlFlowElement getRankedExprChild(Expr e, int i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the name to getUnknownExprChild to match the other helper predicates, and perhaps remove the QL doc.

* Returns the `i`th child of an expression, with
* children ranked from 0.
*/
private ControlFlowElement getRankedExprChild(Expr e, int i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change Expr e to @unknown_expr, otherwise we will be computing the relation for all expressions, rather than just the unknown expressions.

* have a valid `toString()`.
*/
class UnknownCall extends MethodCall
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move brace up.

@@ -0,0 +1,18 @@
import csharp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a

/**
 * @kind graph
 * @id cfg
 */

header; then we will be able to see the visualized graph in the IDE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed again, sorry.

@calumgrant calumgrant force-pushed the cs/standalone-cfg-fixes branch 3 times, most recently from 4c5436e to ff44772 Compare August 23, 2018 11:27
@hvitved
Copy link
Contributor

hvitved commented Sep 7, 2018

@calumgrant : Should this go into 1.18?

@calumgrant
Copy link
Contributor Author

It should be in sync with the corresponding changes in Semmle/code (https://git.semmle.com/Semmle/code/pull/26692), so yes. I'll rebase, but it will conflict with #163.

@calumgrant calumgrant force-pushed the cs/standalone-cfg-fixes branch from ff44772 to ecb3efb Compare September 7, 2018 17:12
@calumgrant calumgrant requested a review from a team as a code owner September 7, 2018 17:12
@calumgrant calumgrant changed the base branch from master to rc/1.18 September 7, 2018 17:14
@hvitved hvitved removed the request for review from a team September 10, 2018 07:39
@hvitved hvitved added this to the 1.18 milestone Sep 10, 2018
@felicitymay
Copy link
Contributor

felicitymay commented Sep 10, 2018

Does this need a change note, or doesn't the change affect existing users?

@hvitved hvitved merged commit 621d845 into github:rc/1.18 Sep 10, 2018
aibaars pushed a commit that referenced this pull request Oct 14, 2021
smowton pushed a commit to smowton/codeql that referenced this pull request Oct 28, 2021
Java/Kotlin: Enhance 'compilations' support
erik-krogh referenced this pull request in erik-krogh/ql Dec 15, 2021
Trying to get a green bar
erik-krogh referenced this pull request in erik-krogh/ql Dec 15, 2021
dbartol pushed a commit that referenced this pull request Dec 18, 2024
feat(composite-actions): Fix summary and source queries for composite actions analysis
nicolaswill added a commit that referenced this pull request May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants