Fix go/impossible-interface-nil-check for separate post-update nodes

When tracing back from nil checks on interfaces, ignore post-update
nodes. There will always be a corresponding pre-update node that
contains the information we want.
This commit is contained in:
Owen Mansel-Chan
2025-10-02 12:34:58 +01:00
parent 2629369c93
commit 7fdda87b06

View File

@@ -35,7 +35,9 @@ predicate flowsToInterfaceNilCheck(DataFlow::Node nd) {
*/
predicate nonNilWrapper(DataFlow::Node nd) {
flowsToInterfaceNilCheck(nd) and
forex(DataFlow::Node pred | pred = nd.getAPredecessor() |
forex(DataFlow::Node pred |
pred = nd.getAPredecessor() and not pred instanceof DataFlow::PostUpdateNode
|
exists(Type predtp | predtp = pred.getType().getUnderlyingType() |
not predtp instanceof InterfaceType and
not predtp instanceof NilLiteralType and