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  static bool isContainerYield(const Token* const cond, Library::Container::Yield y, const std::string& fallback = emptyString);
417  static Library::Container::Yield getContainerYield(const Token* const cond);
418 
419  bool isreflection(const std::string &token) const {
420  return mReflection.find(token) != mReflection.end();
421  }
422 
423  int reflectionArgument(const std::string &token) const {
424  const std::map<std::string, int>::const_iterator it = mReflection.find(token);
425  if (it != mReflection.end())
426  return it->second;
427  return -1;
428  }
429 
430  bool isentrypoint(const std::string &func) const {
431  return func == "main" || mEntrypoints.find(func) != mEntrypoints.end();
432  }
433 
434  std::set<std::string> defines; // to provide some library defines
435 
436  struct SmartPointer {
437  std::string name;
438  bool unique = false;
439  };
440 
441  std::unordered_map<std::string, SmartPointer> smartPointers;
442  bool isSmartPointer(const Token *tok) const;
443  const SmartPointer* detectSmartPointer(const Token* tok, bool withoutStd = false) const;
444 
445  struct PodType {
446  unsigned int size;
447  char sign;
448  enum class Type { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype;
449  };
450  const PodType *podtype(const std::string &name) const {
451  const std::unordered_map<std::string, PodType>::const_iterator it = mPodTypes.find(name);
452  return (it != mPodTypes.end()) ? &(it->second) : nullptr;
453  }
454 
455  struct PlatformType {
456  bool operator == (const PlatformType & type) const {
457  return (mSigned == type.mSigned &&
458  mUnsigned == type.mUnsigned &&
459  mLong == type.mLong &&
460  mPointer == type.mPointer &&
461  mPtrPtr == type.mPtrPtr &&
462  mConstPtr == type.mConstPtr &&
463  mType == type.mType);
464  }
465  bool operator != (const PlatformType & type) const {
466  return !(*this == type);
467  }
468  std::string mType;
469  bool mSigned{};
470  bool mUnsigned{};
471  bool mLong{};
472  bool mPointer{};
473  bool mPtrPtr{};
474  bool mConstPtr{};
475  };
476 
477  struct Platform {
478  const PlatformType *platform_type(const std::string &name) const {
479  const std::map<std::string, PlatformType>::const_iterator it = mPlatformTypes.find(name);
480  return (it != mPlatformTypes.end()) ? &(it->second) : nullptr;
481  }
482  std::map<std::string, PlatformType> mPlatformTypes;
483  };
484 
485  const PlatformType *platform_type(const std::string &name, const std::string & platform) const {
486  const std::map<std::string, Platform>::const_iterator it = mPlatforms.find(platform);
487  if (it != mPlatforms.end()) {
488  const PlatformType * const type = it->second.platform_type(name);
489  if (type)
490  return type;
491  }
492 
493  const std::map<std::string, PlatformType>::const_iterator it2 = mPlatformTypes.find(name);
494  return (it2 != mPlatformTypes.end()) ? &(it2->second) : nullptr;
495  }
496 
497  /**
498  * Get function name for function call
499  */
500  std::string getFunctionName(const Token *ftok) const;
501 
502  /** Suppress/check a type */
503  enum class TypeCheck { def,
504  check,
505  suppress,
506  checkFiniteLifetime, // (unusedvar) object has side effects, but immediate destruction is wrong
507  };
508  TypeCheck getTypeCheck(std::string check, std::string typeName) const;
509  bool hasAnyTypeCheck(const std::string& typeName) const;
510 
511 private:
512  // load a <function> xml node
513  Error loadFunction(const tinyxml2::XMLElement * const node, const std::string &name, std::set<std::string> &unknown_elements);
514 
516  public:
517  void addPrefix(std::string prefix) {
518  mPrefixes.insert(std::move(prefix));
519  }
520  void addSuffix(std::string suffix) {
521  mSuffixes.insert(std::move(suffix));
522  }
523  bool isPrefix(const std::string& prefix) const {
524  return (mPrefixes.find(prefix) != mPrefixes.end());
525  }
526  bool isSuffix(const std::string& suffix) const {
527  return (mSuffixes.find(suffix) != mSuffixes.end());
528  }
529 
530  private:
531  std::set<std::string> mPrefixes;
532  std::set<std::string> mSuffixes;
533  };
534  class CodeBlock {
535  public:
536  CodeBlock() = default;
537 
538  void setStart(const char* s) {
539  mStart = s;
540  }
541  void setEnd(const char* e) {
542  mEnd = e;
543  }
544  void setOffset(const int o) {
545  mOffset = o;
546  }
547  void addBlock(const char* blockName) {
548  mBlocks.insert(blockName);
549  }
550  const std::string& start() const {
551  return mStart;
552  }
553  const std::string& end() const {
554  return mEnd;
555  }
556  int offset() const {
557  return mOffset;
558  }
559  bool isBlock(const std::string& blockName) const {
560  return mBlocks.find(blockName) != mBlocks.end();
561  }
562 
563  private:
564  std::string mStart;
565  std::string mEnd;
566  int mOffset{};
567  std::set<std::string> mBlocks;
568  };
569  enum class FalseTrueMaybe { False, True, Maybe };
570  int mAllocId{};
571  std::set<std::string> mFiles;
572  std::map<std::string, AllocFunc> mAlloc; // allocation functions
573  std::map<std::string, AllocFunc> mDealloc; // deallocation functions
574  std::map<std::string, AllocFunc> mRealloc; // reallocation functions
575  std::unordered_map<std::string, FalseTrueMaybe> mNoReturn; // is function noreturn?
576  std::map<std::string, std::string> mReturnValue;
577  std::map<std::string, std::string> mReturnValueType;
578  std::map<std::string, int> mReturnValueContainer;
579  std::map<std::string, std::vector<MathLib::bigint>> mUnknownReturnValues;
580  std::map<std::string, bool> mReportErrors;
581  std::map<std::string, bool> mProcessAfterCode;
582  std::set<std::string> mMarkupExtensions; // file extensions of markup files
583  std::map<std::string, std::set<std::string>> mKeywords; // keywords for code in the library
584  std::unordered_map<std::string, CodeBlock> mExecutableBlocks; // keywords for blocks of executable code
585  std::map<std::string, ExportedFunctions> mExporters; // keywords that export variables/functions to libraries (meta-code/macros)
586  std::map<std::string, std::set<std::string>> mImporters; // keywords that import variables/functions
587  std::map<std::string, int> mReflection; // invocation of reflection
588  std::unordered_map<std::string, PodType> mPodTypes; // pod types
589  std::map<std::string, PlatformType> mPlatformTypes; // platform independent typedefs
590  std::map<std::string, Platform> mPlatforms; // platform dependent typedefs
591  std::map<std::pair<std::string,std::string>, TypeCheck> mTypeChecks;
592  std::unordered_map<std::string, NonOverlappingData> mNonOverlappingData;
593  std::unordered_set<std::string> mEntrypoints;
594 
595  const ArgumentChecks * getarg(const Token *ftok, int argnr) const;
596 
597  std::string getFunctionName(const Token *ftok, bool &error) const;
598 
599  static const AllocFunc* getAllocDealloc(const std::map<std::string, AllocFunc> &data, const std::string &name) {
600  const std::map<std::string, AllocFunc>::const_iterator it = data.find(name);
601  return (it == data.end()) ? nullptr : &it->second;
602  }
603 
604  enum DetectContainer { ContainerOnly, IteratorOnly, Both };
605  const Library::Container* detectContainerInternal(const Token* typeStart, DetectContainer detect, bool* isIterator = nullptr, bool withoutStd = false) const;
606 };
607 
609 
610 std::shared_ptr<Token> createTokenFromExpression(const std::string& returnValue,
611  const Settings& settings,
612  bool cpp,
613  std::unordered_map<nonneg int, const Token*>* lookupVarId = nullptr);
614 
615 /// @}
616 //---------------------------------------------------------------------------
617 #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:538
std::string mEnd
Definition: library.h:565
const std::string & end() const
Definition: library.h:553
int offset() const
Definition: library.h:556
void setOffset(const int o)
Definition: library.h:544
bool isBlock(const std::string &blockName) const
Definition: library.h:559
void addBlock(const char *blockName)
Definition: library.h:547
const std::string & start() const
Definition: library.h:550
std::set< std::string > mBlocks
Definition: library.h:567
void setEnd(const char *e)
Definition: library.h:541
std::string mStart
Definition: library.h:564
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:532
bool isSuffix(const std::string &suffix) const
Definition: library.h:526
std::set< std::string > mPrefixes
Definition: library.h:531
void addSuffix(std::string suffix)
Definition: library.h:520
bool isPrefix(const std::string &prefix) const
Definition: library.h:523
void addPrefix(std::string prefix)
Definition: library.h:517
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:572
std::set< std::string > mFiles
Definition: library.h:571
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:579
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:583
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:586
std::map< std::pair< std::string, std::string >, TypeCheck > mTypeChecks
Definition: library.h:591
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:430
static const AllocFunc * getAllocDealloc(const std::map< std::string, AllocFunc > &data, const std::string &name)
Definition: library.h:599
bool isboolargbad(const Token *ftok, int argnr) const
Definition: library.h:336
std::map< std::string, ExportedFunctions > mExporters
Definition: library.h:585
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:419
static bool isresource(const AllocFunc *const func)
Definition: library.h:151
DetectContainer
Definition: library.h:604
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:593
std::map< std::string, AllocFunc > mDealloc
Definition: library.h:573
static bool ismemory(const AllocFunc *const func)
Definition: library.h:143
std::set< std::string > mMarkupExtensions
Definition: library.h:582
bool isargstrz(const Token *ftok, int argnr) const
Definition: library.h:349
std::set< std::string > defines
Definition: library.h:434
TypeCheck
Suppress/check a type.
Definition: library.h:503
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:576
std::map< std::string, int > mReturnValueContainer
Definition: library.h:578
FalseTrueMaybe
Definition: library.h:569
const PodType * podtype(const std::string &name) const
Definition: library.h:450
std::map< std::string, bool > mProcessAfterCode
Definition: library.h:581
std::unordered_map< std::string, CodeBlock > mExecutableBlocks
Definition: library.h:584
std::map< std::string, bool > mReportErrors
Definition: library.h:580
std::map< std::string, std::string > mReturnValueType
Definition: library.h:577
std::map< std::string, PlatformType > mPlatformTypes
Definition: library.h:589
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:441
std::unordered_map< std::string, PodType > mPodTypes
Definition: library.h:588
std::unordered_map< std::string, NonOverlappingData > mNonOverlappingData
Definition: library.h:592
std::unordered_map< std::string, FalseTrueMaybe > mNoReturn
Definition: library.h:575
std::map< std::string, AllocFunc > mRealloc
Definition: library.h:574
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:485
std::map< std::string, int > mReflection
Definition: library.h:587
int reflectionArgument(const std::string &token) const
Definition: library.h:423
std::map< std::string, Platform > mPlatforms
Definition: library.h:590
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:1764
CPPCHECKLIB const Library::Container * getLibraryContainer(const Token *tok)
Definition: library.cpp:1731
@ 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:468
const PlatformType * platform_type(const std::string &name) const
Definition: library.h:478
std::map< std::string, PlatformType > mPlatformTypes
Definition: library.h:482
unsigned int size
Definition: library.h:446
std::string name
Definition: library.h:437
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)
static Library::Container::Yield getContainerYield(Token *tok, const Settings &settings, Token **parent=nullptr)
Definition: valueflow.cpp:514