From 68700b3561f9a5e0b79a71a801acd668ad798081 Mon Sep 17 00:00:00 2001 From: Zachary Blair Date: Fri, 31 Dec 2010 12:48:24 -0800 Subject: [PATCH] Fixed #2382 (Catching exceptions by value instead of reference) --- lib/checkother.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 0e99191bb..53ba5fa11 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -319,8 +319,7 @@ void CheckOther::checkCatchExceptionByValue() // Find a pass-by-value declaration in the catch(), excluding basic types // e.g. catch (std::exception err) const Token *tokType = Token::findmatch(tok, "%type% %var% )", endTok); - if (tokType && - !Token::Match(tokType, "bool|char|double|enum|float|int|long|short|size_t|wchar_t")) + if (tokType && !tokType->isStandardType()) { catchExceptionByValueError(tokType); } @@ -2800,7 +2799,7 @@ void CheckOther::misusedScopeObjectError(const Token *tok, const std::string& va void CheckOther::catchExceptionByValueError(const Token *tok) { reportError(tok, Severity::style, - "catchExceptionByStyle", "Exception should be caught by reference.\n" + "catchExceptionByValue", "Exception should be caught by reference.\n" "The exception is caught as a value. It could be caught " "as a (const) reference which is usually recommended in C++."); }