Skip to content
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

Fix #12992 (Refactoring: Use l-value reference specifier for assignment operators to prevent misuse) #6665

Merged
merged 2 commits into from
Aug 7, 2024
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
3 changes: 2 additions & 1 deletion cppcheckpremium-suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ normalCheckLevelMaxBranches
# Cert C++
###########################################################################################################################

# False positives for (a?b:c)&=true;
premium-cert-exp35-c
# False positives for initializations
premium-cert-exp45-c
# False positives when casting to uintptr
Expand Down Expand Up @@ -68,7 +70,6 @@ premium-misra-cpp-2023-13.1.2
premium-misra-cpp-2023-13.3.1
premium-misra-cpp-2023-13.3.2
premium-misra-cpp-2023-13.3.3
premium-misra-cpp-2023-15.0.2
premium-misra-cpp-2023-15.1.2
premium-misra-cpp-2023-15.1.3
premium-misra-cpp-2023-18.1.1
Expand Down
2 changes: 1 addition & 1 deletion lib/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct Analyzer {

Action() = default;
Action(const Action&) = default;
Action& operator=(const Action& rhs) = default;
Action& operator=(const Action& rhs) & = default;

template<class T,
REQUIRES("T must be convertible to unsigned int", std::is_convertible<T, unsigned int> ),
Expand Down
2 changes: 1 addition & 1 deletion lib/importproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CPPCHECKLIB WARN_UNUSED ImportProject {
ImportProject() = default;
virtual ~ImportProject() = default;
ImportProject(const ImportProject&) = default;
ImportProject& operator=(const ImportProject&) = default;
ImportProject& operator=(const ImportProject&) & = default;

void selectOneVsConfig(Platform::Type platform);
void selectVsConfigurations(Platform::Type platform, const std::vector<std::string> &configurations);
Expand Down
2 changes: 1 addition & 1 deletion lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Library::Library(const Library& other)
: mData(new LibraryData(*other.mData))
{}

Library& Library::operator=(const Library& other)
Library& Library::operator=(const Library& other) &
{
mData.reset(new LibraryData(*other.mData));
return *this;
Expand Down
2 changes: 1 addition & 1 deletion lib/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CPPCHECKLIB Library {
~Library();

Library(const Library& other);
Library& operator=(const Library& other);
Library& operator=(const Library& other) &;

enum class ErrorCode : std::uint8_t {
OK,
Expand Down
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ Variable::~Variable()
delete mValueType;
}

Variable& Variable::operator=(const Variable &var)
Variable& Variable::operator=(const Variable &var) &
{
if (this == &var)
return *this;
Expand Down
2 changes: 1 addition & 1 deletion lib/symboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class CPPCHECKLIB Variable {

~Variable();

Variable &operator=(const Variable &var);
Variable &operator=(const Variable &var) &;

/**
* Get name token.
Expand Down
2 changes: 1 addition & 1 deletion lib/valueptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CPPCHECKLIB ValuePtr {
swap(mClone, rhs.mClone);
}

ValuePtr<T>& operator=(ValuePtr rhs) {
ValuePtr<T>& operator=(ValuePtr rhs) & {
swap(rhs);
return *this;
}
Expand Down
Loading