From 9ce6630b28f7299e81496d87417e3770821ef8f3 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 1 Dec 2012 02:16:03 +0100 Subject: [PATCH] Add some unused private copy ctors and operator=. In Token and in Check classes, GCC -Weffc++ reports that it's better to override the copy constructors and the assignment operator to avoid problems with copied objects which could have the same pointers, hence with double frees, when we delete one of these pointers in the copied and in the original object. --- lib/check.h | 3 ++- lib/token.h | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/check.h b/lib/check.h index c4f74b4b3..2980d5b7f 100644 --- a/lib/check.h +++ b/lib/check.h @@ -132,8 +132,9 @@ protected: private: const std::string _name; - /** disabled assignment operator */ + /** disabled assignment operator and copy constructor */ void operator=(const Check &); + Check(const Check &); }; namespace std { diff --git a/lib/token.h b/lib/token.h index d6c89460c..1745af192 100644 --- a/lib/token.h +++ b/lib/token.h @@ -45,6 +45,8 @@ private: // Not implemented.. Token(); + Token(const Token &); + Token operator=(const Token &); public: enum Type { @@ -139,8 +141,13 @@ public: * multi-compare patterns such as "int|void|char" can contain %or%, %oror% and %op% * but it is not recommended to put such an %cmd% as the first pattern. * - * It's possible to use multi-compare patterns with just %cmds%, except for %varid%. - * For example: "%var%|%num%| " means yes to a variable, a number or empty string. + * It's possible to use multi-compare patterns with all the other %cmds%, + * except for %varid%, and normal names, but the %cmds% should be put as + * the first patterns in the list, then the normal names. + * For example: "%var%|%num%|)" means yes to a variable, a number or ')'. + * + * @todo Make it possible to use the %cmds% and the normal names in the + * multicompare list without an order. * * The patterns can be also combined to compare to multiple tokens at once * by separating tokens with a space, e.g. @@ -151,7 +158,8 @@ public: * @param tok List of tokens to be compared to the pattern * @param pattern The pattern against which the tokens are compared, * e.g. "const" or ") const|volatile| {". - * @param varid if %varid% is given in the pattern the Token::varId will be matched against this argument + * @param varid if %varid% is given in the pattern the Token::varId + * will be matched against this argument * @return true if given token matches with given pattern * false if given token does not match with given pattern */