From: James Zern Date: Wed, 22 Jan 2014 01:56:04 +0000 (-0800) Subject: cpplint: restore runtime/sizeof X-Git-Tag: v1.4.0~2603^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fcaf97fd5ad54211e92d02327b0c5ceb4544054;p=libvpx cpplint: restore runtime/sizeof dropped in r113; this check is helpful in this project Change-Id: If810607b7cbf89ad701b4865d685f4b96aeee2dc --- diff --git a/tools/cpplint.py b/tools/cpplint.py index 76d073527..25fbef73d 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -181,6 +181,7 @@ _ERROR_CATEGORIES = [ 'runtime/printf', 'runtime/printf_format', 'runtime/references', + 'runtime/sizeof', 'runtime/string', 'runtime/threadsafe_fn', 'runtime/vlog', @@ -4154,10 +4155,12 @@ def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, if not match: return False - # Exclude lines with sizeof, since sizeof looks like a cast. + # e.g., sizeof(int) sizeof_match = Match(r'.*sizeof\s*$', line[0:match.start(1) - 1]) if sizeof_match: - return False + error(filename, linenum, 'runtime/sizeof', 1, + 'Using sizeof(type). Use sizeof(varname) instead if possible') + return True # operator++(int) and operator--(int) if (line[0:match.start(1) - 1].endswith(' operator++') or