--------------------------------------------------------------------------- try {} catch (std::exception err) {} <- Should be "std::exception& err" ---------------------------------------------------------------------------
| 208 | // try {} catch (std::exception err) {} <- Should be "std::exception& err" |
| 209 | //--------------------------------------------------------------------------- |
| 210 | void CheckExceptionSafetyImpl::checkCatchExceptionByValue() |
| 211 | { |
| 212 | if (!mSettings.severity.isEnabled(Severity::style) && !mSettings.isPremiumEnabled("catchExceptionByValue")) |
| 213 | return; |
| 214 | |
| 215 | logChecker("CheckExceptionSafety::checkCatchExceptionByValue"); // style |
| 216 | |
| 217 | const SymbolDatabase* const symbolDatabase = mTokenizer->getSymbolDatabase(); |
| 218 | |
| 219 | for (const Scope &scope : symbolDatabase->scopeList) { |
| 220 | if (scope.type != ScopeType::eCatch) |
| 221 | continue; |
| 222 | |
| 223 | // Find a pass-by-value declaration in the catch(), excluding basic types |
| 224 | // e.g. catch (std::exception err) |
| 225 | const Variable *var = scope.bodyStart->tokAt(-2)->variable(); |
| 226 | if (var && var->isClass() && !var->isPointer() && !var->isReference()) |
| 227 | catchExceptionByValueError(scope.classDef); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | void CheckExceptionSafetyImpl::catchExceptionByValueError(const Token *tok) |
| 232 | { |