Fraunhofer-AISEC / cpg

A library to extract Code Property Graphs from C/C++, Java, Go, Python, Ruby and every other language through LLVM-IR.
https://fraunhofer-aisec.github.io/cpg/
Apache License 2.0
248 stars 60 forks source link

Improved stability of `isDerivedFrom` decisions #1488

Closed oxisto closed 1 month ago

oxisto commented 2 months ago

This PR adds the way Type.isDerivedFrom works. More concretly, we are once again taking the "wrap state" of the type into account. This means that pointer types and non-pointer types will not match even though their root types derive from each other. This was the way this function behaved in the past and it seems this was changed at some point.

This behaviour seems to be less-error prone because it led to some weird over-approximations in call resolving, basically ignoring wether a type was a pointer or not. To replicate the behaviour previous to the PR, you can use type.root.isDerivedFrom(other.root), if you really want to just match the root types.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
92.6% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud