ref: a72cc78ec581a12affea7e053cd6e56f226270c3
parent: e0ec51d325a24dbb1e7dbd328c73b21d9377f95a
parent: 3fcaf97fd5ad54211e92d02327b0c5ceb4544054
author: James Zern <jzern@google.com>
date: Wed Jan 22 14:45:43 EST 2014
Merge "cpplint: restore runtime/sizeof"
--- a/tools/cpplint.py
+++ b/tools/cpplint.py
@@ -181,6 +181,7 @@
'runtime/printf',
'runtime/printf_format',
'runtime/references',
+ 'runtime/sizeof',
'runtime/string',
'runtime/threadsafe_fn',
'runtime/vlog',
@@ -4154,10 +4155,12 @@
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
--
⑨