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(const bool only_k_r_fpar);
242  void simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, const 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 combineStringAndCharLiterals();
470 
471  void concatenateNegativeNumberAndAnyPositive();
472 
473  void simplifyExternC();
474 
475  void simplifyRoundCurlyParentheses();
476 
477  void simplifySQL();
478 
479  void checkForEnumsWithTypedef();
480 
481  void findComplicatedSyntaxErrorsInTemplates();
482 
483  /**
484  * Simplify e.g. 'atol("0")' into '0'
485  */
486  void simplifyMathFunctions();
487 
488  /**
489  * Simplify e.g. 'sin(0)' into '0'
490  */
491  void simplifyMathExpressions();
492 
493  /**
494  * Modify strings in the token list by replacing hex and oct
495  * values. E.g. "\x61" -> "a" and "\000" -> "\0"
496  * @param source The string to be modified, e.g. "\x61"
497  * @return Modified string, e.g. "a"
498  */
499  static std::string simplifyString(const std::string &source);
500 
501  /**
502  * is token pointing at function head?
503  * @param tok A '(' or ')' token in a possible function head
504  * @param endsWith string after function head
505  * @return token matching with endsWith if syntax seems to be a function head else nullptr
506  */
507  const Token * isFunctionHead(const Token *tok, const std::string &endsWith) const;
508 
509 private:
510 
511  /**
512  * is token pointing at function head?
513  * @param tok A '(' or ')' token in a possible function head
514  * @param endsWith string after function head
515  * @param cpp c++ code
516  * @return token matching with endsWith if syntax seems to be a function head else nullptr
517  */
518  static const Token * isFunctionHead(const Token *tok, const std::string &endsWith, bool cpp);
519 
520  /**
521  * simplify "while (0)"
522  */
523  void simplifyWhile0();
524 
525  /**
526  * Simplify while(func() && errno==EINTR)
527  */
528  void simplifyErrNoInWhile();
529 
530  /**
531  * Simplify while(func(f))
532  */
533  void simplifyFuncInWhile();
534 
535  /**
536  * Remove "std::" before some function names
537  */
538  void simplifyStd();
539 
540  /** Simplify pointer to standard type (C only) */
541  void simplifyPointerToStandardType();
542 
543  /** Simplify function pointers */
544  void simplifyFunctionPointers();
545 
546  /**
547  * Send error message to error logger about internal bug.
548  * @param tok the token that this bug concerns.
549  */
550  void cppcheckError(const Token *tok) const;
551 
552  /**
553  * Setup links for tokens so that one can call Token::link().
554  */
555  void createLinks();
556 
557  /**
558  * Setup links between < and >.
559  */
560  void createLinks2();
561 
562 public:
563 
564  /** Syntax error */
565  void syntaxError(const Token *tok) const;
566 
567  /** Syntax error. Example: invalid number of ')' */
568  void syntaxError(const Token *tok, char c) const;
569 
570 private:
571 
572  /** Report that there is an unhandled "class x y {" code */
573  void unhandled_macro_class_x_y(const Token *tok) const;
574 
575  /**
576  * assert that tokens are ok - used during debugging for example
577  * to catch problems in simplifyTokenList1/2.
578  */
579  void validate() const;
580 
581  /** Detect garbage code */
582  const Token * findGarbageCode() const;
583 
584  /** Detect garbage expression */
585  bool isGarbageExpr(const Token *start, const Token *end) const;
586 
587  /**
588  * Remove __declspec()
589  */
590  void simplifyDeclspec();
591 
592  /**
593  * Remove calling convention
594  */
595  void simplifyCallingConvention();
596 
597  /**
598  * Remove __attribute__ ((?))
599  */
600  void simplifyAttribute();
601 
602  /**
603  * Remove keywords "volatile", "inline", "register", and "restrict"
604  */
605  void simplifyKeyword();
606 
607  /**
608  * Remove __asm
609  */
610  void simplifyAsm();
611 
612  /**
613  * asm heuristics, Put ^{} statements in asm()
614  */
615  void simplifyAsm2();
616 
617  /**
618  * Simplify bitfields - the field width is removed as we don't use it.
619  */
620  void simplifyBitfields();
621 
622  /**
623  * Remove unnecessary member qualification
624  */
625  void removeUnnecessaryQualification();
626 
627  /**
628  * Add std:: in front of std classes, when using namespace std; was given
629  */
630  void simplifyNamespaceStd();
631 
632  /**
633  * Convert Microsoft memory functions
634  * CopyMemory(dst, src, len) -> memcpy(dst, src, len)
635  * FillMemory(dst, len, val) -> memset(dst, val, len)
636  * MoveMemory(dst, src, len) -> memmove(dst, src, len)
637  * ZeroMemory(dst, len) -> memset(dst, 0, len)
638  */
639  void simplifyMicrosoftMemoryFunctions();
640 
641  /**
642  * Convert Microsoft string functions
643  * _tcscpy -> strcpy
644  */
645  void simplifyMicrosoftStringFunctions();
646 
647  /**
648  * Remove Borland code
649  */
650  void simplifyBorland();
651 
652  /**
653  * Remove Qt signals and slots
654  */
655  void simplifyQtSignalsSlots();
656 
657  /**
658  * Collapse operator name tokens into single token
659  * operator = => operator=
660  */
661  void simplifyOperatorName();
662 
663  /**
664  * Remove [[deprecated]] (C++14) from TokenList
665  */
666  void simplifyDeprecated();
667 
668  /**
669  * Replace strlen(str)
670  * @return true if any replacement took place, false else
671  * */
672  bool simplifyStrlen();
673 
674  /**
675  * Prepare ternary operators with parentheses so that the AST can be created
676  * */
677  void prepareTernaryOpForAST();
678 
679  /**
680  * check for duplicate enum definition
681  */
682  bool duplicateDefinition(Token **tokPtr) const;
683 
684  /**
685  * report error message
686  */
687  void reportError(const Token* tok, const Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const;
688  void reportError(const std::list<const Token*>& callstack, Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const;
689 
690  bool duplicateTypedef(Token **tokPtr, const Token *name, const Token *typeDef) const;
691 
692  void unsupportedTypedef(const Token *tok) const;
693 
694  void setVarIdClassDeclaration(const Token * const startToken,
695  const std::map<std::string, unsigned int> &variableId,
696  const unsigned int scopeStartVarId,
697  std::map<unsigned int, std::map<std::string,unsigned int> >& structMembers);
698 
699 
700  /**
701  * Simplify e.g. 'return(strncat(temp,"a",1));' into
702  * strncat(temp,"a",1); return temp;
703  */
704  void simplifyReturnStrncat();
705 
706  /**
707  * Output list of unknown types.
708  */
709  void printUnknownTypes() const;
710 
711 public:
712 
713  /** Was there templates in the code? */
714  bool codeWithTemplates() const {
715  return _codeWithTemplates;
716  }
717 
718 
719  void setSettings(const Settings *settings) {
720  _settings = settings;
721  list.setSettings(settings);
722  }
723 
725  return _symbolDatabase;
726  }
727  void createSymbolDatabase();
728  void deleteSymbolDatabase();
729 
730  /** print --debug output if debug flags match the simplification:
731  * 0=unknown/both simplifications
732  * 1=1st simplifications
733  * 2=2nd simplifications
734  */
735  void printDebugOutput(unsigned int simplification) const;
736 
737  void dump(std::ostream &out) const;
738 
739  Token *deleteInvalidTypedef(Token *typeDef);
740 
741  /**
742  * Get variable count.
743  * @return number of variables
744  */
745  unsigned int varIdCount() const {
746  return _varId;
747  }
748 
749  /**
750  * Token list: stores all tokens.
751  */
753  // Implement tokens() as a wrapper for convenience when using the TokenList
754  const Token* tokens() const {
755  return list.front();
756  }
757 
758  /**
759  * Copy tokens.
760  * @param dest destination token where copied tokens will be inserted after
761  * @param first first token to copy
762  * @param last last token to copy
763  * @param one_line true=>copy all tokens to the same line as dest. false=>copy all tokens to dest while keeping the 'line breaks'
764  * @return new location of last token copied
765  */
766  static Token *copyTokens(Token *dest, const Token *first, const Token *last, bool one_line = true);
767 
768  /**
769  * Helper function to check whether number is zero (0 or 0.0 or 0E+0) or not?
770  * @param s the string to check
771  * @return true in case is is zero and false otherwise.
772  */
773  static bool isZeroNumber(const std::string &s);
774 
775  /**
776  * Helper function to check whether number is one (1 or 0.1E+1 or 1E+0) or not?
777  * @param s the string to check
778  * @return true in case is is one and false otherwise.
779  */
780  static bool isOneNumber(const std::string &s);
781 
782  /**
783  * Helper function to check whether number is two (2 or 0.2E+1 or 2E+0) or not?
784  * @param s the string to check
785  * @return true in case is is two and false otherwise.
786  */
787  static bool isTwoNumber(const std::string &s);
788 
789  /**
790  * Helper function to check for start of function execution scope.
791  * Do not use this in checks. Use the symbol database.
792  * @param tok pointer to end parentheses of parameter list
793  * @return pointer to start brace of function scope or nullptr if not start.
794  */
795  static const Token * startOfExecutableScope(const Token * tok);
796 
797  bool isMaxTime() const {
798 #ifdef MAXTIME
799  return (std::time(0) > maxtime);
800 #else
801  return false;
802 #endif
803  }
804 
805 private:
806  /** Disable copy constructor, no implementation */
807  Tokenizer(const Tokenizer &);
808 
809  /** Disable assignment operator, no implementation */
810  Tokenizer &operator=(const Tokenizer &);
811 
812  Token *processFunc(Token *tok2, bool inOperator) const;
813 
814  /** Set pod types */
815  void setPodTypes();
816 
817  /** settings */
819 
820  /** errorlogger */
822 
823  /** Symbol database that all checks etc can use */
825 
826  /** E.g. "A" for code where "#ifdef A" is true. This is used to
827  print additional information in error situations. */
828  std::string _configuration;
829 
830  /** sizeof information for known types */
831  std::map<std::string, unsigned int> _typeSize;
832 
833  /** variable count */
834  unsigned int _varId;
835 
836  /**
837  * was there any templates? templates that are "unused" are
838  * removed from the token list
839  */
841 
842  /**
843  * TimerResults
844  */
846 
847 #ifdef MAXTIME
848  /** Tokenizer maxtime */
849  std::time_t maxtime;
850 #endif
851 };
852 
853 /// @}
854 
855 //---------------------------------------------------------------------------
856 #endif // tokenizeH
bool isMaxTime() const
Definition: tokenize.h:797
bool isCPP() const
Is the code CPP.
Definition: tokenize.h:62
TimerResults * m_timerResults
TimerResults.
Definition: tokenize.h:845
std::string _configuration
E.g.
Definition: tokenize.h:828
ErrorLogger *const _errorLogger
errorlogger
Definition: tokenize.h:821
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:824
#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:840
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:818
std::map< std::string, unsigned int > _typeSize
sizeof information for known types
Definition: tokenize.h:831
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:165
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:65
const Token * tokens() const
Definition: tokenize.h:754
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:714
const SymbolDatabase * getSymbolDatabase() const
Definition: tokenize.h:724
void setSettings(const Settings *settings)
Definition: tokenize.h:719
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:752
unsigned int varIdCount() const
Get variable count.
Definition: tokenize.h:745
unsigned int _varId
variable count
Definition: tokenize.h:834