Skip to content

[analyzer] Remove deprecated option VirtualCall:PureOnly #131823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@ Crash and bug fixes
Improvements
^^^^^^^^^^^^

- The checker option ``optin.cplusplus.VirtualCall:PureOnly`` was removed,
because it had been deprecated since 2019 and it is completely useless (it
was kept only for compatibility with pre-2019 versions, setting it to true is
equivalent to completely disabling the checker).

Moved checkers
^^^^^^^^^^^^^^

Expand Down
26 changes: 8 additions & 18 deletions clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
Original file line number Diff line number Diff line change
Expand Up @@ -750,24 +750,14 @@ def UninitializedObjectChecker: Checker<"UninitializedObject">,
]>,
Documentation<HasDocumentation>;

def VirtualCallChecker : Checker<"VirtualCall">,
HelpText<"Check virtual function calls during construction/destruction">,
CheckerOptions<[
CmdLineOption<Boolean,
"ShowFixIts",
"Enable fix-it hints for this checker",
"false",
InAlpha>,
CmdLineOption<Boolean,
"PureOnly",
"Disables the checker. Keeps cplusplus.PureVirtualCall "
"enabled. This option is only provided for backwards "
"compatibility.",
"false",
InAlpha>
]>,
Dependencies<[VirtualCallModeling]>,
Documentation<HasDocumentation>;
def VirtualCallChecker
: Checker<"VirtualCall">,
HelpText<"Check virtual function calls during construction/destruction">,
CheckerOptions<[CmdLineOption<Boolean, "ShowFixIts",
"Enable fix-it hints for this checker",
"false", InAlpha>]>,
Dependencies<[VirtualCallModeling]>,
Documentation<HasDocumentation>;

} // end: "optin.cplusplus"

Expand Down
13 changes: 5 additions & 8 deletions clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,11 @@ void ento::registerPureVirtualCallChecker(CheckerManager &Mgr) {

void ento::registerVirtualCallChecker(CheckerManager &Mgr) {
auto *Chk = Mgr.getChecker<VirtualCallChecker>();
if (!Mgr.getAnalyzerOptions().getCheckerBooleanOption(
Mgr.getCurrentCheckerName(), "PureOnly")) {
Chk->BT_Impure = std::make_unique<BugType>(
Mgr.getCurrentCheckerName(), "Unexpected loss of virtual dispatch",
categories::CXXObjectLifecycle);
Chk->ShowFixIts = Mgr.getAnalyzerOptions().getCheckerBooleanOption(
Mgr.getCurrentCheckerName(), "ShowFixIts");
}
Chk->BT_Impure = std::make_unique<BugType>(
Mgr.getCurrentCheckerName(), "Unexpected loss of virtual dispatch",
categories::CXXObjectLifecycle);
Chk->ShowFixIts = Mgr.getAnalyzerOptions().getCheckerBooleanOption(
Mgr.getCurrentCheckerName(), "ShowFixIts");
}

bool ento::shouldRegisterVirtualCallModeling(const CheckerManager &mgr) {
Expand Down
1 change: 0 additions & 1 deletion clang/test/Analysis/analyzer-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
// CHECK-NEXT: optin.cplusplus.UninitializedObject:IgnoreRecordsWithField = ""
// CHECK-NEXT: optin.cplusplus.UninitializedObject:NotesAsWarnings = false
// CHECK-NEXT: optin.cplusplus.UninitializedObject:Pedantic = false
// CHECK-NEXT: optin.cplusplus.VirtualCall:PureOnly = false
// CHECK-NEXT: optin.cplusplus.VirtualCall:ShowFixIts = false
// CHECK-NEXT: optin.osx.cocoa.localizability.NonLocalizedStringChecker:AggressiveReport = false
// CHECK-NEXT: optin.performance.Padding:AllowedPad = 24
Expand Down
18 changes: 0 additions & 18 deletions clang/test/Analysis/virtualcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,11 @@
// RUN: -analyzer-checker=debug.ExprInspection \
// RUN: -std=c++11 -verify=pure -std=c++11 %s

// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.VirtualCall \
// RUN: -analyzer-config \
// RUN: optin.cplusplus.VirtualCall:PureOnly=true \
// RUN: -analyzer-checker=debug.ExprInspection \
// RUN: -std=c++11 -verify=none %s

// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.PureVirtualCall \
// RUN: -analyzer-checker=optin.cplusplus.VirtualCall \
// RUN: -analyzer-checker=debug.ExprInspection \
// RUN: -std=c++11 -verify=pure,impure -std=c++11 %s

// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.PureVirtualCall \
// RUN: -analyzer-checker=optin.cplusplus.VirtualCall \
// RUN: -analyzer-config \
// RUN: optin.cplusplus.VirtualCall:PureOnly=true \
// RUN: -analyzer-checker=debug.ExprInspection \
// RUN: -std=c++11 -verify=pure %s


// We expect no diagnostics when all checks are disabled.
// none-no-diagnostics


#include "virtualcall.h"

void clang_analyzer_warnIfReached();
Expand Down