Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nullability] Fix a crash when calling builtin functions.
Despite its name, the result type of `BuiltinFnToFnPtr` cast is a function, not a function pointer. This means that the callee of a `CallExpr` to a builtin function is not a pointer and so does not have nullability information associated with it. We therefore crashed when trying to access this nullability information. We fix this by only checking for nullability if we have an indirect callee. Direct callees are always non-null, and it isn't possible to take the address of a builtin function, so calls to builtin functions are always direct. We also fix the implementation of the `BuiltinFnToFnPtr` cast so that it doesn't prepend an additional `NullabilityKind::NonNull`. The implementation of the `BuiltinFnToFnPtr` cast in the dataflow framework will also need to be changed, as it currently creates a pointer. However, the current fix will prevent the crash even before the dataflow framework is changed because the nullability checker will now never attempt to query the value associated with the callee to a builtin function. PiperOrigin-RevId: 543360562
- Loading branch information