Skip to content

C++: Do not alert on unreachable code in cpp/incorrect-string-type-conversion #20014

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 4 commits into from
Jul 11, 2025

Conversation

jketema
Copy link
Contributor

@jketema jketema commented Jul 10, 2025

No description provided.

@github-actions github-actions bot added the C++ label Jul 10, 2025
not isLikelyDynamicallyChecked(e1)
not isLikelyDynamicallyChecked(e1) and
// Avoid cases in unreachable blocks.
any(EnterFunctionInstruction e).getASuccessor+().getAst() = e1
Copy link
Contributor

Choose a reason for hiding this comment

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

I imagine this transitive closure is sufficiently constrained so that this doesn't matter much, but in case DCA comes back with a performance problem it may be worth doing getASuccessor+() on basic blocks instead of individual instructions since that's much much more efficient (simply because there are a lot fewer basic blocks than there are instructions).

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 didn't see any performance problems, but out of curiosity, how would I rewrite the code in that case?

  any(EnterFunctionInstruction e).getBlock().getASuccessor+() =
    any(Instruction i | i.getAst() = e1).getBlock()

Or is there any easier way?

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like that, yeah. Probably with * instead of + to handle the case where e1 is in the same block as the entry point of the function.

@jketema jketema marked this pull request as ready for review July 10, 2025 13:13
@jketema jketema requested a review from a team as a code owner July 10, 2025 13:13
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!

@MathiasVP MathiasVP merged commit 649c883 into github:main Jul 11, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy