Skip to content

Commit 3b83a5c

Browse files
eglayshertkruse
authored andcommitted
Revert "Fix the cpplint.py build/endif_comment check."
1 parent 8c78811 commit 3b83a5c

2 files changed

Lines changed: 8 additions & 30 deletions

File tree

cpplint.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,11 +3023,6 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
30233023
filename, line number, error level, and message
30243024
"""
30253025

3026-
line = clean_lines.lines_without_raw_strings[linenum]
3027-
if Match(r'\s*#\s*endif\s*([^/\s]|/[^/]|$)', line):
3028-
error(filename, linenum, 'build/endif_comment', 5,
3029-
'Uncommented text after #endif is non-standard. Use a comment.')
3030-
30313026
# Remove comments from the line, but leave in strings for now.
30323027
line = clean_lines.lines[linenum]
30333028

@@ -3058,6 +3053,10 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
30583053
'Storage-class specifier (static, extern, typedef, etc) should be '
30593054
'at the beginning of the declaration.')
30603055

3056+
if Match(r'\s*#\s*endif\s*[^/\s]+', line):
3057+
error(filename, linenum, 'build/endif_comment', 5,
3058+
'Uncommented text after #endif is non-standard. Use a comment.')
3059+
30613060
if Match(r'\s*class\s+(\w+\s*::\s*)+\w+\s*;', line):
30623061
error(filename, linenum, 'build/forward_decl', 5,
30633062
'Inner-style forward declarations are invalid. Remove this line.')

cpplint_unittest.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3936,7 +3936,7 @@ def testConditionals(self):
39363936
#else
39373937
baz;
39383938
qux;
3939-
#endif // foo""",
3939+
#endif""",
39403940
'')
39413941
self.TestMultiLineLint(
39423942
"""void F() {
@@ -4233,7 +4233,7 @@ def testDuplicateHeader(self):
42334233
'#include "path/unique.h"',
42344234
'#else',
42354235
'#include "path/unique.h"',
4236-
'#endif // MACRO',
4236+
'#endif',
42374237
''],
42384238
error_collector)
42394239
self.assertEqual(
@@ -4284,7 +4284,7 @@ def testBuildClass(self):
42844284
struct Foo : public Goo {
42854285
#else
42864286
struct Foo : public Hoo {
4287-
#endif // DERIVE_FROM_GOO
4287+
#endif
42884288
};""",
42894289
'')
42904290
self.TestMultiLineLint(
@@ -4294,7 +4294,7 @@ class Foo
42944294
: public Goo {
42954295
#else
42964296
: public Hoo {
4297-
#endif // DERIVE_FROM_GOO
4297+
#endif
42984298
};""",
42994299
'')
43004300
# Test incomplete class
@@ -4312,27 +4312,6 @@ def testBuildEndComment(self):
43124312
'Uncommented text after #endif is non-standard. Use a comment.'
43134313
' [build/endif_comment] [5]')
43144314

4315-
correct_lines = [
4316-
'#endif // text',
4317-
'#endif //'
4318-
]
4319-
4320-
for line in correct_lines:
4321-
self.TestLint(line, '')
4322-
4323-
incorrect_lines = [
4324-
'#endif',
4325-
'#endif Not a comment',
4326-
'#endif / One `/` is not enough to start a comment'
4327-
]
4328-
4329-
for line in incorrect_lines:
4330-
self.TestLint(
4331-
line,
4332-
'Uncommented text after #endif is non-standard. Use a comment.'
4333-
' [build/endif_comment] [5]')
4334-
4335-
43364315
def testBuildForwardDecl(self):
43374316
# The crosstool compiler we currently use will fail to compile the
43384317
# code in this test, so we might consider removing the lint check.

0 commit comments

Comments
 (0)