Cppcheck
checkclass.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2024 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 //---------------------------------------------------------------------------
20 #ifndef checkclassH
21 #define checkclassH
22 //---------------------------------------------------------------------------
23 
24 #include "check.h"
25 #include "config.h"
26 #include "tokenize.h"
27 #include "symboldatabase.h"
28 
29 #include <list>
30 #include <map>
31 #include <set>
32 #include <string>
33 #include <vector>
34 
35 class ErrorLogger;
36 class Settings;
37 class Token;
38 
39 namespace CTU {
40  class FileInfo;
41 }
42 
43 namespace tinyxml2 {
44  class XMLElement;
45 }
46 
47 /// @addtogroup Checks
48 /// @{
49 
50 
51 /** @brief %Check classes. Uninitialized member variables, non-conforming operators, missing virtual destructor, etc */
52 class CPPCHECKLIB CheckClass : public Check {
53  friend class TestClass;
54  friend class TestConstructors;
55  friend class TestUnusedPrivateFunction;
56 
57 public:
58  /** @brief This constructor is used when registering the CheckClass */
59  CheckClass() : Check(myName()) {}
60 
61  /** @brief Set of the STL types whose operator[] is not const */
62  static const std::set<std::string> stl_containers_not_const;
63 
64 private:
65  /** @brief This constructor is used when running checks. */
66  CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
67 
68  /** @brief Run checks on the normal token list */
69  void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
70  if (tokenizer.isC())
71  return;
72 
73  CheckClass checkClass(&tokenizer, &tokenizer.getSettings(), errorLogger);
74 
75  // can't be a simplified check .. the 'sizeof' is used.
76  checkClass.checkMemset();
77  checkClass.constructors();
78  checkClass.privateFunctions();
79  checkClass.operatorEqRetRefThis();
80  checkClass.thisSubtraction();
81  checkClass.operatorEqToSelf();
82  checkClass.initializerListOrder();
83  checkClass.initializationListUsage();
84  checkClass.checkSelfInitialization();
85  checkClass.virtualDestructor();
86  checkClass.checkConst();
87  checkClass.copyconstructors();
89  checkClass.checkDuplInheritedMembers();
90  checkClass.checkExplicitConstructors();
91  checkClass.checkCopyCtorAndEqOperator();
92  checkClass.checkOverride();
93  checkClass.checkUselessOverride();
94  checkClass.checkReturnByReference();
95  checkClass.checkThisUseAfterFree();
96  checkClass.checkUnsafeClassRefMember();
97  }
98 
99  /** @brief %Check that all class constructors are ok */
100  void constructors();
101 
102  /** @brief %Check that constructors with single parameter are explicit,
103  * if they has to be.*/
104  void checkExplicitConstructors();
105 
106  /** @brief %Check that all private functions are called */
107  void privateFunctions();
108 
109  /**
110  * @brief %Check that the memsets are valid.
111  * The 'memset' function can do dangerous things if used wrong. If it
112  * is used on STL containers for instance it will clear all its data
113  * and then the STL container may leak memory or worse have an invalid state.
114  * It can also overwrite the virtual table.
115  * Important: The checking doesn't work on simplified tokens list.
116  */
117  void checkMemset();
118  void checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::set<const Scope *> parsedTypes);
119 
120  /** @brief 'operator=' should return reference to *this */
121  void operatorEqRetRefThis(); // Warning upon no "return *this;"
122 
123  /** @brief 'operator=' should check for assignment to self */
124  void operatorEqToSelf(); // Warning upon no check for assignment to self
125 
126  /** @brief The destructor in a base class should be virtual */
127  void virtualDestructor();
128 
129  /** @brief warn for "this-x". The indented code may be "this->x" */
130  void thisSubtraction();
131 
132  /** @brief can member function be const? */
133  void checkConst();
134 
135  /** @brief Check initializer list order */
136  void initializerListOrder();
137 
138  /** @brief Suggest using initialization list */
139  void initializationListUsage();
140 
141  /** @brief Check for initialization of a member with itself */
142  void checkSelfInitialization();
143 
144  void copyconstructors();
145 
146  /** @brief call of virtual function in constructor/destructor */
147  void checkVirtualFunctionCallInConstructor();
148 
149  /** @brief Check duplicated inherited members */
150  void checkDuplInheritedMembers();
151 
152  /** @brief Check that copy constructor and operator defined together */
153  void checkCopyCtorAndEqOperator();
154 
155  /** @brief Check that the override keyword is used when overriding virtual functions */
156  void checkOverride();
157 
158  /** @brief Check that the overriden function is not identical to the base function */
159  void checkUselessOverride();
160 
161  /** @brief Check that large members are returned by reference from getter function */
162  void checkReturnByReference();
163 
164  /** @brief When "self pointer" is destroyed, 'this' might become invalid. */
165  void checkThisUseAfterFree();
166 
167  /** @brief Unsafe class check - const reference member */
168  void checkUnsafeClassRefMember();
169 
170  /** @brief Parse current TU and extract file info */
171  Check::FileInfo *getFileInfo(const Tokenizer &tokenizer, const Settings &settings) const override;
172 
173  Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const override;
174 
175  /** @brief Analyse all file infos for all TU */
176  bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override;
177 
178  const SymbolDatabase* mSymbolDatabase{};
179 
180  // Reporting errors..
181  void noConstructorError(const Token *tok, const std::string &classname, bool isStruct);
182  void noExplicitConstructorError(const Token *tok, const std::string &classname, bool isStruct);
183  //void copyConstructorMallocError(const Token *cctor, const Token *alloc, const std::string& var_name);
184  void copyConstructorShallowCopyError(const Token *tok, const std::string& varname);
185  void noCopyConstructorError(const Scope *scope, bool isdefault, const Token *alloc, bool inconclusive);
186  void noOperatorEqError(const Scope *scope, bool isdefault, const Token *alloc, bool inconclusive);
187  void noDestructorError(const Scope *scope, bool isdefault, const Token *alloc);
188  void uninitVarError(const Token *tok, bool isprivate, Function::Type functionType, const std::string &classname, const std::string &varname, bool derived, bool inconclusive);
189  void uninitVarError(const Token *tok, const std::string &classname, const std::string &varname);
190  void missingMemberCopyError(const Token *tok, Function::Type functionType, const std::string& classname, const std::string& varname);
191  void operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname, bool inconclusive);
192  void unusedPrivateFunctionError(const Token *tok, const std::string &classname, const std::string &funcname);
193  void memsetError(const Token *tok, const std::string &memfunc, const std::string &classname, const std::string &type, bool isContainer = false);
194  void memsetErrorReference(const Token *tok, const std::string &memfunc, const std::string &type);
195  void memsetErrorFloat(const Token *tok, const std::string &type);
196  void mallocOnClassError(const Token* tok, const std::string &memfunc, const Token* classTok, const std::string &classname);
197  void mallocOnClassWarning(const Token* tok, const std::string &memfunc, const Token* classTok);
198  void virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived, bool inconclusive);
199  void thisSubtractionError(const Token *tok);
200  void operatorEqRetRefThisError(const Token *tok);
201  void operatorEqShouldBeLeftUnimplementedError(const Token *tok);
202  void operatorEqMissingReturnStatementError(const Token *tok, bool error);
203  void operatorEqToSelfError(const Token *tok);
204  void checkConstError(const Token *tok, const std::string &classname, const std::string &funcname, bool suggestStatic);
205  void checkConstError2(const Token *tok1, const Token *tok2, const std::string &classname, const std::string &funcname, bool suggestStatic);
206  void initializerListError(const Token *tok1,const Token *tok2, const std::string & classname, const std::string &varname, const std::string& argname = {});
207  void suggestInitializationList(const Token *tok, const std::string& varname);
208  void selfInitializationError(const Token* tok, const std::string& varname);
209  void pureVirtualFunctionCallInConstructorError(const Function * scopeFunction, const std::list<const Token *> & tokStack, const std::string &purefuncname);
210  void virtualFunctionCallInConstructorError(const Function * scopeFunction, const std::list<const Token *> & tokStack, const std::string &funcname);
211  void duplInheritedMembersError(const Token* tok1, const Token* tok2, const std::string &derivedName, const std::string &baseName, const std::string &memberName, bool derivedIsStruct, bool baseIsStruct, bool isFunction = false);
212  void copyCtorAndEqOperatorError(const Token *tok, const std::string &classname, bool isStruct, bool hasCopyCtor);
213  void overrideError(const Function *funcInBase, const Function *funcInDerived);
214  void uselessOverrideError(const Function *funcInBase, const Function *funcInDerived, bool isSameCode = false);
215  void returnByReferenceError(const Function *func, const Variable* var);
216  void thisUseAfterFree(const Token *self, const Token *free, const Token *use);
217  void unsafeClassRefMemberError(const Token *tok, const std::string &varname);
218  void checkDuplInheritedMembersRecursive(const Type* typeCurrent, const Type* typeBase);
219 
220  void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override {
221  CheckClass c(nullptr, settings, errorLogger);
222  c.noConstructorError(nullptr, "classname", false);
223  c.noExplicitConstructorError(nullptr, "classname", false);
224  //c.copyConstructorMallocError(nullptr, 0, "var");
225  c.copyConstructorShallowCopyError(nullptr, "var");
226  c.noCopyConstructorError(nullptr, false, nullptr, false);
227  c.noOperatorEqError(nullptr, false, nullptr, false);
228  c.noDestructorError(nullptr, false, nullptr);
229  c.uninitVarError(nullptr, false, Function::eConstructor, "classname", "varname", false, false);
230  c.uninitVarError(nullptr, true, Function::eConstructor, "classname", "varnamepriv", false, false);
231  c.uninitVarError(nullptr, false, Function::eConstructor, "classname", "varname", true, false);
232  c.uninitVarError(nullptr, true, Function::eConstructor, "classname", "varnamepriv", true, false);
233  c.missingMemberCopyError(nullptr, Function::eConstructor, "classname", "varnamepriv");
234  c.operatorEqVarError(nullptr, "classname", emptyString, false);
235  c.unusedPrivateFunctionError(nullptr, "classname", "funcname");
236  c.memsetError(nullptr, "memfunc", "classname", "class");
237  c.memsetErrorReference(nullptr, "memfunc", "class");
238  c.memsetErrorFloat(nullptr, "class");
239  c.mallocOnClassWarning(nullptr, "malloc", nullptr);
240  c.mallocOnClassError(nullptr, "malloc", nullptr, "std::string");
241  c.virtualDestructorError(nullptr, "Base", "Derived", false);
242  c.thisSubtractionError(nullptr);
243  c.operatorEqRetRefThisError(nullptr);
244  c.operatorEqMissingReturnStatementError(nullptr, true);
246  c.operatorEqToSelfError(nullptr);
247  c.checkConstError(nullptr, "class", "function", false);
248  c.checkConstError(nullptr, "class", "function", true);
249  c.initializerListError(nullptr, nullptr, "class", "variable");
250  c.suggestInitializationList(nullptr, "variable");
251  c.selfInitializationError(nullptr, "var");
252  c.duplInheritedMembersError(nullptr, nullptr, "class", "class", "variable", false, false);
253  c.copyCtorAndEqOperatorError(nullptr, "class", false, false);
254  c.overrideError(nullptr, nullptr);
255  c.uselessOverrideError(nullptr, nullptr);
256  c.returnByReferenceError(nullptr, nullptr);
257  c.pureVirtualFunctionCallInConstructorError(nullptr, std::list<const Token *>(), "f");
258  c.virtualFunctionCallInConstructorError(nullptr, std::list<const Token *>(), "f");
259  c.thisUseAfterFree(nullptr, nullptr, nullptr);
260  c.unsafeClassRefMemberError(nullptr, "UnsafeClass::var");
261  }
262 
263  static std::string myName() {
264  return "Class";
265  }
266 
267  std::string classInfo() const override {
268  return "Check the code for each class.\n"
269  "- Missing constructors and copy constructors\n"
270  //"- Missing allocation of memory in copy constructor\n"
271  "- Constructors which should be explicit\n"
272  "- Are all variables initialized by the constructors?\n"
273  "- Are all variables assigned by 'operator='?\n"
274  "- Warn if memset, memcpy etc are used on a class\n"
275  "- Warn if memory for classes is allocated with malloc()\n"
276  "- If it's a base class, check that the destructor is virtual\n"
277  "- Are there unused private functions?\n"
278  "- 'operator=' should check for assignment to self\n"
279  "- Constness for member functions\n"
280  "- Order of initializations\n"
281  "- Suggest usage of initialization list\n"
282  "- Initialization of a member with itself\n"
283  "- Suspicious subtraction from 'this'\n"
284  "- Call of pure virtual function in constructor/destructor\n"
285  "- Duplicated inherited data members\n"
286  // disabled for now "- If 'copy constructor' defined, 'operator=' also should be defined and vice versa\n"
287  "- Check that arbitrary usage of public interface does not result in division by zero\n"
288  "- Delete \"self pointer\" and then access 'this'\n"
289  "- Check that the 'override' keyword is used when overriding virtual functions\n"
290  "- Check that the 'one definition rule' is not violated\n";
291  }
292 
293  // operatorEqRetRefThis helper functions
294  void checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last);
295  void checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set<const Function*>& analyzedFunctions);
296 
297  // operatorEqToSelf helper functions
298  bool hasAllocation(const Function *func, const Scope* scope) const;
299  bool hasAllocation(const Function *func, const Scope* scope, const Token *start, const Token *end) const;
300  bool hasAllocationInIfScope(const Function *func, const Scope* scope, const Token *ifStatementScopeStart) const;
301  static bool hasAssignSelf(const Function *func, const Token *rhs, const Token *&out_ifStatementScopeStart);
302  enum class Bool { TRUE, FALSE, BAILOUT };
303  static Bool isInverted(const Token *tok, const Token *rhs);
304  static const Token * getIfStmtBodyStart(const Token *tok, const Token *rhs);
305 
306  // checkConst helper functions
307  bool isMemberVar(const Scope *scope, const Token *tok) const;
308  static bool isMemberFunc(const Scope *scope, const Token *tok);
309  static bool isConstMemberFunc(const Scope *scope, const Token *tok);
310  enum class MemberAccess { NONE, SELF, MEMBER };
311  bool checkConstFunc(const Scope *scope, const Function *func, MemberAccess& memberAccessed) const;
312 
313  // constructors helper function
314  /** @brief Information about a member variable. Used when checking for uninitialized variables */
315  struct Usage {
316  explicit Usage(const Variable *var) : var(var) {}
317 
318  /** Variable that this usage is for */
319  const Variable *var;
320 
321  /** @brief has this variable been assigned? */
322  bool assign{};
323 
324  /** @brief has this variable been initialized? */
325  bool init{};
326  };
327 
328  static bool isBaseClassMutableMemberFunc(const Token *tok, const Scope *scope);
329 
330  /**
331  * @brief Create usage list that contains all scope members and also members
332  * of base classes without constructors.
333  * @param scope current class scope
334  */
335  static std::vector<Usage> createUsageList(const Scope *scope);
336 
337  /**
338  * @brief assign a variable in the varlist
339  * @param usageList reference to usage vector
340  * @param varid id of variable to mark assigned
341  */
342  static void assignVar(std::vector<Usage> &usageList, nonneg int varid);
343 
344  /**
345  * @brief assign a variable in the varlist
346  * @param usageList reference to usage vector
347  * @param vartok variable token
348  */
349  static void assignVar(std::vector<Usage> &usageList, const Token *vartok);
350 
351  /**
352  * @brief initialize a variable in the varlist
353  * @param usageList reference to usage vector
354  * @param varid id of variable to mark initialized
355  */
356  static void initVar(std::vector<Usage> &usageList, nonneg int varid);
357 
358  /**
359  * @brief set all variables in list assigned
360  * @param usageList reference to usage vector
361  */
362  static void assignAllVar(std::vector<Usage> &usageList);
363 
364  /**
365  * @brief set all variable in list assigned, if visible from given scope
366  * @param usageList reference to usage vector
367  * @param scope scope from which usages must be visible
368  */
369  static void assignAllVarsVisibleFromScope(std::vector<Usage> &usageList, const Scope *scope);
370 
371  /**
372  * @brief set all variables in list not assigned and not initialized
373  * @param usageList reference to usage vector
374  */
375  static void clearAllVar(std::vector<Usage> &usageList);
376 
377  /**
378  * @brief parse a scope for a constructor or member function and set the "init" flags in the provided varlist
379  * @param func reference to the function that should be checked
380  * @param callstack the function doesn't look into recursive function calls.
381  * @param scope pointer to variable Scope
382  * @param usage reference to usage vector
383  */
384  void initializeVarList(const Function &func, std::list<const Function *> &callstack, const Scope *scope, std::vector<Usage> &usage) const;
385 
386  /**
387  * @brief gives a list of tokens where virtual functions are called directly or indirectly
388  * @param function function to be checked
389  * @param virtualFunctionCallsMap map of results for already checked functions
390  * @return list of tokens where pure virtual functions are called
391  */
392  const std::list<const Token *> & getVirtualFunctionCalls(
393  const Function & function,
394  std::map<const Function *, std::list<const Token *>> & virtualFunctionCallsMap);
395 
396  /**
397  * @brief looks for the first virtual function call stack
398  * @param virtualFunctionCallsMap map of results obtained from getVirtualFunctionCalls
399  * @param callToken token where pure virtual function is called directly or indirectly
400  * @param[in,out] pureFuncStack list to append the stack
401  */
402  static void getFirstVirtualFunctionCallStack(
403  std::map<const Function *, std::list<const Token *>> & virtualFunctionCallsMap,
404  const Token *callToken,
405  std::list<const Token *> & pureFuncStack);
406 
407  static bool canNotCopy(const Scope *scope);
408 
409  static bool canNotMove(const Scope *scope);
410 
411  /**
412  * @brief Helper for checkThisUseAfterFree
413  */
414  bool checkThisUseAfterFreeRecursive(const Scope *classScope, const Function *func, const Variable *selfPointer, std::set<const Function *> callstack, const Token *&freeToken);
415 };
416 /// @}
417 //---------------------------------------------------------------------------
418 #endif // checkclassH
Check classes.
Definition: checkclass.h:52
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override
get error messages
Definition: checkclass.h:220
void operatorEqMissingReturnStatementError(const Token *tok, bool error)
void overrideError(const Function *funcInBase, const Function *funcInDerived)
void checkCopyCtorAndEqOperator()
Check that copy constructor and operator defined together.
void checkOverride()
Check that the override keyword is used when overriding virtual functions.
void uninitVarError(const Token *tok, bool isprivate, Function::Type functionType, const std::string &classname, const std::string &varname, bool derived, bool inconclusive)
void thisSubtraction()
warn for "this-x".
void checkThisUseAfterFree()
When "self pointer" is destroyed, 'this' might become invalid.
void initializerListError(const Token *tok1, const Token *tok2, const std::string &classname, const std::string &varname, const std::string &argname={})
void noExplicitConstructorError(const Token *tok, const std::string &classname, bool isStruct)
void operatorEqRetRefThis()
'operator=' should return reference to *this
void operatorEqToSelfError(const Token *tok)
void operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname, bool inconclusive)
void duplInheritedMembersError(const Token *tok1, const Token *tok2, const std::string &derivedName, const std::string &baseName, const std::string &memberName, bool derivedIsStruct, bool baseIsStruct, bool isFunction=false)
void uselessOverrideError(const Function *funcInBase, const Function *funcInDerived, bool isSameCode=false)
void mallocOnClassWarning(const Token *tok, const std::string &memfunc, const Token *classTok)
void copyConstructorShallowCopyError(const Token *tok, const std::string &varname)
Definition: checkclass.cpp:540
void unusedPrivateFunctionError(const Token *tok, const std::string &classname, const std::string &funcname)
void checkUnsafeClassRefMember()
Unsafe class check - const reference member.
void virtualFunctionCallInConstructorError(const Function *scopeFunction, const std::list< const Token * > &tokStack, const std::string &funcname)
CheckClass()
This constructor is used when registering the CheckClass.
Definition: checkclass.h:59
void thisSubtractionError(const Token *tok)
void checkReturnByReference()
Check that large members are returned by reference from getter function.
void checkDuplInheritedMembers()
Check duplicated inherited members.
void operatorEqToSelf()
'operator=' should check for assignment to self
void selfInitializationError(const Token *tok, const std::string &varname)
void operatorEqShouldBeLeftUnimplementedError(const Token *tok)
void mallocOnClassError(const Token *tok, const std::string &memfunc, const Token *classTok, const std::string &classname)
void noConstructorError(const Token *tok, const std::string &classname, bool isStruct)
void privateFunctions()
Check that all private functions are called
void virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived, bool inconclusive)
void checkUselessOverride()
Check that the overriden function is not identical to the base function.
void initializerListOrder()
Check initializer list order.
void initializationListUsage()
Suggest using initialization list.
void checkMemset()
Check that the memsets are valid.
void noDestructorError(const Scope *scope, bool isdefault, const Token *alloc)
Definition: checkclass.cpp:576
void missingMemberCopyError(const Token *tok, Function::Type functionType, const std::string &classname, const std::string &varname)
static std::string myName()
Definition: checkclass.h:263
void checkVirtualFunctionCallInConstructor()
call of virtual function in constructor/destructor
std::string classInfo() const override
get information about this class, used to generate documentation
Definition: checkclass.h:267
void memsetErrorFloat(const Token *tok, const std::string &type)
void noCopyConstructorError(const Scope *scope, bool isdefault, const Token *alloc, bool inconclusive)
Definition: checkclass.cpp:566
void checkConstError(const Token *tok, const std::string &classname, const std::string &funcname, bool suggestStatic)
void constructors()
Check that all class constructors are ok
Definition: checkclass.cpp:128
void checkSelfInitialization()
Check for initialization of a member with itself.
void operatorEqRetRefThisError(const Token *tok)
void noOperatorEqError(const Scope *scope, bool isdefault, const Token *alloc, bool inconclusive)
Definition: checkclass.cpp:571
static const std::set< std::string > stl_containers_not_const
Set of the STL types whose operator[] is not const.
Definition: checkclass.h:62
void virtualDestructor()
The destructor in a base class should be virtual.
void copyconstructors()
Definition: checkclass.cpp:408
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override
Run checks on the normal token list.
Definition: checkclass.h:69
void suggestInitializationList(const Token *tok, const std::string &varname)
void returnByReferenceError(const Function *func, const Variable *var)
void memsetErrorReference(const Token *tok, const std::string &memfunc, const std::string &type)
void pureVirtualFunctionCallInConstructorError(const Function *scopeFunction, const std::list< const Token * > &tokStack, const std::string &purefuncname)
void unsafeClassRefMemberError(const Token *tok, const std::string &varname)
void memsetError(const Token *tok, const std::string &memfunc, const std::string &classname, const std::string &type, bool isContainer=false)
void checkConst()
can member function be const?
void thisUseAfterFree(const Token *self, const Token *free, const Token *use)
void checkExplicitConstructors()
Check that constructors with single parameter are explicit, if they has to be.
Definition: checkclass.cpp:339
void copyCtorAndEqOperatorError(const Token *tok, const std::string &classname, bool isStruct, bool hasCopyCtor)
Base class used for whole-program analysis.
Definition: check.h:103
Interface class that cppcheck uses to communicate with the checks.
Definition: check.h:59
virtual bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list< FileInfo * > &fileInfo, const Settings &, ErrorLogger &)
Definition: check.h:122
virtual FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const
Definition: check.h:116
virtual FileInfo * getFileInfo(const Tokenizer &, const Settings &) const
Definition: check.h:112
This is an interface, which the class responsible of error logging should implement.
Definition: errorlogger.h:214
This is just a container for general settings so that we don't need to pass individual values to func...
Definition: settings.h:95
The token list that the TokenList generates is a linked-list of this class.
Definition: token.h:150
The main purpose is to tokenize the source code.
Definition: tokenize.h:46
const Settings & getSettings() const
Definition: tokenize.h:615
bool isC() const
Is the code C.
Definition: tokenize.h:64
Information about a class type.
Information about a member variable.
static const std::string emptyString
Definition: config.h:127
#define CPPCHECKLIB
Definition: config.h:35
#define nonneg
Definition: config.h:138
@ error
Programming error.
Whole program analysis (ctu=Cross Translation Unit)
Definition: check.h:35
Definition: check.h:31
Information about a member variable.
Definition: checkclass.h:315
const Variable * var
Variable that this usage is for.
Definition: checkclass.h:319
Usage(const Variable *var)
Definition: checkclass.h:316