Skip to content

C++: Fix small PrintAST and PrintIR issue #18277

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 5 commits into from
Dec 12, 2024
Merged

Conversation

jketema
Copy link
Contributor

@jketema jketema commented Dec 12, 2024

  • PrintIR is currently doing the wrong thing for OverloadedArrayExpr add a test and fix
  • PrintIR currently does the wrong thing if a block has two outgoing edges to the same successor block. At present this is not an issue, but it will be once Brodes/seh flow phas3.1 add basic seh edges #18253 is merged. I tested this on top of that PR, but since merging that PR is somewhat blocked at present, I would like to get this in preemptively.

Pull Request checklist

All query authors

Internal query authors only

  • Autofixes generated based on these changes are valid, only needed if this PR makes significant changes to .ql, .qll, or .qhelp files. See the documentation (internal access required).
  • Changes are validated at scale (internal access required).
  • Adding a new query? Consider also adding the query to autofix.

@Copilot Copilot AI review requested due to automatic review settings December 12, 2024 12:54
@jketema jketema requested a review from a team as a code owner December 12, 2024 12:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again, by re-requesting a review.

@github-actions github-actions bot added the C++ label Dec 12, 2024
@jketema jketema added the no-change-note-required This PR does not need a change note label Dec 12, 2024
key = "semmle.label" and
exists(string kinds |
kinds =
concat(EdgeKind k |
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is changed to a strictcount you could remove line 428, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still need 428 to correctly bind succBlock in the other side of the or, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the key = "semmle.order" case? That's bound by getSuccessorIndex anyway. Although, I do see that you need to rewrite the exists slightly to get rid of the resulting cartesian product with kind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the key = "semmle.order" case? That's bound by getSuccessorIndex anyway.

Ah, you're right.

So are you thinking of something like:

query predicate edges(PrintableIRBlock pred, PrintableIRBlock succ, string key, string value) {
  exists(IRBlock predBlock, IRBlock succBlock |
    predBlock = pred.getBlock() and
    succBlock = succ.getBlock() and
    (
      key = "semmle.label" and
      exists(string kinds |
        kinds =
          strictconcat(EdgeKind k |
            predBlock.getSuccessor(k) = succBlock
          |
            k.toString(), "|" order by k.toString()
          )
      |
        if predBlock.getBackEdgeSuccessor(_) = succBlock
        then value = kinds + " (back edge)"
        else value = kinds
      )
      or
      key = "semmle.order" and
      value = getSuccessorIndex(predBlock, succBlock).toString()
    )
  )
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly 👍

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 in f9bfd96

Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

LGTM! The CI failures looks unrelated!

@jketema jketema merged commit 7925044 into github:main Dec 12, 2024
13 of 14 checks passed
@jketema jketema deleted the printast branch December 12, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants