misra.py: Fix R21.1 crash on C++ code (#2354)

Variables from cppcheckdata.Variable have no nameToken if they are
objects of user-defined classes.
This commit is contained in:
Georgy Komarov 2019-11-13 09:58:26 +03:00 committed by Sebastian
parent 49d6bfbd7b
commit dbe23f878b
1 changed files with 2 additions and 0 deletions

View File

@ -1916,6 +1916,8 @@ class MisraChecker:
token = i.nameToken
elif isinstance(i, cppcheckdata.Function):
token = i.tokenDef
if not token:
continue
if len(token.str) < 2:
continue
if token.str == 'errno':