Skip to content

Commit 83e7842

Browse files
committed
Improve the check for header guard
Summary: cpplint.py only recognize `#ifdef HEADER_GUARD` as header guard. This patch enables the check for `#pragma once`. Test Plan: New arc lint exclude the false alarm for `#pragma once`. Reviewers: dhruba, sdong, igor, haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D16227
1 parent 78ce24a commit 83e7842

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

linters/cpp_linter/cpplint.py

+3
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,9 @@ def CheckForHeaderGuard(filename, lines, error):
14201420
endif = None
14211421
endif_linenum = 0
14221422
for linenum, line in enumerate(lines):
1423+
# Already been well guarded, no need for further checking.
1424+
if line.strip() == "#pragma once":
1425+
return
14231426
linesplit = line.split()
14241427
if len(linesplit) >= 2:
14251428
# find the first occurrence of #ifndef and #define, save arg

0 commit comments

Comments
 (0)