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}
This commit is contained in:
kjellander 2017-02-20 01:13:18 -08:00 committed by Commit bot
parent fe5d521a69
commit 6aeef74b6e
9 changed files with 21 additions and 8 deletions

View File

@ -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))

View File

@ -10,7 +10,6 @@
#ifndef WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_
#define WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_
#pragma once
#include <deque>
#include <map>

View File

@ -10,7 +10,6 @@
#ifndef WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_DEFAULTS_H_
#define WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_DEFAULTS_H_
#pragma once
#include <stdint.h>

View File

@ -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"

View File

@ -10,7 +10,6 @@
#ifndef WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_MAIN_WND_H_
#define WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_MAIN_WND_H_
#pragma once
#include <map>
#include <memory>

View File

@ -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 <map>
#include <memory>

View File

@ -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 <winsock2.h>

View File

@ -10,7 +10,6 @@
#ifndef WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_PEER_CHANNEL_H_
#define WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_PEER_CHANNEL_H_
#pragma once
#include <time.h>

View File

@ -10,7 +10,6 @@
#ifndef WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_UTILS_H_
#define WEBRTC_EXAMPLES_PEERCONNECTION_SERVER_UTILS_H_
#pragma once
#include <assert.h>
#include <string>