matchcompiler: throw InternalError if Token::Match is called with the varid 0

This commit is contained in:
Daniel Marjamäki 2012-12-19 06:45:05 +01:00
parent 3913fd8398
commit 3b3fe1c616
1 changed files with 6 additions and 0 deletions

View File

@ -40,6 +40,11 @@ def compilePattern(pattern, nr, varid):
arg2 = ', const unsigned int varid' arg2 = ', const unsigned int varid'
ret = '// ' + pattern + '\n' ret = '// ' + pattern + '\n'
ret = ret + 'static bool match' + str(nr) + '(const Token *tok'+arg2+') {\n' ret = ret + 'static bool match' + str(nr) + '(const Token *tok'+arg2+') {\n'
if varid:
# if varid is provided, check that it's non-zero
ret = ret + ' if (varid==0U)\n'
ret = ret + ' throw InternalError(tok, "Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers");\n'
tokens = pattern.split(' ') tokens = pattern.split(' ')
gotoNextToken = '' gotoNextToken = ''
for tok in tokens: for tok in tokens:
@ -136,6 +141,7 @@ def convertFile(srcname, destname):
matchfunctions = '' matchfunctions = ''
matchfunctions = matchfunctions + '#include "token.h"\n' matchfunctions = matchfunctions + '#include "token.h"\n'
matchfunctions = matchfunctions + '#include "errorlogger.h"\n'
matchfunctions = matchfunctions + '#include <string>\n' matchfunctions = matchfunctions + '#include <string>\n'
matchfunctions = matchfunctions + '#include <cstring>\n' matchfunctions = matchfunctions + '#include <cstring>\n'
code = '' code = ''