[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 3 18:31:10 PST 2023


https://github.com/Xazax-hun approved this pull request.

Overall, I love it! I have some comments on some features in the future, but those are probably not going to be addressed any time soon. First of all, I think in the future when we reason about the values of the pointers, synthetic fields might need to have offsets to be able to know things like `&modeled.getField1() != &modeled.getField2()`. Offsets might also be a way to support unions, multiple synthetic fields starting at the same offset might express just that.

Another big item is properly supporting inheritance. Consider:
```
struct B { int a; };
struct D : /*virtual*/ B {};
struct E : /*virtual*/  B {};
struct F: D, E {
    void m() {
        int* l = &(D::a);
        int* m = &(E::a);
    }
};

``` 

Here, whether we have the same or different memory locations for `D::a` and `E::a` depends on whether we are doing virtual inheritance. This is something that should work both for regular fields and synthetic fields.

https://github.com/llvm/llvm-project/pull/73860


More information about the cfe-commits mailing list