Closed Bug 1536719 Opened 8 months ago Closed 8 months ago

Fix handling of member calls on operator calls in static analysis


(Firefox Build System :: Source Code Analysis, defect)

Not set


(firefox68 fixed)

Tracking Status
firefox68 --- fixed


(Reporter: bzbarsky, Assigned: bzbarsky)




(1 file)

The patch description will explain what's going on and why the patch fixes it, but the short story is that this will fix the FIXME at

Assignee: nobody → bzbarsky
Depends on: 1536336

The old code for member method calls did the following:

  1. Find the member method calls.
  2. Look at their "this" expression.
  3. If the "this" is an operator call, check for any of the arguments of the
    operator call being invalid.
  4. Otherwise (if not an operator call) check for the "this" value being

This wasn't right, because the "is invalid" check checks the type and only
considers refcounted things. So if the code looked something like
"foo[i]->call_method()", we would look at the types of "foo" and "i" and
determine that none of those are refcounted types so there is nothing invalid
here (since "foo" is some sort of array type and "i" is an integer). The new
setup just checks whether the "this" value is invalid, which does the type
check on the "this" value itself; in the "foo[i]->call_method()" case on
"foo[i]". We then adjust the exclusions in InvalidArg to consider operator->
on known-live things valid, to allow the thing that we were really trying to
accomplish with the "check for an operator call" bits:

The test coverage being added for the made-up TArray type is meant to catch
things like the geolocation issue that was being hidden by the buggy behavior.
I'm not using nsTArray itself because some header included by nsTArray.h
tries to define operator new/delete bits inline and that triggers warnings that
then cause a clang-plugin test failure, because they're unexpected.

Blocks: 1536724
Pushed by
Fix handling of member method calls in the MOZ_CAN_RUN_SCRIPT analysis.  r=andi
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.