Cppcheck
library.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 libraryH
21 #define libraryH
22 //---------------------------------------------------------------------------
23 
24 #include "config.h"
25 #include "mathlib.h"
26 #include "standards.h"
27 
28 #include <map>
29 #include <memory>
30 #include <set>
31 #include <string>
32 #include <unordered_map>
33 #include <unordered_set>
34 #include <utility>
35 #include <vector>
36 
37 class Token;
38 class Settings;
39 enum class Severity;
40 
41 namespace tinyxml2 {
42  class XMLDocument;
43  class XMLElement;
44 }
45 
46 /// @addtogroup Core
47 /// @{
48 
49 /**
50  * @brief Library definitions handling
51  */
53  // TODO: get rid of this
54  friend class TestSymbolDatabase; // For testing only
55  friend class TestSingleExecutorBase; // For testing only
56  friend class TestThreadExecutorBase; // For testing only
57  friend class TestProcessExecutorBase; // For testing only
58 
59 public:
60  Library() = default;
61 
62  enum class ErrorCode {
63  OK,
64  FILE_NOT_FOUND, BAD_XML, UNKNOWN_ELEMENT, MISSING_ATTRIBUTE, BAD_ATTRIBUTE_VALUE,
65  UNSUPPORTED_FORMAT, DUPLICATE_PLATFORM_TYPE, PLATFORM_TYPE_REDEFINED, DUPLICATE_DEFINE
66  };
67 
68  class Error {
69  public:
70  Error() : errorcode(ErrorCode::OK) {}
71  explicit Error(ErrorCode e) : errorcode(e) {}
72  template<typename T>
73  Error(ErrorCode e, T&& r) : errorcode(e), reason(r) {}
75  std::string reason;
76  };
77 
78  Error load(const char exename[], const char path[]);
79  Error load(const tinyxml2::XMLDocument &doc);
80 
81  struct AllocFunc {
82  int groupId;
83  int arg;
84  enum class BufferSize {none,malloc,calloc,strdup};
89  bool initData;
90  };
91 
92  /** get allocation info for function */
93  const AllocFunc* getAllocFuncInfo(const Token *tok) const;
94 
95  /** get deallocation info for function */
96  const AllocFunc* getDeallocFuncInfo(const Token *tok) const;
97 
98  /** get reallocation info for function */
99  const AllocFunc* getReallocFuncInfo(const Token *tok) const;
100 
101  /** get allocation id for function */
102  int getAllocId(const Token *tok, int arg) const;
103 
104  /** get deallocation id for function */
105  int getDeallocId(const Token *tok, int arg) const;
106 
107  /** get reallocation id for function */
108  int getReallocId(const Token *tok, int arg) const;
109 
110  // TODO: get rid of this
111  /** get allocation info for function by name (deprecated, use other alloc) */
112  const AllocFunc* getAllocFuncInfo(const char name[]) const {
113  return getAllocDealloc(mAlloc, name);
114  }
115 
116  // TODO: get rid of this
117  /** get deallocation info for function by name (deprecated, use other alloc) */
118  const AllocFunc* getDeallocFuncInfo(const char name[]) const {
119  return getAllocDealloc(mDealloc, name);
120  }
121 
122  // TODO: get rid of this
123  /** get allocation id for function by name (deprecated, use other alloc) */
124  // cppcheck-suppress unusedFunction
125  int allocId(const char name[]) const {
126  const AllocFunc* af = getAllocDealloc(mAlloc, name);
127  return af ? af->groupId : 0;
128  }
129 
130  // TODO: get rid of this
131  /** get deallocation id for function by name (deprecated, use other alloc) */
132  int deallocId(const char name[]) const {
133  const AllocFunc* af = getAllocDealloc(mDealloc, name);
134  return af ? af->groupId : 0;
135  }
136 
137  static bool isCompliantValidationExpression(const char* p);
138 
139  /** is allocation type memory? */
140  static bool ismemory(const int id) {
141  return ((id > 0) && ((id & 1) == 0));
142  }
143  static bool ismemory(const AllocFunc* const func) {
144  return func && (func->groupId > 0) && ((func->groupId & 1) == 0);
145  }
146 
147  /** is allocation type resource? */
148  static bool isresource(const int id) {
149  return ((id > 0) && ((id & 1) == 1));
150  }
151  static bool isresource(const AllocFunc* const func) {
152  return func && (func->groupId > 0) && ((func->groupId & 1) == 1);
153  }
154 
155  bool formatstr_function(const Token* ftok) const;
156  int formatstr_argno(const Token* ftok) const;
157  bool formatstr_scan(const Token* ftok) const;
158  bool formatstr_secure(const Token* ftok) const;
159 
161  int ptr1Arg;
162  int ptr2Arg;
163  int sizeArg;
165  int countArg;
166  };
167  const NonOverlappingData* getNonOverlappingData(const Token *ftok) const;
168 
169  struct WarnInfo {
170  std::string message;
173  };
174  std::map<std::string, WarnInfo> functionwarn;
175 
176  const WarnInfo* getWarnInfo(const Token* ftok) const;
177 
178  // returns true if ftok is not a library function
179  bool isNotLibraryFunction(const Token *ftok) const;
180  bool matchArguments(const Token *ftok, const std::string &functionName) const;
181 
182  enum class UseRetValType { NONE, DEFAULT, ERROR_CODE };
183  UseRetValType getUseRetValType(const Token* ftok) const;
184 
185  const std::string& returnValue(const Token *ftok) const;
186  const std::string& returnValueType(const Token *ftok) const;
187  int returnValueContainer(const Token *ftok) const;
188  std::vector<MathLib::bigint> unknownReturnValues(const Token *ftok) const;
189 
190  bool isnoreturn(const Token *ftok) const;
191  bool isnotnoreturn(const Token *ftok) const;
192 
193  bool isScopeNoReturn(const Token *end, std::string *unknownFunc) const;
194 
195  class Container {
196  public:
197  Container() = default;
198 
199  enum class Action {
200  RESIZE,
201  CLEAR,
202  PUSH,
203  POP,
204  FIND,
205  FIND_CONST,
206  INSERT,
207  ERASE,
208  CHANGE_CONTENT,
209  CHANGE,
210  CHANGE_INTERNAL,
211  NO_ACTION
212  };
213  enum class Yield {
214  AT_INDEX,
215  ITEM,
216  BUFFER,
217  BUFFER_NT,
218  START_ITERATOR,
219  END_ITERATOR,
220  ITERATOR,
221  SIZE,
222  EMPTY,
223  NO_YIELD
224  };
225  struct Function {
228  std::string returnType;
229  };
231  std::string name;
232  int templateParameter; // TODO: use this
233  };
234  std::string startPattern, startPattern2, endPattern, itEndPattern;
235  std::map<std::string, Function> functions;
236  int type_templateArgNo = -1;
237  std::vector<RangeItemRecordTypeItem> rangeItemRecordType;
238  int size_templateArgNo = -1;
239  bool arrayLike_indexOp{};
240  bool stdStringLike{};
241  bool stdAssociativeLike{};
242  bool opLessAllowed = true;
243  bool hasInitializerListConstructor{};
244  bool unstableErase{};
245  bool unstableInsert{};
246  bool view{};
247 
248  Action getAction(const std::string& function) const {
249  const std::map<std::string, Function>::const_iterator i = functions.find(function);
250  if (i != functions.end())
251  return i->second.action;
252  return Action::NO_ACTION;
253  }
254 
255  Yield getYield(const std::string& function) const {
256  const std::map<std::string, Function>::const_iterator i = functions.find(function);
257  if (i != functions.end())
258  return i->second.yield;
259  return Yield::NO_YIELD;
260  }
261 
262  const std::string& getReturnType(const std::string& function) const {
263  auto i = functions.find(function);
264  return (i != functions.end()) ? i->second.returnType : emptyString;
265  }
266 
267  static Yield yieldFrom(const std::string& yieldName);
268  static Action actionFrom(const std::string& actionName);
269  };
270  std::unordered_map<std::string, Container> containers;
271  const Container* detectContainer(const Token* typeStart) const;
272  const Container* detectIterator(const Token* typeStart) const;
273  const Container* detectContainerOrIterator(const Token* typeStart, bool* isIterator = nullptr, bool withoutStd = false) const;
274 
275  struct ArgumentChecks {
276  bool notbool{};
277  bool notnull{};
278  int notuninit = -1;
279  bool formatstr{};
280  bool strz{};
281  bool optional{};
282  bool variadic{};
283  std::string valid;
284 
285  struct IteratorInfo {
286  int container{};
287  bool it{};
288  bool first{};
289  bool last{};
290  };
292 
293  struct MinSize {
294  enum class Type { NONE, STRLEN, ARGVALUE, SIZEOF, MUL, VALUE };
295  MinSize(Type t, int a) : type(t), arg(a) {}
297  int arg;
298  int arg2 = 0;
299  long long value = 0;
300  std::string baseType;
301  };
302  std::vector<MinSize> minsizes;
303 
304  enum class Direction {
305  DIR_IN, ///< Input to called function. Data is treated as read-only.
306  DIR_OUT, ///< Output to caller. Data is passed by reference or address and is potentially written.
307  DIR_INOUT, ///< Input to called function, and output to caller. Data is passed by reference or address and is potentially modified.
308  DIR_UNKNOWN ///< direction not known / specified
309  };
310  Direction direction = Direction::DIR_UNKNOWN;
311  };
312 
313  struct Function {
314  std::map<int, ArgumentChecks> argumentChecks; // argument nr => argument data
315  bool use{};
316  bool leakignore{};
317  bool isconst{};
318  bool ispure{};
319  UseRetValType useretval = UseRetValType::NONE;
320  bool ignore{}; // ignore functions/macros from a library (gtk, qt etc)
321  bool formatstr{};
322  bool formatstr_scan{};
323  bool formatstr_secure{};
324  Container::Action containerAction = Container::Action::NO_ACTION;
325  Container::Yield containerYield = Container::Yield::NO_YIELD;
326  std::string returnType;
327  };
328 
329  const Function *getFunction(const Token *ftok) const;
330  std::unordered_map<std::string, Function> functions;
331  bool isUse(const std::string& functionName) const;
332  bool isLeakIgnore(const std::string& functionName) const;
333  bool isFunctionConst(const std::string& functionName, bool pure) const;
334  bool isFunctionConst(const Token *ftok) const;
335 
336  bool isboolargbad(const Token *ftok, int argnr) const {
337  const ArgumentChecks *arg = getarg(ftok, argnr);
338  return arg && arg->notbool;
339  }
340 
341  bool isnullargbad(const Token *ftok, int argnr) const;
342  bool isuninitargbad(const Token *ftok, int argnr, int indirect = 0, bool *hasIndirect=nullptr) const;
343 
344  bool isargformatstr(const Token *ftok, int argnr) const {
345  const ArgumentChecks *arg = getarg(ftok, argnr);
346  return arg && arg->formatstr;
347  }
348 
349  bool isargstrz(const Token *ftok, int argnr) const {
350  const ArgumentChecks *arg = getarg(ftok, argnr);
351  return arg && arg->strz;
352  }
353 
354  bool isIntArgValid(const Token *ftok, int argnr, const MathLib::bigint argvalue) const;
355  bool isFloatArgValid(const Token *ftok, int argnr, double argvalue) const;
356 
357  const std::string& validarg(const Token *ftok, int argnr) const {
358  const ArgumentChecks *arg = getarg(ftok, argnr);
359  return arg ? arg->valid : emptyString;
360  }
361 
362  const ArgumentChecks::IteratorInfo *getArgIteratorInfo(const Token *ftok, int argnr) const {
363  const ArgumentChecks *arg = getarg(ftok, argnr);
364  return arg && arg->iteratorInfo.it ? &arg->iteratorInfo : nullptr;
365  }
366 
367  bool hasminsize(const Token *ftok) const;
368 
369  const std::vector<ArgumentChecks::MinSize> *argminsizes(const Token *ftok, int argnr) const {
370  const ArgumentChecks *arg = getarg(ftok, argnr);
371  return arg ? &arg->minsizes : nullptr;
372  }
373 
374  ArgumentChecks::Direction getArgDirection(const Token* ftok, int argnr) const;
375 
376  bool markupFile(const std::string &path) const;
377 
378  bool processMarkupAfterCode(const std::string &path) const;
379 
380  const std::set<std::string> &markupExtensions() const {
381  return mMarkupExtensions;
382  }
383 
384  bool reportErrors(const std::string &path) const;
385 
386  bool ignorefunction(const std::string &functionName) const;
387 
388  bool isexecutableblock(const std::string &file, const std::string &token) const;
389 
390  int blockstartoffset(const std::string &file) const;
391 
392  const std::string& blockstart(const std::string &file) const;
393  const std::string& blockend(const std::string &file) const;
394 
395  bool iskeyword(const std::string &file, const std::string &keyword) const;
396 
397  bool isexporter(const std::string &prefix) const {
398  return mExporters.find(prefix) != mExporters.end();
399  }
400 
401  bool isexportedprefix(const std::string &prefix, const std::string &token) const {
402  const std::map<std::string, ExportedFunctions>::const_iterator it = mExporters.find(prefix);
403  return (it != mExporters.end() && it->second.isPrefix(token));
404  }
405 
406  bool isexportedsuffix(const std::string &prefix, const std::string &token) const {
407  const std::map<std::string, ExportedFunctions>::const_iterator it = mExporters.find(prefix);
408  return (it != mExporters.end() && it->second.isSuffix(token));
409  }
410 
411  bool isimporter(const std::string& file, const std::string &importer) const;
412 
413  const Token* getContainerFromYield(const Token* tok, Container::Yield yield) const;
414  const Token* getContainerFromAction(const Token* tok, Container::Action action) const;
415 
416  bool isreflection(const std::string &token) const {
417  return mReflection.find(token) != mReflection.end();
418  }
419 
420  int reflectionArgument(const std::string &token) const {
421  const std::map<std::string, int>::const_iterator it = mReflection.find(token);
422  if (it != mReflection.end())
423  return it->second;
424  return -1;
425  }
426 
427  bool isentrypoint(const std::string &func) const {
428  return func == "main" || mEntrypoints.find(func) != mEntrypoints.end();
429  }
430 
431  std::set<std::string> defines; // to provide some library defines
432 
433  struct SmartPointer {
434  std::string name;
435  bool unique = false;
436  };
437 
438  std::unordered_map<std::string, SmartPointer> smartPointers;
439  bool isSmartPointer(const Token *tok) const;
440  const SmartPointer* detectSmartPointer(const Token* tok, bool withoutStd = false) const;
441 
442  struct PodType {
443  unsigned int size;
444  char sign;
445  enum class Type { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype;
446  };
447  const PodType *podtype(const std::string &name) const {
448  const std::unordered_map<std::string, PodType>::const_iterator it = mPodTypes.find(name);
449  return (it != mPodTypes.end()) ? &(it->second) : nullptr;
450  }
451 
452  struct PlatformType {
453  bool operator == (const PlatformType & type) const {
454  return (mSigned == type.mSigned &&
455  mUnsigned == type.mUnsigned &&
456  mLong == type.mLong &&
457  mPointer == type.mPointer &&
458  mPtrPtr == type.mPtrPtr &&
459  mConstPtr == type.mConstPtr &&
460  mType == type.mType);
461  }
462  bool operator != (const PlatformType & type) const {
463  return !(*this == type);
464  }
465  std::string mType;
466  bool mSigned{};
467  bool mUnsigned{};
468  bool mLong{};
469  bool mPointer{};
470  bool mPtrPtr{};
471  bool mConstPtr{};
472  };
473 
474  struct Platform {
475  const PlatformType *platform_type(const std::string &name) const {
476  const std::map<std::string, PlatformType>::const_iterator it = mPlatformTypes.find(name);
477  return (it != mPlatformTypes.end()) ? &(it->second) : nullptr;
478  }
479  std::map<std::string, PlatformType> mPlatformTypes;
480  };
481 
482  const PlatformType *platform_type(const std::string &name, const std::string & platform) const {
483  const std::map<std::string, Platform>::const_iterator it = mPlatforms.find(platform);
484  if (it != mPlatforms.end()) {
485  const PlatformType * const type = it->second.platform_type(name);
486  if (type)
487  return type;
488  }
489 
490  const std::map<std::string, PlatformType>::const_iterator it2 = mPlatformTypes.find(name);
491  return (it2 != mPlatformTypes.end()) ? &(it2->second) : nullptr;
492  }
493 
494  /**
495  * Get function name for function call
496  */
497  std::string getFunctionName(const Token *ftok) const;
498 
499  static bool isContainerYield(const Token * const cond, Library::Container::Yield y, const std::string& fallback=emptyString);
500 
501  /** Suppress/check a type */
502  enum class TypeCheck { def,
503  check,
504  suppress,
505  checkFiniteLifetime, // (unusedvar) object has side effects, but immediate destruction is wrong
506  };
507  TypeCheck getTypeCheck(std::string check, std::string typeName) const;
508  bool hasAnyTypeCheck(const std::string& typeName) const;
509 
510 private:
511  // load a <function> xml node
512  Error loadFunction(const tinyxml2::XMLElement * const node, const std::string &name, std::set<std::string> &unknown_elements);
513 
515  public:
516  void addPrefix(std::string prefix) {
517  mPrefixes.insert(std::move(prefix));
518  }
519  void addSuffix(std::string suffix) {
520  mSuffixes.insert(std::move(suffix));
521  }
522  bool isPrefix(const std::string& prefix) const {
523  return (mPrefixes.find(prefix) != mPrefixes.end());
524  }
525  bool isSuffix(const std::string& suffix) const {
526  return (mSuffixes.find(suffix) != mSuffixes.end());
527  }
528 
529  private:
530  std::set<std::string> mPrefixes;
531  std::set<std::string> mSuffixes;
532  };
533  class CodeBlock {
534  public:
535  CodeBlock() = default;
536 
537  void setStart(const char* s) {
538  mStart = s;
539  }
540  void setEnd(const char* e) {
541  mEnd = e;
542  }
543  void setOffset(const int o) {
544  mOffset = o;
545  }
546  void addBlock(const char* blockName) {
547  mBlocks.insert(blockName);
548  }
549  const std::string& start() const {
550  return mStart;
551  }
552  const std::string& end() const {
553  return mEnd;
554  }
555  int offset() const {
556  return mOffset;
557  }
558  bool isBlock(const std::string& blockName) const {
559  return mBlocks.find(blockName) != mBlocks.end();
560  }
561 
562  private:
563  std::string mStart;
564  std::string mEnd;
565  int mOffset{};
566  std::set<std::string> mBlocks;
567  };
568  enum class FalseTrueMaybe { False, True, Maybe };
569  int mAllocId{};
570  std::set<std::string> mFiles;
571  std::map<std::string, AllocFunc> mAlloc; // allocation functions
572  std::map<std::string, AllocFunc> mDealloc; // deallocation functions
573  std::map<std::string, AllocFunc> mRealloc; // reallocation functions
574  std::unordered_map<std::string, FalseTrueMaybe> mNoReturn; // is function noreturn?
575  std::map<std::string, std::string> mReturnValue;
576  std::map<std::string, std::string> mReturnValueType;
577  std::map<std::string, int> mReturnValueContainer;
578  std::map<std::string, std::vector<MathLib::bigint>> mUnknownReturnValues;
579  std::map<std::string, bool> mReportErrors;
580  std::map<std::string, bool> mProcessAfterCode;
581  std::set<std::string> mMarkupExtensions; // file extensions of markup files
582  std::map<std::string, std::set<std::string>> mKeywords; // keywords for code in the library
583  std::unordered_map<std::string, CodeBlock> mExecutableBlocks; // keywords for blocks of executable code
584  std::map<std::string, ExportedFunctions> mExporters; // keywords that export variables/functions to libraries (meta-code/macros)
585  std::map<std::string, std::set<std::string>> mImporters; // keywords that import variables/functions
586  std::map<std::string, int> mReflection; // invocation of reflection
587  std::unordered_map<std::string, PodType> mPodTypes; // pod types
588  std::map<std::string, PlatformType> mPlatformTypes; // platform independent typedefs
589  std::map<std::string, Platform> mPlatforms; // platform dependent typedefs
590  std::map<std::pair<std::string,std::string>, TypeCheck> mTypeChecks;
591  std::unordered_map<std::string, NonOverlappingData> mNonOverlappingData;
592  std::unordered_set<std::string> mEntrypoints;
593 
594  const ArgumentChecks * getarg(const Token *ftok, int argnr) const;
595 
596  std::string getFunctionName(const Token *ftok, bool &error) const;
597 
598  static const AllocFunc* getAllocDealloc(const std::map<std::string, AllocFunc> &data, const std::string &name) {
599  const std::map<std::string, AllocFunc>::const_iterator it = data.find(name);
600  return (it == data.end()) ? nullptr : &it->second;
601  }
602 
603  enum DetectContainer { ContainerOnly, IteratorOnly, Both };
604  const Library::Container* detectContainerInternal(const Token* typeStart, DetectContainer detect, bool* isIterator = nullptr, bool withoutStd = false) const;
605 };
606 
608 
609 std::shared_ptr<Token> createTokenFromExpression(const std::string& returnValue,
610  const Settings& settings,
611  bool cpp,
612  std::unordered_map<nonneg int, const Token*>* lookupVarId = nullptr);
613 
614 /// @}
615 //---------------------------------------------------------------------------
616 #endif // libraryH
static bool isIterator(const Variable *var, bool &inconclusiveType)
Definition: checkstl.cpp:419
static bool operator!=(const VariableValue &v, MathLib::bigint i)
void setStart(const char *s)
Definition: library.h:537
std::string mEnd
Definition: library.h:564
const std::string & end() const
Definition: library.h:552
int offset() const
Definition: library.h:555
void setOffset(const int o)
Definition: library.h:543
bool isBlock(const std::string &blockName) const
Definition: library.h:558
void addBlock(const char *blockName)
Definition: library.h:546
const std::string & start() const
Definition: library.h:549
std::set< std::string > mBlocks
Definition: library.h:566
void setEnd(const char *e)
Definition: library.h:540
std::string mStart
Definition: library.h:563
const std::string & getReturnType(const std::string &function) const
Definition: library.h:262
std::vector< RangeItemRecordTypeItem > rangeItemRecordType
Definition: library.h:237
std::map< std::string, Function > functions
Definition: library.h:235
Action getAction(const std::string &function) const
Definition: library.h:248
std::string endPattern
Definition: library.h:234
Yield getYield(const std::string &function) const
Definition: library.h:255
ErrorCode errorcode
Definition: library.h:74
Error(ErrorCode e)
Definition: library.h:71
Error(ErrorCode e, T &&r)
Definition: library.h:73
std::string reason
Definition: library.h:75
std::set< std::string > mSuffixes
Definition: library.h:531
bool isSuffix(const std::string &suffix) const
Definition: library.h:525
std::set< std::string > mPrefixes
Definition: library.h:530
void addSuffix(std::string suffix)
Definition: library.h:519
bool isPrefix(const std::string &prefix) const
Definition: library.h:522
void addPrefix(std::string prefix)
Definition: library.h:516
Library definitions handling.
Definition: library.h:52
const std::set< std::string > & markupExtensions() const
Definition: library.h:380
int allocId(const char name[]) const
get allocation id for function by name (deprecated, use other alloc)
Definition: library.h:125
std::map< std::string, AllocFunc > mAlloc
Definition: library.h:571
std::set< std::string > mFiles
Definition: library.h:570
static bool isresource(const int id)
is allocation type resource?
Definition: library.h:148
const AllocFunc * getDeallocFuncInfo(const char name[]) const
get deallocation info for function by name (deprecated, use other alloc)
Definition: library.h:118
std::map< std::string, std::vector< MathLib::bigint > > mUnknownReturnValues
Definition: library.h:578
const AllocFunc * getAllocFuncInfo(const char name[]) const
get allocation info for function by name (deprecated, use other alloc)
Definition: library.h:112
ErrorCode
Definition: library.h:62
const std::string & validarg(const Token *ftok, int argnr) const
Definition: library.h:357
std::map< std::string, std::set< std::string > > mKeywords
Definition: library.h:582
bool isexportedsuffix(const std::string &prefix, const std::string &token) const
Definition: library.h:406
std::map< std::string, std::set< std::string > > mImporters
Definition: library.h:585
std::map< std::pair< std::string, std::string >, TypeCheck > mTypeChecks
Definition: library.h:590
static bool ismemory(const int id)
is allocation type memory?
Definition: library.h:140
bool isexporter(const std::string &prefix) const
Definition: library.h:397
bool isentrypoint(const std::string &func) const
Definition: library.h:427
static const AllocFunc * getAllocDealloc(const std::map< std::string, AllocFunc > &data, const std::string &name)
Definition: library.h:598
bool isboolargbad(const Token *ftok, int argnr) const
Definition: library.h:336
std::map< std::string, ExportedFunctions > mExporters
Definition: library.h:584
bool isargformatstr(const Token *ftok, int argnr) const
Definition: library.h:344
UseRetValType
Definition: library.h:182
bool isreflection(const std::string &token) const
Definition: library.h:416
static bool isresource(const AllocFunc *const func)
Definition: library.h:151
DetectContainer
Definition: library.h:603
const std::vector< ArgumentChecks::MinSize > * argminsizes(const Token *ftok, int argnr) const
Definition: library.h:369
std::unordered_set< std::string > mEntrypoints
Definition: library.h:592
std::map< std::string, AllocFunc > mDealloc
Definition: library.h:572
static bool ismemory(const AllocFunc *const func)
Definition: library.h:143
std::set< std::string > mMarkupExtensions
Definition: library.h:581
bool isargstrz(const Token *ftok, int argnr) const
Definition: library.h:349
std::set< std::string > defines
Definition: library.h:431
TypeCheck
Suppress/check a type.
Definition: library.h:502
int deallocId(const char name[]) const
get deallocation id for function by name (deprecated, use other alloc)
Definition: library.h:132
std::map< std::string, std::string > mReturnValue
Definition: library.h:575
std::map< std::string, int > mReturnValueContainer
Definition: library.h:577
FalseTrueMaybe
Definition: library.h:568
const PodType * podtype(const std::string &name) const
Definition: library.h:447
std::map< std::string, bool > mProcessAfterCode
Definition: library.h:580
std::unordered_map< std::string, CodeBlock > mExecutableBlocks
Definition: library.h:583
std::map< std::string, bool > mReportErrors
Definition: library.h:579
std::map< std::string, std::string > mReturnValueType
Definition: library.h:576
std::map< std::string, PlatformType > mPlatformTypes
Definition: library.h:588
Library()=default
const ArgumentChecks::IteratorInfo * getArgIteratorInfo(const Token *ftok, int argnr) const
Definition: library.h:362
std::map< std::string, WarnInfo > functionwarn
Definition: library.h:174
std::unordered_map< std::string, Container > containers
Definition: library.h:270
std::unordered_map< std::string, SmartPointer > smartPointers
Definition: library.h:438
std::unordered_map< std::string, PodType > mPodTypes
Definition: library.h:587
std::unordered_map< std::string, NonOverlappingData > mNonOverlappingData
Definition: library.h:591
std::unordered_map< std::string, FalseTrueMaybe > mNoReturn
Definition: library.h:574
std::map< std::string, AllocFunc > mRealloc
Definition: library.h:573
bool isexportedprefix(const std::string &prefix, const std::string &token) const
Definition: library.h:401
std::unordered_map< std::string, Function > functions
Definition: library.h:330
const PlatformType * platform_type(const std::string &name, const std::string &platform) const
Definition: library.h:482
std::map< std::string, int > mReflection
Definition: library.h:586
int reflectionArgument(const std::string &token) const
Definition: library.h:420
std::map< std::string, Platform > mPlatforms
Definition: library.h:589
long long bigint
Definition: mathlib.h:68
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
Information about a class type.
static const std::string emptyString
Definition: config.h:127
#define CPPCHECKLIB
Definition: config.h:35
static CppcheckLibraryData::Function loadFunction(QXmlStreamReader &xmlReader, const QString &comments)
Severity
enum class for severity.
Definition: errortypes.h:63
std::shared_ptr< Token > createTokenFromExpression(const std::string &returnValue, const Settings &settings, bool cpp, std::unordered_map< nonneg int, const Token * > *lookupVarId=nullptr)
Definition: library.cpp:1748
CPPCHECKLIB const Library::Container * getLibraryContainer(const Token *tok)
Definition: library.cpp:1715
@ error
Programming error.
bool operator==(const QErrorPathItem &i1, const QErrorPathItem &i2)
Definition: erroritem.cpp:32
Definition: check.h:31
BufferSize bufferSize
Definition: library.h:85
std::vector< MinSize > minsizes
Definition: library.h:302
std::string valid
Definition: library.h:283
IteratorInfo iteratorInfo
Definition: library.h:291
std::string returnType
Definition: library.h:326
std::map< int, ArgumentChecks > argumentChecks
Definition: library.h:314
std::string mType
Definition: library.h:465
const PlatformType * platform_type(const std::string &name) const
Definition: library.h:475
std::map< std::string, PlatformType > mPlatformTypes
Definition: library.h:479
unsigned int size
Definition: library.h:443
std::string name
Definition: library.h:434
Standards standards
Definition: library.h:171
Severity severity
Definition: library.h:172
std::string message
Definition: library.h:170
This is just a container for standards settings.
Definition: standards.h:36
static const Function * getFunction(const Token *tok)