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