Cppcheck
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tokenize.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2016 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 tokenizeH
21 #define tokenizeH
22 //---------------------------------------------------------------------------
23 
24 #include "errorlogger.h"
25 #include "tokenlist.h"
26 #include "config.h"
27 
28 #include <string>
29 #include <map>
30 #include <set>
31 #include <list>
32 #include <ctime>
33 
34 class Settings;
35 class SymbolDatabase;
36 class TimerResults;
37 
38 /// @addtogroup Core
39 /// @{
40 
41 /** @brief The main purpose is to tokenize the source code. It also has functions that simplify the token list */
43 
44  friend class TestSimplifyTokens;
45  friend class TestSimplifyTypedef;
46  friend class TestTokenizer;
47 public:
48  Tokenizer();
49  Tokenizer(const Settings * settings, ErrorLogger *errorLogger);
50  ~Tokenizer();
51 
53  m_timerResults = tr;
54  }
55 
56  /** Is the code C. Used for bailouts */
57  bool isC() const {
58  return list.isC();
59  }
60 
61  /** Is the code CPP. Used for bailouts */
62  bool isCPP() const {
63  return list.isCPP();
64  }
65 
66  /**
67  * Check if inner scope ends with a call to a noreturn function
68  * \param endScopeToken The '}' token
69  * \param unknown set to true if it's unknown if the scope is noreturn
70  * \return true if scope ends with a function call that might be 'noreturn'
71  */
72  bool IsScopeNoReturn(const Token *endScopeToken, bool *unknown = nullptr) const;
73 
74  bool createTokens(std::istream &code,
75  const std::string& FileName);
76 
77  bool simplifyTokens1(const std::string &configuration);
78  /**
79  * Tokenize code
80  * @param code input stream for code, e.g.
81  * \code
82  * #file "p.h"
83  * class Foo
84  * {
85  * private:
86  * void Bar();
87  * };
88  *
89  * #endfile
90  * void Foo::Bar()
91  * {
92  * }
93  * \endcode
94  *
95  * @param FileName The filename
96  * @param configuration E.g. "A" for code where "#ifdef A" is true
97  * @param noSymbolDB_AST Disable creation of SymbolDatabase and AST
98  * @return false if source code contains syntax errors
99  */
100  bool tokenize(std::istream &code,
101  const char FileName[],
102  const std::string &configuration = emptyString);
103 
104  /** Set variable id */
105  void setVarId();
106  void setVarIdPass1();
107  void setVarIdPass2();
108 
109  /**
110  * Basic simplification of tokenlist
111  *
112  * @param FileName The filename to run; used to do
113  * markup checks.
114  *
115  * @return false if there is an error that requires aborting
116  * the checking of this file.
117  */
118  bool simplifyTokenList1(const char FileName[]);
119 
120  void SimplifyNamelessRValueReferences();
121 
122  /**
123  * Most aggressive simplification of tokenlist
124  *
125  * @return false if there is an error that requires aborting
126  * the checking of this file.
127  */
128  bool simplifyTokenList2();
129 
130  /**
131  * Deletes dead code between 'begin' and 'end'.
132  * In general not everything can be erased, such as:
133  * - code after labels;
134  * - code outside the scope where the function is called;
135  * - code after a change of scope caused by 'switch(...);'
136  * instructions, like 'case %any%;' or 'default;'
137  * Also, if the dead code contains a 'switch' block
138  * and inside it there's a label, the function removes all
139  * the 'switch(..)' tokens and every occurrence of 'case %any%; | default;'
140  * expression, such as the 'switch' block is reduced to a simple block.
141  *
142  * @param begin Tokens after this have a possibility to be erased.
143  * @param end Tokens before this have a possibility to be erased.
144  */
145  static void eraseDeadCode(Token *begin, const Token *end);
146 
147  /**
148  * Simplify '* & ( %name% ) =' or any combination of '* &' and '()'
149  * parentheses around '%name%' to '%name% ='
150  */
151  void simplifyMulAndParens();
152 
153  /**
154  * Calculates sizeof value for given type.
155  * @param type Token which will contain e.g. "int", "*", or string.
156  * @return sizeof for given type, or 0 if it can't be calculated.
157  */
158  unsigned int sizeOfType(const Token *type) const;
159 
160  /**
161  * Try to determine if function parameter is passed by value by looking
162  * at the function declaration.
163  * @param fpar token for function parameter in the function call
164  * @return true if the parameter is passed by value. if unsure, false is returned
165  */
166  bool isFunctionParameterPassedByValue(const Token *fpar) const;
167 
168  /** Simplify assignment in function call "f(x=g());" => "x=g();f(x);"
169  */
170  void simplifyAssignmentInFunctionCall();
171 
172  /** Simplify assignment where rhs is a block : "x=({123;});" => "{x=123;}" */
173  void simplifyAssignmentBlock();
174 
175  /**
176  * Simplify constant calculations such as "1+2" => "3"
177  * @return true if modifications to token-list are done.
178  * false if no modifications are done.
179  */
180  bool simplifyCalculations();
181 
182  /**
183  * Simplify dereferencing a pointer offset by a number:
184  * "*(ptr + num)" => "ptr[num]"
185  * "*(ptr - num)" => "ptr[-num]"
186  */
187  void simplifyOffsetPointerDereference();
188 
189  /**
190  * Simplify referencing a pointer offset:
191  * "Replace "&str[num]" => "(str + num)"
192  */
193  void simplifyOffsetPointerReference();
194 
195  /** Insert array size where it isn't given */
196  void arraySize();
197 
198  /** Simplify labels and 'case|default' syntaxes.
199  */
200  void simplifyLabelsCaseDefault();
201 
202  /** simplify case ranges (gcc extension)
203  */
204  void simplifyCaseRange();
205 
206  /** Remove macros in global scope */
207  void removeMacrosInGlobalScope();
208 
209  /** Remove undefined macro in class definition:
210  * class DLLEXPORT Fred { };
211  * class Fred FINAL : Base { };
212  */
213  void removeMacroInClassDef();
214 
215  /** Remove unknown macro in variable declarations: PROGMEM char x; */
216  void removeMacroInVarDecl();
217 
218  /** Remove redundant assignment */
219  void removeRedundantAssignment();
220 
221  /** Simplifies some realloc usage like
222  * 'x = realloc (0, n);' => 'x = malloc(n);'
223  * 'x = realloc (y, 0);' => 'x = 0; free(y);'
224  */
225  void simplifyRealloc();
226 
227  /** Add parentheses for sizeof: sizeof x => sizeof(x) */
228  void sizeofAddParentheses();
229 
230  /**
231  * Replace sizeof() to appropriate size.
232  * @return true if modifications to token-list are done.
233  * false if no modifications are done.
234  */
235  bool simplifySizeof();
236 
237  /**
238  * Simplify variable declarations (split up)
239  * \param only_k_r_fpar Only simplify K&R function parameters
240  */
241  void simplifyVarDecl(bool only_k_r_fpar);
242  void simplifyVarDecl(Token * tokBegin, Token * tokEnd, bool only_k_r_fpar);
243 
244  /**
245  * Simplify variable initialization
246  * '; int *p(0);' => '; int *p = 0;'
247  */
248  void simplifyInitVar();
249  Token * initVar(Token * tok);
250 
251  /**
252  * Convert platform dependent types to standard types.
253  * 32 bits: size_t -> unsigned long
254  * 64 bits: size_t -> unsigned long long
255  */
256  void simplifyPlatformTypes();
257 
258  /**
259  * Collapse compound standard types into a single token.
260  * unsigned long long int => long _isUnsigned=true,_isLong=true
261  */
262  void simplifyStdType();
263 
264  /**
265  * Simplify easy constant '?:' operation
266  * Example: 0 ? (2/0) : 0 => 0
267  * @return true if something is modified
268  * false if nothing is done.
269  */
270  bool simplifyConstTernaryOp();
271 
272  /**
273  * Simplify compound assignments
274  * Example: ";a+=b;" => ";a=a+b;"
275  */
276  void simplifyCompoundAssignment();
277 
278  /**
279  * Simplify the location of "static" and "const" qualifiers in
280  * a variable declaration or definition.
281  * Example: "int static const a;" => "static const a;"
282  * Example: "long long const static b;" => "static const long long b;"
283  */
284  void simplifyStaticConst();
285 
286  /**
287  * Simplify assignments in "if" and "while" conditions
288  * Example: "if(a=b);" => "a=b;if(a);"
289  * Example: "while(a=b) { f(a); }" => "a = b; while(a){ f(a); a = b; }"
290  * Example: "do { f(a); } while(a=b);" => "do { f(a); a = b; } while(a);"
291  */
292  void simplifyIfAndWhileAssign();
293 
294  /**
295  * Simplify multiple assignments.
296  * Example: "a = b = c = 0;" => "a = 0; b = 0; c = 0;"
297  */
298  void simplifyVariableMultipleAssign();
299 
300  /**
301  * Simplify the 'C Alternative Tokens'
302  * Examples:
303  * "if(s and t)" => "if(s && t)"
304  * "while((r bitand s) and not t)" => while((r & s) && !t)"
305  * "a and_eq b;" => "a &= b;"
306  */
307  bool simplifyCAlternativeTokens();
308 
309  /**
310  * Simplify comma into a semicolon when possible:
311  * - "delete a, delete b" => "delete a; delete b;"
312  * - "a = 0, b = 0;" => "a = 0; b = 0;"
313  * - "return a(), b;" => "a(); return b;"
314  */
315  void simplifyComma();
316 
317  /** Add braces to an if-block, for-block, etc.
318  * @return true if no syntax errors
319  */
320  bool simplifyAddBraces();
321 
322  /** Add braces to an if-block, for-block, etc.
323  * for command starting at token including else-block
324  * @return last token of command
325  * or input token in case of an error where no braces are added
326  * or NULL when syntaxError is called
327  */
328  Token * simplifyAddBracesToCommand(Token * tok);
329 
330  /** Add pair of braces to an single if-block, else-block, for-block, etc.
331  * for command starting at token
332  * @return last token of command
333  * or input token in case of an error where no braces are added
334  * or NULL when syntaxError is called
335  */
336  Token * simplifyAddBracesPair(Token *tok, bool commandWithCondition);
337 
338  /**
339  * typedef A mytype;
340  * mytype c;
341  *
342  * Becomes:
343  * typedef A mytype;
344  * A c;
345  */
346  void simplifyTypedef();
347 
348  /**
349  * Simplify casts
350  */
351  void simplifyCasts();
352 
353  /**
354  * Change (multiple) arrays to (multiple) pointers.
355  */
356  void simplifyUndefinedSizeArray();
357 
358  /**
359  * A simplify function that replaces a variable with its value in cases
360  * when the value is known. e.g. "x=10; if(x)" => "x=10;if(10)"
361  *
362  * @return true if modifications to token-list are done.
363  * false if no modifications are done.
364  */
365  bool simplifyKnownVariables();
366 
367  /**
368  * Utility function for simplifyKnownVariables. Get data about an
369  * assigned variable.
370  */
371  static bool simplifyKnownVariablesGetData(unsigned int varid, Token **_tok2, Token **_tok3, std::string &value, unsigned int &valueVarId, bool &valueIsPointer, bool floatvar);
372 
373  /**
374  * utility function for simplifyKnownVariables. Perform simplification
375  * of a given variable
376  */
377  bool simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsigned int varid, const std::string &structname, std::string &value, unsigned int valueVarId, bool valueIsPointer, const Token * const valueToken, int indentlevel) const;
378 
379  /** Simplify useless C++ empty namespaces, like: 'namespace %name% { }'*/
380  void simplifyEmptyNamespaces();
381 
382  /** Simplify redundant code placed after control flow statements :
383  * 'return', 'throw', 'goto', 'break' and 'continue'
384  */
385  void simplifyFlowControl();
386 
387  /** Expand nested strcat() calls. */
388  void simplifyNestedStrcat();
389 
390  /** Simplify "if else" */
391  void elseif();
392 
393  /** Simplify conditions
394  * @return true if something is modified
395  * false if nothing is done.
396  */
397  bool simplifyConditions();
398 
399  /** Remove redundant code, e.g. if( false ) { int a; } should be
400  * removed, because it is never executed.
401  * @return true if something is modified
402  * false if nothing is done.
403  */
404  bool removeRedundantConditions();
405 
406  /**
407  * Remove redundant for:
408  * "for (x=0;x<1;x++) { }" => "{ x = 1; }"
409  */
410  void removeRedundantFor();
411 
412 
413  /**
414  * Reduces "; ;" to ";", except in "( ; ; )"
415  */
416  void removeRedundantSemicolons();
417 
418  /** Simplify function calls - constant return value
419  * @return true if something is modified
420  * false if nothing is done.
421  */
422  bool simplifyFunctionReturn();
423 
424  /** Struct simplification
425  * "struct S { } s;" => "struct S { }; S s;"
426  */
427 
428  void simplifyStructDecl();
429 
430  /**
431  * Remove redundant parentheses:
432  * - "((x))" => "(x)"
433  * - "(function())" => "function()"
434  * - "(delete x)" => "delete x"
435  * - "(delete [] x)" => "delete [] x"
436  * @return true if modifications to token-list are done.
437  * false if no modifications are done.
438  */
439  bool simplifyRedundantParentheses();
440 
441  void simplifyCharAt();
442 
443  /** Simplify references */
444  void simplifyReference();
445 
446  /**
447  * Simplify functions like "void f(x) int x; {"
448  * into "void f(int x) {"
449  */
450  void simplifyFunctionParameters();
451 
452  /**
453  * Simplify templates
454  */
455  void simplifyTemplates();
456 
457  void simplifyDoublePlusAndDoubleMinus();
458 
459  void simplifyRedundantConsecutiveBraces();
460 
461  void simplifyArrayAccessSyntax();
462 
463  void simplifyParameterVoid();
464 
465  void fillTypeSizes();
466 
467  void combineOperators();
468 
469  void combineStrings();
470 
471  void simplifyNull();
472 
473  void concatenateNegativeNumberAndAnyPositive();
474 
475  void simplifyExternC();
476 
477  void simplifyRoundCurlyParentheses();
478 
479  void simplifySQL();
480 
481  void checkForEnumsWithTypedef();
482 
483  void findComplicatedSyntaxErrorsInTemplates();
484 
485  /**
486  * Simplify e.g. 'atol("0")' into '0'
487  */
488  void simplifyMathFunctions();
489 
490  /**
491  * Simplify e.g. 'sin(0)' into '0'
492  */
493  void simplifyMathExpressions();
494 
495  /**
496  * Modify strings in the token list by replacing hex and oct
497  * values. E.g. "\x61" -> "a" and "\000" -> "\0"
498  * @param source The string to be modified, e.g. "\x61"
499  * @return Modified string, e.g. "a"
500  */
501  static std::string simplifyString(const std::string &source);
502 
503  /**
504  * is token pointing at function head?
505  * @param tok A '(' or ')' token in a possible function head
506  * @param endsWith string after function head
507  * @return token matching with endsWith if syntax seems to be a function head else nullptr
508  */
509  const Token * isFunctionHead(const Token *tok, const std::string &endsWith) const;
510 
511 private:
512 
513  /**
514  * is token pointing at function head?
515  * @param tok A '(' or ')' token in a possible function head
516  * @param endsWith string after function head
517  * @param cpp c++ code
518  * @return token matching with endsWith if syntax seems to be a function head else nullptr
519  */
520  static const Token * isFunctionHead(const Token *tok, const std::string &endsWith, bool cpp);
521 
522  /**
523  * simplify "while (0)"
524  */
525  void simplifyWhile0();
526 
527  /**
528  * Simplify while(func() && errno==EINTR)
529  */
530  void simplifyErrNoInWhile();
531 
532  /**
533  * Simplify while(func(f))
534  */
535  void simplifyFuncInWhile();
536 
537  /**
538  * Remove "std::" before some function names
539  */
540  void simplifyStd();
541 
542  /** Simplify pointer to standard type (C only) */
543  void simplifyPointerToStandardType();
544 
545  /** Simplify function pointers */
546  void simplifyFunctionPointers();
547 
548  /**
549  * Send error message to error logger about internal bug.
550  * @param tok the token that this bug concerns.
551  */
552  void cppcheckError(const Token *tok) const;
553 
554  /**
555  * Setup links for tokens so that one can call Token::link().
556  */
557  void createLinks();
558 
559  /**
560  * Setup links between < and >.
561  */
562  void createLinks2();
563 
564 public:
565 
566  /** Syntax error */
567  void syntaxError(const Token *tok) const;
568 
569  /** Syntax error. Example: invalid number of ')' */
570  void syntaxError(const Token *tok, char c) const;
571 
572 private:
573 
574  /** Report that there is an unhandled "class x y {" code */
575  void unhandled_macro_class_x_y(const Token *tok) const;
576 
577  /**
578  * assert that tokens are ok - used during debugging for example
579  * to catch problems in simplifyTokenList1/2.
580  */
581  void validate() const;
582 
583  /** Detect garbage code */
584  const Token * findGarbageCode() const;
585 
586  /** Detect garbage expression */
587  bool isGarbageExpr(const Token *start, const Token *end) const;
588 
589  /**
590  * Remove __declspec()
591  */
592  void simplifyDeclspec();
593 
594  /**
595  * Remove calling convention
596  */
597  void simplifyCallingConvention();
598 
599  /**
600  * Remove __attribute__ ((?))
601  */
602  void simplifyAttribute();
603 
604  /**
605  * Remove keywords "volatile", "inline", "register", and "restrict"
606  */
607  void simplifyKeyword();
608 
609  /**
610  * Remove __asm
611  */
612  void simplifyAsm();
613 
614  /**
615  * asm heuristics, Put ^{} statements in asm()
616  */
617  void simplifyAsm2();
618 
619  /**
620  * Simplify bitfields - the field width is removed as we don't use it.
621  */
622  void simplifyBitfields();
623 
624  /**
625  * Remove unnecessary member qualification
626  */
627  void removeUnnecessaryQualification();
628 
629  /**
630  * Add std:: in front of std classes, when using namespace std; was given
631  */
632  void simplifyNamespaceStd();
633 
634  /**
635  * Convert Microsoft memory functions
636  * CopyMemory(dst, src, len) -> memcpy(dst, src, len)
637  * FillMemory(dst, len, val) -> memset(dst, val, len)
638  * MoveMemory(dst, src, len) -> memmove(dst, src, len)
639  * ZeroMemory(dst, len) -> memset(dst, 0, len)
640  */
641  void simplifyMicrosoftMemoryFunctions();
642 
643  /**
644  * Convert Microsoft string functions
645  * _tcscpy -> strcpy
646  */
647  void simplifyMicrosoftStringFunctions();
648 
649  /**
650  * Remove Borland code
651  */
652  void simplifyBorland();
653 
654  /**
655  * Remove Qt signals and slots
656  */
657  void simplifyQtSignalsSlots();
658 
659  /**
660  * Collapse operator name tokens into single token
661  * operator = => operator=
662  */
663  void simplifyOperatorName();
664 
665  /**
666  * Remove [[deprecated]] (C++14) from TokenList
667  */
668  void simplifyDeprecated();
669 
670  /**
671  * Replace strlen(str)
672  * @return true if any replacement took place, false else
673  * */
674  bool simplifyStrlen();
675 
676  /**
677  * Prepare ternary operators with parentheses so that the AST can be created
678  * */
679  void prepareTernaryOpForAST();
680 
681  /**
682  * check for duplicate enum definition
683  */
684  bool duplicateDefinition(Token **tokPtr) const;
685 
686  /**
687  * report error message
688  */
689  void reportError(const Token* tok, const Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const;
690  void reportError(const std::list<const Token*>& callstack, Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const;
691 
692  bool duplicateTypedef(Token **tokPtr, const Token *name, const Token *typeDef) const;
693 
694  void unsupportedTypedef(const Token *tok) const;
695 
696  void setVarIdClassDeclaration(Token * const startToken,
697  const std::map<std::string, unsigned int> &variableId,
698  const unsigned int scopeStartVarId,
699  std::map<unsigned int, std::map<std::string,unsigned int> >& structMembers);
700 
701 
702  /**
703  * Simplify e.g. 'return(strncat(temp,"a",1));' into
704  * strncat(temp,"a",1); return temp;
705  */
706  void simplifyReturnStrncat();
707 
708  /**
709  * Output list of unknown types.
710  */
711  void printUnknownTypes() const;
712 
713 public:
714 
715  /** Was there templates in the code? */
716  bool codeWithTemplates() const {
717  return _codeWithTemplates;
718  }
719 
720 
721  void setSettings(const Settings *settings) {
722  _settings = settings;
723  list.setSettings(settings);
724  }
725 
727  return _symbolDatabase;
728  }
729  void createSymbolDatabase();
730  void deleteSymbolDatabase();
731 
732  /** print --debug output if debug flags match the simplification:
733  * 0=unknown/both simplifications
734  * 1=1st simplifications
735  * 2=2nd simplifications
736  */
737  void printDebugOutput(unsigned int simplification) const;
738 
739  void dump(std::ostream &out) const;
740 
741  Token *deleteInvalidTypedef(Token *typeDef);
742 
743  /**
744  * Get variable count.
745  * @return number of variables
746  */
747  unsigned int varIdCount() const {
748  return _varId;
749  }
750 
751  /**
752  * Token list: stores all tokens.
753  */
755  // Implement tokens() as a wrapper for convinience when using the TokenList
756  const Token* tokens() const {
757  return list.front();
758  }
759 
760  /**
761  * Copy tokens.
762  * @param dest destination token where copied tokens will be inserted after
763  * @param first first token to copy
764  * @param last last token to copy
765  * @param one_line true=>copy all tokens to the same line as dest. false=>copy all tokens to dest while keeping the 'line breaks'
766  * @return new location of last token copied
767  */
768  static Token *copyTokens(Token *dest, const Token *first, const Token *last, bool one_line = true);
769 
770  /**
771  * Helper function to check whether number is zero (0 or 0.0 or 0E+0) or not?
772  * @param s the string to check
773  * @return true in case is is zero and false otherwise.
774  */
775  static bool isZeroNumber(const std::string &s);
776 
777  /**
778  * Helper function to check whether number is one (1 or 0.1E+1 or 1E+0) or not?
779  * @param s the string to check
780  * @return true in case is is one and false otherwise.
781  */
782  static bool isOneNumber(const std::string &s);
783 
784  /**
785  * Helper function to check whether number is two (2 or 0.2E+1 or 2E+0) or not?
786  * @param s the string to check
787  * @return true in case is is two and false otherwise.
788  */
789  static bool isTwoNumber(const std::string &s);
790 
791  /**
792  * Helper function to check for start of function execution scope.
793  * Do not use this in checks. Use the symbol database.
794  * @param tok pointer to end parentheses of parameter list
795  * @return pointer to start brace of function scope or nullptr if not start.
796  */
797  static const Token * startOfExecutableScope(const Token * tok);
798 
799  bool isMaxTime() const {
800 #ifdef MAXTIME
801  return (std::time(0) > maxtime);
802 #else
803  return false;
804 #endif
805  }
806 
807 private:
808  /** Disable copy constructor, no implementation */
809  Tokenizer(const Tokenizer &);
810 
811  /** Disable assignment operator, no implementation */
812  Tokenizer &operator=(const Tokenizer &);
813 
814  Token *processFunc(Token *tok2, bool inOperator) const;
815 
816  /** Set pod types */
817  void setPodTypes();
818 
819  /** settings */
821 
822  /** errorlogger */
824 
825  /** Symbol database that all checks etc can use */
827 
828  /** E.g. "A" for code where "#ifdef A" is true. This is used to
829  print additional information in error situations. */
830  std::string _configuration;
831 
832  /** sizeof information for known types */
833  std::map<std::string, unsigned int> _typeSize;
834 
835  /** variable count */
836  unsigned int _varId;
837 
838  /**
839  * was there any templates? templates that are "unused" are
840  * removed from the token list
841  */
843 
844  /**
845  * TimerResults
846  */
848 
849 #ifdef MAXTIME
850  /** Tokenizer maxtime */
851  std::time_t maxtime;
852 #endif
853 };
854 
855 /// @}
856 
857 //---------------------------------------------------------------------------
858 #endif // tokenizeH
bool isMaxTime() const
Definition: tokenize.h:799
bool isCPP() const
Is the code CPP.
Definition: tokenize.h:62
TimerResults * m_timerResults
TimerResults.
Definition: tokenize.h:847
std::string _configuration
E.g.
Definition: tokenize.h:830
ErrorLogger *const _errorLogger
errorlogger
Definition: tokenize.h:823
The main purpose is to tokenize the source code.
Definition: tokenize.h:42
SymbolDatabase * _symbolDatabase
Symbol database that all checks etc can use.
Definition: tokenize.h:826
#define CPPCHECKLIB
Definition: config.h:13
bool _codeWithTemplates
was there any templates? templates that are "unused" are removed from the token list ...
Definition: tokenize.h:842
void setTimerResults(TimerResults *tr)
Definition: tokenize.h:52
bool isC() const
Is the code C.
Definition: tokenize.h:57
const Settings * _settings
settings
Definition: tokenize.h:820
std::map< std::string, unsigned int > _typeSize
sizeof information for known types
Definition: tokenize.h:833
static const std::string emptyString
Definition: config.h:23
This is an interface, which the class responsible of error logging should implement.
Definition: errorlogger.h:162
This is just a container for general settings so that we don't need to pass individual values to func...
Definition: settings.h:45
SeverityType
Message severities.
Definition: errorlogger.h:62
const Token * tokens() const
Definition: tokenize.h:756
const Token * front() const
get first token of list
Definition: tokenlist.h:89
bool codeWithTemplates() const
Was there templates in the code?
Definition: tokenize.h:716
const SymbolDatabase * getSymbolDatabase() const
Definition: tokenize.h:726
void setSettings(const Settings *settings)
Definition: tokenize.h:721
The token list that the TokenList generates is a linked-list of this class.
Definition: token.h:53
TokenList list
Token list: stores all tokens.
Definition: tokenize.h:754
unsigned int varIdCount() const
Get variable count.
Definition: tokenize.h:747
unsigned int _varId
variable count
Definition: tokenize.h:836