Skip to content

Commit 11df5ae

Browse files
authored
Refactoring: Use NOEXCEPT for swap methods (danmar#6682)
Misra C++ 2023 rule 18.4.1: Exception-unfriendly functions shall be noexcept
1 parent c8cdd7a commit 11df5ae

File tree

5 files changed

+4
-7
lines changed

5 files changed

+4
-7
lines changed

cppcheckpremium-suppressions

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ premium-misra-cpp-2023-18.1.1
223223
# TODO do not throw token pointer?
224224
premium-misra-cpp-2023-18.3.2:lib/tokenize.cpp
225225

226-
# TODO use noexcept
227-
premium-misra-cpp-2023-18.4.1
228-
229226
# in smallvector we intentionally put a constant above some preprocessor includes
230227
premium-misra-cpp-2023-19.0.3:lib/smallvector.h
231228

lib/checkleakautovar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class CPPCHECKLIB VarInfo {
7676
referenced.erase(varid);
7777
}
7878

79-
void swap(VarInfo &other) {
79+
void swap(VarInfo &other) NOEXCEPT {
8080
alloctype.swap(other.alloctype);
8181
possibleUsage.swap(other.possibleUsage);
8282
conditionalAlloc.swap(other.conditionalAlloc);

lib/programmemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void ProgramMemory::erase_if(const std::function<bool(const ExprIdToken&)>& pred
184184
}
185185
}
186186

187-
void ProgramMemory::swap(ProgramMemory &pm)
187+
void ProgramMemory::swap(ProgramMemory &pm) NOEXCEPT
188188
{
189189
mValues.swap(pm.mValues);
190190
}

lib/programmemory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct CPPCHECKLIB ProgramMemory {
124124

125125
void erase_if(const std::function<bool(const ExprIdToken&)>& pred);
126126

127-
void swap(ProgramMemory &pm);
127+
void swap(ProgramMemory &pm) NOEXCEPT;
128128

129129
void clear();
130130

lib/valueptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class CPPCHECKLIB ValuePtr {
7575
return get();
7676
}
7777

78-
void swap(ValuePtr& rhs) {
78+
void swap(ValuePtr& rhs) NOEXCEPT {
7979
using std::swap;
8080
swap(mPtr, rhs.mPtr);
8181
swap(mClone, rhs.mClone);

0 commit comments

Comments
 (0)