Skip to content

Commit

Permalink
Bug 1519636 - Initial reformat of C/C++ code with clang-format versio…
Browse files Browse the repository at this point in the history
…n 12.0.0. r=sylvestre

clang-format version 12.0.0 (taskcluster-KEgO7qdgQ8uaewA6NkRnRA)

Differential Revision: https://phabricator.services.mozilla.com/D114211
  • Loading branch information
abpostelnicu committed May 10, 2021
1 parent a1f2f73 commit eab549f
Show file tree
Hide file tree
Showing 37 changed files with 229 additions and 189 deletions.
4 changes: 2 additions & 2 deletions browser/app/winlauncher/LauncherProcessWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ Maybe<int> LauncherMain(int& argc, wchar_t* argv[],

// Make sure that the launcher process itself has image load policies set
if (IsWin10AnniversaryUpdateOrLater()) {
static const StaticDynamicallyLinkedFunctionPtr<decltype(
&SetProcessMitigationPolicy)>
static const StaticDynamicallyLinkedFunctionPtr<
decltype(&SetProcessMitigationPolicy)>
pSetProcessMitigationPolicy(L"kernel32.dll",
"SetProcessMitigationPolicy");
if (pSetProcessMitigationPolicy) {
Expand Down
17 changes: 9 additions & 8 deletions dom/indexedDB/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,16 @@ struct FullObjectStoreMetadata {
typedef nsTHashMap<nsUint64HashKey, SafeRefPtr<FullObjectStoreMetadata>>
ObjectStoreTable;

static_assert(
std::is_same_v<IndexOrObjectStoreId,
std::remove_cv_t<std::remove_reference_t<
decltype(std::declval<const ObjectStoreGetParams&>()
.objectStoreId())>>>);
static_assert(
std::is_same_v<
IndexOrObjectStoreId,
std::remove_cv_t<std::remove_reference_t<decltype(
std::declval<const ObjectStoreGetParams&>().objectStoreId())>>>);
static_assert(std::is_same_v<
IndexOrObjectStoreId,
std::remove_cv_t<std::remove_reference_t<decltype(
std::declval<const IndexGetParams&>().objectStoreId())>>>);
std::remove_cv_t<std::remove_reference_t<
decltype(std::declval<const IndexGetParams&>().objectStoreId())>>>);

struct FullDatabaseMetadata final : AtomicSafeRefCounted<FullDatabaseMetadata> {
DatabaseMetadata mCommonMetadata;
Expand Down Expand Up @@ -20691,8 +20692,8 @@ CursorOpBaseHelperBase<CursorType>::PopulateResponseFromStatement(
// inconsistent state.

if (aInitializeResponse) {
mOp.mResponse = std::remove_reference_t<decltype(
populateResponseHelper.GetTypedResponse(&mOp.mResponse))>();
mOp.mResponse = std::remove_reference_t<
decltype(populateResponseHelper.GetTypedResponse(&mOp.mResponse))>();
}

auto& responses = populateResponseHelper.GetTypedResponse(&mOp.mResponse);
Expand Down
10 changes: 6 additions & 4 deletions dom/media/MediaBlockCacheBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ class MediaBlockCacheBase {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaBlockCacheBase)

static_assert(MediaCacheStream::BLOCK_SIZE <
static_cast<std::remove_const<decltype(
MediaCacheStream::BLOCK_SIZE)>::type>(INT32_MAX),
"MediaCacheStream::BLOCK_SIZE should fit in 31 bits");
static_assert(
MediaCacheStream::BLOCK_SIZE <
static_cast<
std::remove_const<decltype(MediaCacheStream::BLOCK_SIZE)>::type>(
INT32_MAX),
"MediaCacheStream::BLOCK_SIZE should fit in 31 bits");
static const int32_t BLOCK_SIZE = MediaCacheStream::BLOCK_SIZE;

protected:
Expand Down
12 changes: 6 additions & 6 deletions dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ FFmpegLibWrapper::LinkResult FFmpegLibWrapper::Link() {
#func))) { \
} \
} else { \
func = (decltype(func)) nullptr; \
func = (decltype(func))nullptr; \
}

#define AV_FUNC_OPTION(func, ver) \
AV_FUNC_OPTION_SILENT(func, ver) \
if ((ver)&version && (func) == (decltype(func)) nullptr) { \
FFMPEG_LOG("Couldn't load function " #func); \
#define AV_FUNC_OPTION(func, ver) \
AV_FUNC_OPTION_SILENT(func, ver) \
if ((ver)&version && (func) == (decltype(func))nullptr) { \
FFMPEG_LOG("Couldn't load function " #func); \
}

#define AV_FUNC(func, ver) \
Expand Down Expand Up @@ -179,7 +179,7 @@ FFmpegLibWrapper::LinkResult FFmpegLibWrapper::Link() {
#ifdef MOZ_WAYLAND
# define VA_FUNC_OPTION_SILENT(func) \
if (!(func = (decltype(func))PR_FindSymbol(mVALib, #func))) { \
func = (decltype(func)) nullptr; \
func = (decltype(func))nullptr; \
}

// mVALib is optional and may not be present.
Expand Down
8 changes: 4 additions & 4 deletions dom/quota/CheckedUnsafePtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ template <typename T, CheckingSupport = T::SupportsChecking::value>
class CheckedUnsafePtrBase;

template <typename T, typename U, typename S = std::nullptr_t>
using EnableIfCompatible =
std::enable_if_t<std::is_base_of<T, std::remove_reference_t<decltype(
*std::declval<U>())>>::value,
S>;
using EnableIfCompatible = std::enable_if_t<
std::is_base_of<
T, std::remove_reference_t<decltype(*std::declval<U>())>>::value,
S>;

template <typename T>
class CheckedUnsafePtrBase<T, CheckingSupport::Enabled>
Expand Down
18 changes: 8 additions & 10 deletions dom/webauthn/WinWebAuthnManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ static HMODULE gWinWebAuthnModule = 0;

static decltype(WebAuthNIsUserVerifyingPlatformAuthenticatorAvailable)*
gWinWebauthnIsUVPAA = nullptr;
static decltype(
WebAuthNAuthenticatorMakeCredential)* gWinWebauthnMakeCredential = nullptr;
static decltype(
WebAuthNFreeCredentialAttestation)* gWinWebauthnFreeCredentialAttestation =
nullptr;
static decltype(WebAuthNAuthenticatorMakeCredential)*
gWinWebauthnMakeCredential = nullptr;
static decltype(WebAuthNFreeCredentialAttestation)*
gWinWebauthnFreeCredentialAttestation = nullptr;
static decltype(WebAuthNAuthenticatorGetAssertion)* gWinWebauthnGetAssertion =
nullptr;
static decltype(WebAuthNFreeAssertion)* gWinWebauthnFreeAssertion = nullptr;
static decltype(WebAuthNGetCancellationId)* gWinWebauthnGetCancellationId =
nullptr;
static decltype(
WebAuthNCancelCurrentOperation)* gWinWebauthnCancelCurrentOperation =
nullptr;
static decltype(WebAuthNCancelCurrentOperation)*
gWinWebauthnCancelCurrentOperation = nullptr;
static decltype(WebAuthNGetErrorName)* gWinWebauthnGetErrorName = nullptr;
static decltype(WebAuthNGetApiVersionNumber)* gWinWebauthnGetApiVersionNumber =
nullptr;
Expand All @@ -57,8 +55,8 @@ WinWebAuthnManager::WinWebAuthnManager() {
gWinWebAuthnModule = LoadLibrarySystem32(L"webauthn.dll");

if (gWinWebAuthnModule) {
gWinWebauthnIsUVPAA = reinterpret_cast<decltype(
WebAuthNIsUserVerifyingPlatformAuthenticatorAvailable)*>(
gWinWebauthnIsUVPAA = reinterpret_cast<
decltype(WebAuthNIsUserVerifyingPlatformAuthenticatorAvailable)*>(
GetProcAddress(
gWinWebAuthnModule,
"WebAuthNIsUserVerifyingPlatformAuthenticatorAvailable"));
Expand Down
5 changes: 3 additions & 2 deletions dom/workers/WorkerScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,9 @@ already_AddRefed<Promise> ServiceWorkerGlobalScope::SkipWaiting(
}

if (ServiceWorkerParentInterceptEnabled()) {
using MozPromiseType = decltype(
mWorkerPrivate->SetServiceWorkerSkipWaitingFlag())::element_type;
using MozPromiseType =
decltype(mWorkerPrivate
->SetServiceWorkerSkipWaitingFlag())::element_type;
auto holder = MakeRefPtr<DOMMozPromiseRequestHolder<MozPromiseType>>(this);

mWorkerPrivate->SetServiceWorkerSkipWaitingFlag()
Expand Down
23 changes: 13 additions & 10 deletions gfx/vr/service/OSVRSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,15 @@ bool OSVRSession::InitState(mozilla::gfx::VRSystemState& aSystemState) {
state.eightCC = GFX_VR_EIGHTCC('O', 'S', 'V', 'R', ' ', ' ', ' ', ' ');
state.isConnected = true;
state.isMounted = false;
state.capabilityFlags = (VRDisplayCapabilityFlags)(
(int)VRDisplayCapabilityFlags::Cap_None |
(int)VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position |
(int)VRDisplayCapabilityFlags::Cap_External |
(int)VRDisplayCapabilityFlags::Cap_Present |
(int)VRDisplayCapabilityFlags::Cap_ImmersiveVR);
state.capabilityFlags =
(VRDisplayCapabilityFlags)((int)VRDisplayCapabilityFlags::Cap_None |
(int)
VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position |
(int)VRDisplayCapabilityFlags::Cap_External |
(int)VRDisplayCapabilityFlags::Cap_Present |
(int)
VRDisplayCapabilityFlags::Cap_ImmersiveVR);
state.blendMode = VRDisplayBlendMode::Opaque;
state.reportsDroppedFrames = false;

Expand Down Expand Up @@ -412,9 +414,10 @@ bool OSVRSession::InitState(mozilla::gfx::VRSystemState& aSystemState) {

// default to an identity quaternion
VRHMDSensorState& sensorState = aSystemState.sensorState;
sensorState.flags = (VRDisplayCapabilityFlags)(
(int)VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position);
sensorState.flags =
(VRDisplayCapabilityFlags)((int)
VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position);
sensorState.pose.orientation[3] = 1.0f; // Default to an identity quaternion

return true;
Expand Down
7 changes: 4 additions & 3 deletions gfx/vr/service/OculusSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,9 +1064,10 @@ bool OculusSession::InitState(VRSystemState& aSystemState) {
UpdateEyeParameters(aSystemState);

VRHMDSensorState& sensorState = aSystemState.sensorState;
sensorState.flags = (VRDisplayCapabilityFlags)(
(int)VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position);
sensorState.flags =
(VRDisplayCapabilityFlags)((int)
VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position);
sensorState.pose.orientation[3] = 1.0f; // Default to an identity quaternion

return true;
Expand Down
40 changes: 23 additions & 17 deletions gfx/vr/service/OpenVRSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,14 +713,17 @@ bool OpenVRSession::InitState(VRSystemState& aSystemState) {
state.isConnected =
mVRSystem->IsTrackedDeviceConnected(::vr::k_unTrackedDeviceIndex_Hmd);
state.isMounted = false;
state.capabilityFlags = (VRDisplayCapabilityFlags)(
(int)VRDisplayCapabilityFlags::Cap_None |
(int)VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position |
(int)VRDisplayCapabilityFlags::Cap_External |
(int)VRDisplayCapabilityFlags::Cap_Present |
(int)VRDisplayCapabilityFlags::Cap_StageParameters |
(int)VRDisplayCapabilityFlags::Cap_ImmersiveVR);
state.capabilityFlags =
(VRDisplayCapabilityFlags)((int)VRDisplayCapabilityFlags::Cap_None |
(int)
VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position |
(int)VRDisplayCapabilityFlags::Cap_External |
(int)VRDisplayCapabilityFlags::Cap_Present |
(int)VRDisplayCapabilityFlags::
Cap_StageParameters |
(int)
VRDisplayCapabilityFlags::Cap_ImmersiveVR);
state.blendMode = VRDisplayBlendMode::Opaque;
state.reportsDroppedFrames = true;

Expand All @@ -729,9 +732,10 @@ bool OpenVRSession::InitState(VRSystemState& aSystemState) {
::vr::k_unTrackedDeviceIndex_Hmd, ::vr::Prop_ContainsProximitySensor_Bool,
&err);
if (err == ::vr::TrackedProp_Success && bHasProximitySensor) {
state.capabilityFlags = (VRDisplayCapabilityFlags)(
(int)state.capabilityFlags |
(int)VRDisplayCapabilityFlags::Cap_MountDetection);
state.capabilityFlags =
(VRDisplayCapabilityFlags)((int)state.capabilityFlags |
(int)VRDisplayCapabilityFlags::
Cap_MountDetection);
}

uint32_t w, h;
Expand All @@ -747,9 +751,10 @@ bool OpenVRSession::InitState(VRSystemState& aSystemState) {
UpdateEyeParameters(aSystemState);

VRHMDSensorState& sensorState = aSystemState.sensorState;
sensorState.flags = (VRDisplayCapabilityFlags)(
(int)VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position);
sensorState.flags =
(VRDisplayCapabilityFlags)((int)
VRDisplayCapabilityFlags::Cap_Orientation |
(int)VRDisplayCapabilityFlags::Cap_Position);
sensorState.pose.orientation[3] = 1.0f; // Default to an identity quaternion

return true;
Expand Down Expand Up @@ -878,9 +883,10 @@ void OpenVRSession::UpdateHeadsetPose(VRSystemState& aState) {
gfx::Quaternion rot;
rot.SetFromRotationMatrix(m);

aState.sensorState.flags = (VRDisplayCapabilityFlags)(
(int)aState.sensorState.flags |
(int)VRDisplayCapabilityFlags::Cap_Orientation);
aState.sensorState.flags =
(VRDisplayCapabilityFlags)((int)aState.sensorState.flags |
(int)VRDisplayCapabilityFlags::
Cap_Orientation);
aState.sensorState.pose.orientation[0] = rot.x;
aState.sensorState.pose.orientation[1] = rot.y;
aState.sensorState.pose.orientation[2] = rot.z;
Expand Down
4 changes: 2 additions & 2 deletions ipc/mscom/AgileReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ void AgileReference::AssignInternal(IUnknown* aObject) {
* If that API is not available, we fall back to using the Global Interface
* Table.
*/
static const StaticDynamicallyLinkedFunctionPtr<decltype(
&::RoGetAgileReference)>
static const StaticDynamicallyLinkedFunctionPtr<
decltype(&::RoGetAgileReference)>
pRoGetAgileReference(L"ole32.dll", "RoGetAgileReference");

MOZ_ASSERT(aObject);
Expand Down
4 changes: 2 additions & 2 deletions js/src/frontend/EitherParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct InvokeMemberFunction {
mozilla::Tuple<std::decay_t<Args>...> args;

template <class This, size_t... Indices>
auto matchInternal(This* obj, std::index_sequence<Indices...>) -> decltype(
((*obj).*(MemberFunction<This>::get()))(mozilla::Get<Indices>(args)...)) {
auto matchInternal(This* obj, std::index_sequence<Indices...>) -> decltype((
(*obj).*(MemberFunction<This>::get()))(mozilla::Get<Indices>(args)...)) {
return ((*obj).*
(MemberFunction<This>::get()))(mozilla::Get<Indices>(args)...);
}
Expand Down
5 changes: 3 additions & 2 deletions layout/style/ComputedStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@ static nscolor ExtractColor(const ComputedStyle& aStyle,
#define STYLE_FIELD(struct_, field_) aField == &struct_::field_ ||
#define STYLE_STRUCT(name_, fields_) \
template <> \
nscolor ComputedStyle::GetVisitedDependentColor(decltype( \
nsStyle##name_::MOZ_ARG_1 fields_) nsStyle##name_::*aField) const { \
nscolor ComputedStyle::GetVisitedDependentColor( \
decltype(nsStyle##name_::MOZ_ARG_1 fields_) nsStyle##name_::*aField) \
const { \
MOZ_ASSERT(MOZ_FOR_EACH(STYLE_FIELD, (nsStyle##name_, ), fields_) false, \
"Getting visited-dependent color for a field in nsStyle" #name_ \
" which is not listed in nsCSSVisitedDependentPropList.h"); \
Expand Down
8 changes: 4 additions & 4 deletions mfbt/Attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@
# define MOZ_STATIC_CLASS __attribute__((annotate("moz_global_class")))
# define MOZ_STATIC_LOCAL_CLASS \
__attribute__((annotate("moz_static_local_class"))) \
__attribute__((annotate("moz_trivial_dtor")))
__attribute__((annotate("moz_trivial_dtor")))
# define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))
# define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
# define MOZ_HEAP_CLASS __attribute__((annotate("moz_heap_class")))
Expand Down Expand Up @@ -757,8 +757,8 @@
# define MOZ_NO_DANGLING_ON_TEMPORARIES \
__attribute__((annotate("moz_no_dangling_on_temporaries")))
# define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS \
__attribute__( \
(annotate("moz_inherit_type_annotations_from_template_args")))
__attribute__(( \
annotate("moz_inherit_type_annotations_from_template_args")))
# define MOZ_NON_AUTOABLE __attribute__((annotate("moz_non_autoable")))
# define MOZ_INIT_OUTSIDE_CTOR
# define MOZ_IS_CLASS_INIT
Expand All @@ -781,7 +781,7 @@
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
__attribute__((annotate("moz_heap_allocator"))) \
_Pragma("clang diagnostic pop")
_Pragma("clang diagnostic pop")
# else
# define MOZ_HEAP_ALLOCATOR __attribute__((annotate("moz_heap_allocator")))
# endif
Expand Down
11 changes: 6 additions & 5 deletions mfbt/ResultExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ struct outparam_as_reference<T*> {

template <typename R, template <typename> typename RArg, typename Func,
typename... Args>
using to_result_retval_t = decltype(
std::declval<Func&>()(std::declval<Args&&>()...,
std::declval<typename RArg<decltype(
ResultRefAsParam(std::declval<R&>()))>::type>()),
Result<R, nsresult>(Err(NS_ERROR_FAILURE)));
using to_result_retval_t =
decltype(std::declval<Func&>()(
std::declval<Args&&>()...,
std::declval<typename RArg<decltype(ResultRefAsParam(
std::declval<R&>()))>::type>()),
Result<R, nsresult>(Err(NS_ERROR_FAILURE)));

// There are two ToResultInvokeSelector overloads, which cover the cases of a) a
// pointer-typed output parameter, and b) a reference-typed output parameter,
Expand Down
12 changes: 6 additions & 6 deletions mfbt/Variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ struct VariantImplementation<Tag, N, T, Ts...> {
static decltype(auto) match(Matcher&& aMatcher, ConcreteVariant&& aV) {
if (aV.template is<N>()) {
if constexpr (std::is_invocable_v<Matcher, Tag,
decltype(
std::forward<ConcreteVariant>(aV)
.template as<N>())>) {
decltype(std::forward<ConcreteVariant>(
aV)
.template as<N>())>) {
return std::forward<Matcher>(aMatcher)(
Tag(N), std::forward<ConcreteVariant>(aV).template as<N>());
} else {
Expand All @@ -284,9 +284,9 @@ struct VariantImplementation<Tag, N, T, Ts...> {
static decltype(auto) matchN(ConcreteVariant&& aV, Mi&& aMi, Ms&&... aMs) {
if (aV.template is<N>()) {
if constexpr (std::is_invocable_v<Mi, Tag,
decltype(
std::forward<ConcreteVariant>(aV)
.template as<N>())>) {
decltype(std::forward<ConcreteVariant>(
aV)
.template as<N>())>) {
static_assert(
std::is_same_v<
decltype(std::forward<Mi>(aMi)(
Expand Down
9 changes: 4 additions & 5 deletions mozglue/baseprofiler/public/BlocksRingBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,10 @@ struct ProfileBufferEntryReader::Deserializer<BlocksRingBuffer> {
writer.WriteFromReader(aER, end - start);
MOZ_ASSERT(writer.RemainingBytes() == 0);
// Finally copy stats.
aBuffer.mMaybeUnderlyingBuffer->mPushedBlockCount = aER.ReadObject<decltype(
aBuffer.mMaybeUnderlyingBuffer->mPushedBlockCount)>();
aBuffer.mMaybeUnderlyingBuffer->mClearedBlockCount =
aER.ReadObject<decltype(
aBuffer.mMaybeUnderlyingBuffer->mClearedBlockCount)>();
aBuffer.mMaybeUnderlyingBuffer->mPushedBlockCount = aER.ReadObject<
decltype(aBuffer.mMaybeUnderlyingBuffer->mPushedBlockCount)>();
aBuffer.mMaybeUnderlyingBuffer->mClearedBlockCount = aER.ReadObject<
decltype(aBuffer.mMaybeUnderlyingBuffer->mClearedBlockCount)>();
}

// We cannot output a BlocksRingBuffer object (not copyable), use `ReadInto()`
Expand Down
Loading

0 comments on commit eab549f

Please sign in to comment.