-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C#: Remove assembly prefixes from TRAP labels #4017
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
Conversation
76bad19 to
873061e
Compare
f553d41 to
9fe12f5
Compare
2531682 to
7b50815
Compare
c199d4e to
7b9d295
Compare
…rwise, an entity with the wrong (cached) nullability could be created.
…er imports into alphabetical order.
…e` needed to be the same as `objectEntityCache` to fix nullability warnings.
…ble implementations Previosly, we returned only the body belonging to "the most likely" implementation, based on a CFG size heuristics. However, now that more callables are mapped to the same entity, it makes more sense to treat such callables (to some extent) like partial methods. This means, for instance, that data flow will branch out to all possible implementations, much like we do for virtual dispatch.
51243f1 to
701e189
Compare
|
Rebased to resolve merge conflict in the change notes. |
|
Here is the new CSharp-Differences job: https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/408/. I will update the PR description to link to this as soon as it completes. |
Done. |
calumgrant
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this. Looks good!
|
OK, lets get it in 🤞 |
This PR is based on @calumgrant 's #3350 (only the last five commits are new), and takes the approach one step further by totally removing assembly prefixes. Removing assembly prefixes means we have to perform extra disambiguation when constructing labels, to avoid DB inconsistencies. However, I strongly believe that this extra logic is worthwhile the effort, as identical identities belonging to different assemblies will no longer result in two entities.
Even though only the last five commits are new, it probably makes more sense to review this PR in its entirety.
TRAP ID changes
<>f__AnonymousType0are not characterized as anonymous types by Roslyn, but we still need to handle them as such for disambiguation.Other extractor changes
object;objectis added back in QL when needed.BuildTypeIdhas been simplified as it no longer takes anAction<Context, TextWriter, ITypeSymbol> subTermActionargument; instead we always call the newly introducedBuildOrWriteIdin the recursive cases, which makes sure to avoid cyclic labels.CreateEntityandCreateEntityFromSymbol. The former requires an explicit cache key while the latter caches based on theISymbolused to initialize the entity.--assemblysensitivetraponto the extractor invocation, but this is now opt-in.Control flow graph changes
Previously, methods with multiple implementations had "the most likely" implementation chosen, based on counting CFG nodes. So for instance if
and
were both compiled to the same assembly, then the implementation from
A.cswas chosen as the body ofC1.M. Now, however, even ifA.csandB.csare compiled to different assemblies, there will still be only oneC1.Mmethod in the database. Since this appears to be much more common, I decided to completely abandon the "most likely implementation" heuristics, and instead treat both0andthrow nullas possible bodies ofC1.M. In some sense this also fits better with how we deal with virtual dispatch where all viable dispatch targets are visited; here dispatch happens at linking-time, though. This means that the CFG forC1.Mnow looks like:Performance
CSharp-Differences job
herehere.