Skip to content
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

Trim analyzer: Implement intrinsics handling of object.GetType #93732

Merged
merged 4 commits into from
Nov 1, 2023

Commits on Oct 19, 2023

  1. Trim analyzer: Implement intrinsics handling of object.GetType

    This fixes dotnet#86921.
    
    Analyzer so far didn't handle correct data flow around `object.GetType` and `DynamicallyAccessedMembersAttribute` on types. This change implements that behavior.
    
    Main changes:
    * Move `IValueWithStaticType` to the shared code and refactor its existing usage in trimmer/AOT to use the shared code instead. Also implement it for the analyzer.
    * Refactor method call handling in the analyzer to a single static method which is called both from the visitor and from the patterns.
    * In order to get same behavior, start tracking values for all fields and method parameters.
    
    Outside of the actual fix, the other main change is that analyzer now tracks values for all fields and method parameters, regardless if their type is interesting to analysis. This is necessary because the static type now matterns, even if it's something else than `System.Type`.
    
    The effect of that is that the analyzer now recognizes lot more invalid cases because it can determine if the value is something unrecognizable. Before the change such values where tracked as "empty", and thus anslysis ignored them. Now they're track as "value of a field, without annotations" which can lead to producing more warnings.
    
    That means this effectively fixes dotnet/linker#2755. At least all the test cases which were added because of that bug, or which expected different behavior because of it now produce consistent behavior with trimmer/NativeAOT.
    vitek-karas committed Oct 19, 2023
    Configuration menu
    Copy the full SHA
    70975fc View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2023

  1. Revert unnecessary change to how empty values are handled

    This leaves 2 test cases where the analyzer doesn't detect a warning, but they are relative corner cases.
    vitek-karas committed Oct 27, 2023
    Configuration menu
    Copy the full SHA
    aed9966 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2afdc16 View commit details
    Browse the repository at this point in the history
  3. Fix tabs

    vitek-karas committed Oct 27, 2023
    Configuration menu
    Copy the full SHA
    a075d97 View commit details
    Browse the repository at this point in the history