Skip to content

Swift: add CFG and PrintAst consistency queries, enabling them in CI #13270

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

Closed
wants to merge 8 commits into from

Conversation

redsun82
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the Swift label May 24, 2023
@@ -0,0 +1 @@
import codeql.swift.printast.Consistency
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should not include these queries in the codeql/swift-queries pack. They are not meant for users. Other languages seem to store them in separate packs LANG/ql/consistency-queries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

redsun82 added 7 commits May 24, 2023 13:11
Previously there was code that was treating `BraceStmt` within `TapExpr`
in a special way, skipping the first variable declaration element which
was purposedly visited first in the `TapExpr` itself.

This might have introduced CFG inconsistencies, and here this is
switched to a simpler setup where the tap expression variable
declaration is visited in the body as is normal for `BraceStmt`.
@redsun82
Copy link
Contributor Author

I discussed a plan with @MathiasVP:

  • we don't need to fix these inconsistencies for the release, but we should check our latest PRs did not introduce any new inconsistencies
  • we should turn on this CI check with all expected results on main (I'll finish this tomorrow)
  • we should open issues to fix these inconsistencies

The current status of this PR is highly incomplete, also the fix to the property wrapper double needs to be revisited, as it turns out the initializer is not always shared between a var decl and its synthesized property wrapper backing binding.

@@ -969,6 +959,9 @@ module Decls {
result.asAstNode() = ast.getPattern(j).getFullyUnresolved()
)
or
// PropertyWrapperBackingVarBinding is a special case as it shares the init
// with the original variable binding (see also PrintAstNode.qll)
ast != any(VarDecl d).getPropertyWrapperBackingVarBinding() and
Copy link
Contributor

Choose a reason for hiding this comment

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

As we discussed in our sync. See https://codeql.github.com/docs/ql-language-reference/formulas/#equality.

Suggested change
ast != any(VarDecl d).getPropertyWrapperBackingVarBinding() and
not ast = any(VarDecl d).getPropertyWrapperBackingVarBinding() and

@redsun82 redsun82 closed this May 25, 2023
@redsun82 redsun82 deleted the redsun82/swift-consistency branch November 16, 2023 11:58
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