Skip to content

Commit 03adb0e

Browse files
authored
[analyzer] Remove deprecated option VirtualCall:PureOnly (#131823)
VirtualCallChecker.cpp implements two related checkers: - `optin.cplusplus.VirtualCall` which reports situations when constructors or destructors call virtual methods (which is bugprone because it does not trigger virtual dispatch, but can be legitmate). - `cplusplus.PureVirtualCall` reports situations when constructors or destructors call _pure_ virtual methods, which is an error. Six years ago these two bug types were both reported by the same checker (called `optin.cplusplus.VirtualCall`) and it had an option called `PureOnly` which limited its output to the pure case. When (in 2019) the two checker parts were separated by the commit d3971fe, the option `PureOnly` was preserved for the sake of compatibility, but it is no longer useful (when it is set to true, it just suppresses all reports from `optin.cplusplus.VirtualCall`) so it was marked as deprecated. I'm removing this deprecated option now because it is no longer relevant and its presence caused minor complications when I was porting `VirtualCallChecker.cpp` to the new multipart checker framework (introduced in 2709998).
1 parent 5669161 commit 03adb0e

File tree

5 files changed

+18
-45
lines changed

5 files changed

+18
-45
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ Crash and bug fixes
491491
Improvements
492492
^^^^^^^^^^^^
493493

494+
- The checker option ``optin.cplusplus.VirtualCall:PureOnly`` was removed,
495+
because it had been deprecated since 2019 and it is completely useless (it
496+
was kept only for compatibility with pre-2019 versions, setting it to true is
497+
equivalent to completely disabling the checker).
498+
494499
Moved checkers
495500
^^^^^^^^^^^^^^
496501

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -750,24 +750,14 @@ def UninitializedObjectChecker: Checker<"UninitializedObject">,
750750
]>,
751751
Documentation<HasDocumentation>;
752752

753-
def VirtualCallChecker : Checker<"VirtualCall">,
754-
HelpText<"Check virtual function calls during construction/destruction">,
755-
CheckerOptions<[
756-
CmdLineOption<Boolean,
757-
"ShowFixIts",
758-
"Enable fix-it hints for this checker",
759-
"false",
760-
InAlpha>,
761-
CmdLineOption<Boolean,
762-
"PureOnly",
763-
"Disables the checker. Keeps cplusplus.PureVirtualCall "
764-
"enabled. This option is only provided for backwards "
765-
"compatibility.",
766-
"false",
767-
InAlpha>
768-
]>,
769-
Dependencies<[VirtualCallModeling]>,
770-
Documentation<HasDocumentation>;
753+
def VirtualCallChecker
754+
: Checker<"VirtualCall">,
755+
HelpText<"Check virtual function calls during construction/destruction">,
756+
CheckerOptions<[CmdLineOption<Boolean, "ShowFixIts",
757+
"Enable fix-it hints for this checker",
758+
"false", InAlpha>]>,
759+
Dependencies<[VirtualCallModeling]>,
760+
Documentation<HasDocumentation>;
771761

772762
} // end: "optin.cplusplus"
773763

clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,11 @@ void ento::registerPureVirtualCallChecker(CheckerManager &Mgr) {
214214

215215
void ento::registerVirtualCallChecker(CheckerManager &Mgr) {
216216
auto *Chk = Mgr.getChecker<VirtualCallChecker>();
217-
if (!Mgr.getAnalyzerOptions().getCheckerBooleanOption(
218-
Mgr.getCurrentCheckerName(), "PureOnly")) {
219-
Chk->BT_Impure = std::make_unique<BugType>(
220-
Mgr.getCurrentCheckerName(), "Unexpected loss of virtual dispatch",
221-
categories::CXXObjectLifecycle);
222-
Chk->ShowFixIts = Mgr.getAnalyzerOptions().getCheckerBooleanOption(
223-
Mgr.getCurrentCheckerName(), "ShowFixIts");
224-
}
217+
Chk->BT_Impure = std::make_unique<BugType>(
218+
Mgr.getCurrentCheckerName(), "Unexpected loss of virtual dispatch",
219+
categories::CXXObjectLifecycle);
220+
Chk->ShowFixIts = Mgr.getAnalyzerOptions().getCheckerBooleanOption(
221+
Mgr.getCurrentCheckerName(), "ShowFixIts");
225222
}
226223

227224
bool ento::shouldRegisterVirtualCallModeling(const CheckerManager &mgr) {

clang/test/Analysis/analyzer-config.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
// CHECK-NEXT: optin.cplusplus.UninitializedObject:IgnoreRecordsWithField = ""
109109
// CHECK-NEXT: optin.cplusplus.UninitializedObject:NotesAsWarnings = false
110110
// CHECK-NEXT: optin.cplusplus.UninitializedObject:Pedantic = false
111-
// CHECK-NEXT: optin.cplusplus.VirtualCall:PureOnly = false
112111
// CHECK-NEXT: optin.cplusplus.VirtualCall:ShowFixIts = false
113112
// CHECK-NEXT: optin.osx.cocoa.localizability.NonLocalizedStringChecker:AggressiveReport = false
114113
// CHECK-NEXT: optin.performance.Padding:AllowedPad = 24

clang/test/Analysis/virtualcall.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,11 @@
66
// RUN: -analyzer-checker=debug.ExprInspection \
77
// RUN: -std=c++11 -verify=pure -std=c++11 %s
88

9-
// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.VirtualCall \
10-
// RUN: -analyzer-config \
11-
// RUN: optin.cplusplus.VirtualCall:PureOnly=true \
12-
// RUN: -analyzer-checker=debug.ExprInspection \
13-
// RUN: -std=c++11 -verify=none %s
14-
159
// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.PureVirtualCall \
1610
// RUN: -analyzer-checker=optin.cplusplus.VirtualCall \
1711
// RUN: -analyzer-checker=debug.ExprInspection \
1812
// RUN: -std=c++11 -verify=pure,impure -std=c++11 %s
1913

20-
// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.PureVirtualCall \
21-
// RUN: -analyzer-checker=optin.cplusplus.VirtualCall \
22-
// RUN: -analyzer-config \
23-
// RUN: optin.cplusplus.VirtualCall:PureOnly=true \
24-
// RUN: -analyzer-checker=debug.ExprInspection \
25-
// RUN: -std=c++11 -verify=pure %s
26-
27-
28-
// We expect no diagnostics when all checks are disabled.
29-
// none-no-diagnostics
30-
31-
3214
#include "virtualcall.h"
3315

3416
void clang_analyzer_warnIfReached();

0 commit comments

Comments
 (0)