Move FALLTHROUGH macro to a separate header, and give it an RTC_ prefix
Bug: chromium:805946 Change-Id: Ibb5dce9af27d0e48c9aee6b0a860b6f62b3c76a0 Reviewed-on: https://webrtc-review.googlesource.com/46145 Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21889}
This commit is contained in:
@ -1080,6 +1080,7 @@ rtc_static_library("neteq") {
|
||||
"../../rtc_base:gtest_prod",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../rtc_base:sanitizer",
|
||||
"../../rtc_base/system:fallthrough",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"../../system_wrappers:metrics_api",
|
||||
]
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/sanitizer.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
@ -943,7 +944,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted) {
|
||||
static_cast<uint32_t>(output_size_samples_));
|
||||
// Skipping break on purpose. Execution should move on into the
|
||||
// next case.
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
}
|
||||
case kAudioRepetition: {
|
||||
// TODO(hlundin): Write test for this.
|
||||
|
||||
@ -82,6 +82,7 @@ if (rtc_include_internal_audio_device && is_ios) {
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:gtest_prod",
|
||||
"../../rtc_base:rtc_base",
|
||||
"../../rtc_base/system:fallthrough",
|
||||
"../../sdk:audio_objc",
|
||||
"../../sdk:common_objc",
|
||||
"../../system_wrappers:metrics_api",
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#import "modules/audio_device/ios/voice_processing_audio_unit.h"
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
|
||||
#import "WebRTC/RTCLogging.h"
|
||||
@ -444,12 +445,12 @@ void VoiceProcessingAudioUnit::DisposeAudioUnit() {
|
||||
case kStarted:
|
||||
Stop();
|
||||
// Fall through.
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
case kInitialized:
|
||||
Uninitialize();
|
||||
break;
|
||||
case kUninitialized:
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
case kInitRequired:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -142,6 +142,7 @@ if (rtc_include_tests) {
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../rtc_base:rtc_numerics",
|
||||
"../../rtc_base/experiments:alr_experiment",
|
||||
"../../rtc_base/system:fallthrough",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"../../test:perf_test",
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "modules/remote_bitrate_estimator/test/estimators/send_side.h"
|
||||
#include "modules/remote_bitrate_estimator/test/estimators/tcp.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace testing {
|
||||
@ -97,7 +98,7 @@ BweSender* CreateBweSender(BandwidthEstimatorType estimator,
|
||||
case kBbrEstimator:
|
||||
return new BbrBweSender(observer, clock);
|
||||
case kTcpEstimator:
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
case kNullEstimator:
|
||||
return new NullBweSender();
|
||||
}
|
||||
|
||||
@ -212,6 +212,7 @@ rtc_static_library("rtp_rtcp") {
|
||||
"../../rtc_base:rtc_numerics",
|
||||
"../../rtc_base:sequenced_task_checker",
|
||||
"../../rtc_base:stringutils",
|
||||
"../../rtc_base/system:fallthrough",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"../../system_wrappers:metrics_api",
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -574,7 +575,7 @@ bool RtpDepacketizerH264::ProcessStapAOrSingleNalu(
|
||||
}
|
||||
case H264::NaluType::kIdr:
|
||||
parsed_payload->frame_type = kVideoFrameKey;
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
case H264::NaluType::kSlice: {
|
||||
rtc::Optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice(
|
||||
&payload_data[start_offset], end_offset - start_offset);
|
||||
|
||||
@ -122,6 +122,7 @@ rtc_static_library("video_coding") {
|
||||
"../../rtc_base:rtc_task_queue",
|
||||
"../../rtc_base:sequenced_task_checker",
|
||||
"../../rtc_base/experiments:alr_experiment",
|
||||
"../../rtc_base/system:fallthrough",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"../../system_wrappers:metrics_api",
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "modules/video_coding/packet.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "system_wrappers/include/event_wrapper.h"
|
||||
@ -749,7 +750,7 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet,
|
||||
frame_event_->Set();
|
||||
}
|
||||
}
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
}
|
||||
// Note: There is no break here - continuing to kDecodableSession.
|
||||
case kDecodableSession: {
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include "modules/video_coding/packet_buffer.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace video_coding {
|
||||
@ -71,7 +72,7 @@ void RtpFrameReferenceFinder::RetryStashedFrames() {
|
||||
case kHandOff:
|
||||
complete_frame = true;
|
||||
frame_callback_->OnCompleteFrame(std::move(*frame_it));
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
case kDrop:
|
||||
frame_it = stashed_frames_.erase(frame_it);
|
||||
}
|
||||
|
||||
@ -879,6 +879,7 @@ rtc_source_set("rtc_base_tests_utils") {
|
||||
":stringutils",
|
||||
"../test:field_trial",
|
||||
"../test:test_support",
|
||||
"system:fallthrough",
|
||||
]
|
||||
public_deps = [
|
||||
"//testing/gtest",
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/socket.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
#include "rtc_base/thread.h"
|
||||
|
||||
namespace rtc {
|
||||
@ -537,7 +538,7 @@ bool HttpBase::DoReceiveLoop(HttpError* error) {
|
||||
case SR_EOS:
|
||||
// Clean close, with no error.
|
||||
read_error = 0;
|
||||
FALLTHROUGH(); // Fall through to HandleStreamClose.
|
||||
RTC_FALLTHROUGH(); // Fall through to HandleStreamClose.
|
||||
case SR_ERROR:
|
||||
*error = HandleStreamClose(read_error);
|
||||
return true;
|
||||
|
||||
19
rtc_base/system/BUILD.gn
Normal file
19
rtc_base/system/BUILD.gn
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import("../../webrtc.gni")
|
||||
if (is_android) {
|
||||
import("//build/config/android/config.gni")
|
||||
import("//build/config/android/rules.gni")
|
||||
}
|
||||
|
||||
rtc_source_set("fallthrough") {
|
||||
sources = [
|
||||
"fallthrough.h",
|
||||
]
|
||||
}
|
||||
31
rtc_base/system/fallthrough.h
Normal file
31
rtc_base/system/fallthrough.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef RTC_BASE_SYSTEM_FALLTHROUGH_H_
|
||||
#define RTC_BASE_SYSTEM_FALLTHROUGH_H_
|
||||
|
||||
// Macro to be used for switch-case fallthrough (required for enabling
|
||||
// -Wimplicit-fallthrough warning on Clang).
|
||||
|
||||
// This macro definition must not be included from public headers! Because
|
||||
// clang's diagnostic checks if there's a macro expanding to
|
||||
// [[clang::fallthrough]] defined, and if so it suggests the first macro
|
||||
// expanding to it. So if this macro is included in a public header, clang may
|
||||
// suggest it instead of the client's own macro, which can cause confusion.
|
||||
|
||||
#ifdef __clang__
|
||||
#define RTC_FALLTHROUGH() [[clang::fallthrough]]
|
||||
#else
|
||||
#define RTC_FALLTHROUGH() \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif // RTC_BASE_SYSTEM_FALLTHROUGH_H_
|
||||
10
typedefs.h
10
typedefs.h
@ -91,16 +91,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Macro to be used for switch-case fallthrough (required for enabling
|
||||
// -Wimplicit-fallthrough warning on Clang).
|
||||
#ifndef FALLTHROUGH
|
||||
#if defined(__clang__)
|
||||
#define FALLTHROUGH() [[clang::fallthrough]]
|
||||
#else
|
||||
#define FALLTHROUGH() do { } while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NO_RETURN
|
||||
// Annotate a function that will not return control flow to the caller.
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
@ -71,6 +71,7 @@ rtc_static_library("video") {
|
||||
"../modules/video_coding:video_codec_interface",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base/experiments:alr_experiment",
|
||||
"../rtc_base/system:fallthrough",
|
||||
"../system_wrappers:field_trial_api",
|
||||
"../system_wrappers:metrics_api",
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/location.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
#include "system_wrappers/include/timestamp_extrapolator.h"
|
||||
@ -253,7 +254,7 @@ int32_t RtpVideoStreamReceiver::OnReceivedPayloadData(
|
||||
switch (tracker_.CopyAndFixBitstream(&packet)) {
|
||||
case video_coding::H264SpsPpsTracker::kRequestKeyframe:
|
||||
keyframe_request_sender_->RequestKeyFrame();
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
case video_coding::H264SpsPpsTracker::kDrop:
|
||||
return 0;
|
||||
case video_coding::H264SpsPpsTracker::kInsert:
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/location.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "video/overuse_frame_detector.h"
|
||||
@ -991,7 +992,7 @@ void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
|
||||
break;
|
||||
}
|
||||
// Scale down resolution.
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
}
|
||||
case VideoSendStream::DegradationPreference::kMaintainFramerate: {
|
||||
// Scale down resolution.
|
||||
@ -1074,7 +1075,7 @@ void VideoStreamEncoder::AdaptUp(AdaptReason reason) {
|
||||
break;
|
||||
}
|
||||
// Scale up resolution.
|
||||
FALLTHROUGH();
|
||||
RTC_FALLTHROUGH();
|
||||
}
|
||||
case VideoSendStream::DegradationPreference::kMaintainFramerate: {
|
||||
// Scale up resolution.
|
||||
|
||||
Reference in New Issue
Block a user