HomePhabricator

[analyzer] Improve VirtualCallChecker and enable parts of it by default.

Description

[analyzer] Improve VirtualCallChecker and enable parts of it by default.

Calling a pure virtual method during construction or destruction
is undefined behavior. It's worth it to warn about it by default.
That part is now known as the cplusplus.PureVirtualCall checker.

Calling a normal virtual method during construction or destruction
may be fine, but does behave unexpectedly, as it skips virtual dispatch.
Do not warn about this by default, but let projects opt in into it
by enabling the optin.cplusplus.VirtualCall checker manually.

Give the two parts differentiated warning text:

Before:

  Call to virtual function during construction or destruction:
  Call to pure virtual function during construction

  Call to virtual function during construction or destruction:
  Call to virtual function during destruction

After:

  Pure virtual method call:
  Call to pure virtual method 'X::foo' during construction
      has undefined behavior

  Unexpected loss of virtual dispatch:
  Call to virtual method 'Y::bar' during construction
      bypasses virtual dispatch

Also fix checker names in consumers that support them (eg., clang-tidy)
because we now have different checker names for pure virtual calls and
regular virtual calls.

Also fix capitalization in the bug category.

Differential Revision: https://reviews.llvm.org/D64274

Details