From 83e7842f80aa96b7782f01ef05caf0f90dfbb736 Mon Sep 17 00:00:00 2001 From: kailiu Date: Wed, 19 Feb 2014 01:00:54 -0800 Subject: [PATCH] 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 --- linters/cpp_linter/cpplint.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linters/cpp_linter/cpplint.py b/linters/cpp_linter/cpplint.py index 814b44f20..5f7e169bb 100755 --- a/linters/cpp_linter/cpplint.py +++ b/linters/cpp_linter/cpplint.py @@ -1420,6 +1420,9 @@ def CheckForHeaderGuard(filename, lines, error): endif = None endif_linenum = 0 for linenum, line in enumerate(lines): + # Already been well guarded, no need for further checking. + if line.strip() == "#pragma once": + return linesplit = line.split() if len(linesplit) >= 2: # find the first occurrence of #ifndef and #define, save arg