From 6aeef74b6e04bfa78a90b38b5d2323b24f0875d2 Mon Sep 17 00:00:00 2001 From: kjellander Date: Mon, 20 Feb 2017 01:13:18 -0800 Subject: [PATCH] Remove uses of #pragma once and add PRESUBMIT check. They violate the C++ coding style guide: https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#File-headers BUG=webrtc:7191 NOTRY=True Review-Url: https://codereview.webrtc.org/2707843002 Cr-Commit-Position: refs/heads/master@{#16712} --- PRESUBMIT.py | 21 +++++++++++++++++++ .../peerconnection/client/conductor.h | 1 - .../examples/peerconnection/client/defaults.h | 1 - .../examples/peerconnection/client/flagdefs.h | 1 - .../examples/peerconnection/client/main_wnd.h | 1 - .../client/peer_connection_client.h | 1 - .../peerconnection/server/data_socket.h | 1 - .../peerconnection/server/peer_channel.h | 1 - webrtc/examples/peerconnection/server/utils.h | 1 - 9 files changed, 21 insertions(+), 8 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 3405ef9116..f7500e8076 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -169,6 +169,26 @@ def _CheckNoIOStreamInHeaders(input_api, output_api): return [] +def _CheckNoPragmaOnce(input_api, output_api): + """Make sure that banned functions are not used.""" + files = [] + pattern = input_api.re.compile(r'^#pragma\s+once', + input_api.re.MULTILINE) + for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): + if not f.LocalPath().endswith('.h'): + continue + contents = input_api.ReadFile(f) + if pattern.search(contents): + files.append(f) + + if files: + return [output_api.PresubmitError( + 'Do not use #pragma once in header files.\n' + 'See http://www.chromium.org/developers/coding-style#TOC-File-headers', + files)] + return [] + + def _CheckNoFRIEND_TEST(input_api, output_api): """Make sure that gtest's FRIEND_TEST() macro is not used, the FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be @@ -514,6 +534,7 @@ def _CommonChecks(input_api, output_api): input_api, output_api)) results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) + results.extend(_CheckNoPragmaOnce(input_api, output_api)) results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) results.extend(_CheckGnChanges(input_api, output_api)) results.extend(_CheckUnwantedDependencies(input_api, output_api)) diff --git a/webrtc/examples/peerconnection/client/conductor.h b/webrtc/examples/peerconnection/client/conductor.h index 726534b941..0041a9b2b7 100644 --- a/webrtc/examples/peerconnection/client/conductor.h +++ b/webrtc/examples/peerconnection/client/conductor.h @@ -10,7 +10,6 @@ #ifndef WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_ #define WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_ -#pragma once #include #include diff --git a/webrtc/examples/peerconnection/client/defaults.h b/webrtc/examples/peerconnection/client/defaults.h index ecfb9ba3da..f4527c0a29 100644 --- a/webrtc/examples/peerconnection/client/defaults.h +++ b/webrtc/examples/peerconnection/client/defaults.h @@ -10,7 +10,6 @@ #ifndef WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_DEFAULTS_H_ #define WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_DEFAULTS_H_ -#pragma once #include diff --git a/webrtc/examples/peerconnection/client/flagdefs.h b/webrtc/examples/peerconnection/client/flagdefs.h index 92e2773166..19a2b02c36 100644 --- a/webrtc/examples/peerconnection/client/flagdefs.h +++ b/webrtc/examples/peerconnection/client/flagdefs.h @@ -10,7 +10,6 @@ #ifndef WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_FLAGDEFS_H_ #define WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_FLAGDEFS_H_ -#pragma once #include "webrtc/base/flags.h" diff --git a/webrtc/examples/peerconnection/client/main_wnd.h b/webrtc/examples/peerconnection/client/main_wnd.h index d61f95df74..01c8823f0e 100644 --- a/webrtc/examples/peerconnection/client/main_wnd.h +++ b/webrtc/examples/peerconnection/client/main_wnd.h @@ -10,7 +10,6 @@ #ifndef WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_MAIN_WND_H_ #define WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_MAIN_WND_H_ -#pragma once #include #include diff --git a/webrtc/examples/peerconnection/client/peer_connection_client.h b/webrtc/examples/peerconnection/client/peer_connection_client.h index dbf2d8ff3d..de460dd9a4 100644 --- a/webrtc/examples/peerconnection/client/peer_connection_client.h +++ b/webrtc/examples/peerconnection/client/peer_connection_client.h @@ -10,7 +10,6 @@ #ifndef WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_PEER_CONNECTION_CLIENT_H_ #define WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_PEER_CONNECTION_CLIENT_H_ -#pragma once #include #include diff --git a/webrtc/examples/peerconnection/server/data_socket.h b/webrtc/examples/peerconnection/server/data_socket.h index 0ef61ea6aa..6350dcf26d 100644 --- a/webrtc/examples/peerconnection/server/data_socket.h +++ b/webrtc/examples/peerconnection/server/data_socket.h @@ -10,7 +10,6 @@ #ifndef WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_DATA_SOCKET_H_ #define WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_DATA_SOCKET_H_ -#pragma once #ifdef WIN32 #include diff --git a/webrtc/examples/peerconnection/server/peer_channel.h b/webrtc/examples/peerconnection/server/peer_channel.h index 6fd740d2f9..3d51db299c 100644 --- a/webrtc/examples/peerconnection/server/peer_channel.h +++ b/webrtc/examples/peerconnection/server/peer_channel.h @@ -10,7 +10,6 @@ #ifndef WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_PEER_CHANNEL_H_ #define WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_PEER_CHANNEL_H_ -#pragma once #include diff --git a/webrtc/examples/peerconnection/server/utils.h b/webrtc/examples/peerconnection/server/utils.h index e1c8729c0b..fd875f5de8 100644 --- a/webrtc/examples/peerconnection/server/utils.h +++ b/webrtc/examples/peerconnection/server/utils.h @@ -10,7 +10,6 @@ #ifndef WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_UTILS_H_ #define WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_UTILS_H_ -#pragma once #include #include