Enable Clang Tidy (#1586)
Summary: X-link: https://github.com/facebook/litho/pull/976 Pull Request resolved: https://github.com/facebook/yoga/pull/1586 X-link: https://github.com/facebook/react-native/pull/43299 Add the React Clang Tidy config to Yoga, run the auto fixes, and make some manual mechanical tweaks. Notably, the automatic changes to the infra for generating a Yoga tree from JSON capture make it 70% faster. Before: {F1463947076} After: {F1463946802} This also cleans up all the no-op shallow const parameters in headers. {F1463943386} Not all checks are available in all environments, but that is okay, as Clang Tidy will gracefully skip them. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D54461054 fbshipit-source-id: dbd2d9ce51afd3174d1f2c6d439fa7d08baff46f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
47a56db5f6
commit
b959c79a2a
@@ -54,7 +54,9 @@ static void jni_YGConfigSetExperimentalFeatureEnabledJNI(
|
||||
jboolean enabled) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
YGConfigSetExperimentalFeatureEnabled(
|
||||
config, static_cast<YGExperimentalFeature>(feature), enabled);
|
||||
config,
|
||||
static_cast<YGExperimentalFeature>(feature),
|
||||
static_cast<bool>(enabled));
|
||||
}
|
||||
|
||||
static void jni_YGConfigSetUseWebDefaultsJNI(
|
||||
@@ -63,7 +65,7 @@ static void jni_YGConfigSetUseWebDefaultsJNI(
|
||||
jlong nativePointer,
|
||||
jboolean useWebDefaults) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
YGConfigSetUseWebDefaults(config, useWebDefaults);
|
||||
YGConfigSetUseWebDefaults(config, static_cast<bool>(useWebDefaults));
|
||||
}
|
||||
|
||||
static void jni_YGConfigSetPointScaleFactorJNI(
|
||||
@@ -161,7 +163,7 @@ static void jni_YGConfigSetLoggerJNI(
|
||||
auto context =
|
||||
reinterpret_cast<ScopedGlobalRef<jobject>*>(YGConfigGetContext(config));
|
||||
|
||||
if (logger) {
|
||||
if (logger != nullptr) {
|
||||
if (context == nullptr) {
|
||||
context = new ScopedGlobalRef<jobject>();
|
||||
YGConfigSetContext(config, context);
|
||||
@@ -225,14 +227,15 @@ static void jni_YGNodeSetIsReferenceBaselineJNI(
|
||||
jlong nativePointer,
|
||||
jboolean isReferenceBaseline) {
|
||||
YGNodeSetIsReferenceBaseline(
|
||||
_jlong2YGNodeRef(nativePointer), isReferenceBaseline);
|
||||
_jlong2YGNodeRef(nativePointer), static_cast<bool>(isReferenceBaseline));
|
||||
}
|
||||
|
||||
static jboolean jni_YGNodeIsReferenceBaselineJNI(
|
||||
JNIEnv* /*env*/,
|
||||
jobject /*obj*/,
|
||||
jlong nativePointer) {
|
||||
return YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer));
|
||||
return static_cast<jboolean>(
|
||||
YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer)));
|
||||
}
|
||||
|
||||
static void jni_YGNodeRemoveAllChildrenJNI(
|
||||
@@ -340,7 +343,7 @@ static void jni_YGNodeCalculateLayoutJNI(
|
||||
try {
|
||||
PtrJNodeMapVanilla* layoutContext = nullptr;
|
||||
auto map = PtrJNodeMapVanilla{};
|
||||
if (nativePointers) {
|
||||
if (nativePointers != nullptr) {
|
||||
map = PtrJNodeMapVanilla{nativePointers, javaNodes};
|
||||
layoutContext = ↦
|
||||
}
|
||||
@@ -356,7 +359,7 @@ static void jni_YGNodeCalculateLayoutJNI(
|
||||
YGTransferLayoutOutputsRecursive(env, obj, root);
|
||||
} catch (const YogaJniException& jniException) {
|
||||
ScopedLocalRef<jthrowable> throwable = jniException.getThrowable();
|
||||
if (throwable.get()) {
|
||||
if (throwable.get() != nullptr) {
|
||||
env->Throw(throwable.get());
|
||||
}
|
||||
} catch (const std::logic_error& ex) {
|
||||
@@ -626,8 +629,8 @@ static YGSize YGJNIMeasureFunc(
|
||||
|
||||
uint32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
|
||||
uint32_t hBits = 0xFFFFFFFF & measureResult;
|
||||
float measuredWidth = std::bit_cast<float>(wBits);
|
||||
float measuredHeight = std::bit_cast<float>(hBits);
|
||||
auto measuredWidth = std::bit_cast<float>(wBits);
|
||||
auto measuredHeight = std::bit_cast<float>(hBits);
|
||||
|
||||
return YGSize{measuredWidth, measuredHeight};
|
||||
} else {
|
||||
@@ -645,7 +648,7 @@ static void jni_YGNodeSetHasMeasureFuncJNI(
|
||||
jboolean hasMeasureFunc) {
|
||||
YGNodeSetMeasureFunc(
|
||||
_jlong2YGNodeRef(nativePointer),
|
||||
hasMeasureFunc ? YGJNIMeasureFunc : nullptr);
|
||||
static_cast<bool>(hasMeasureFunc) ? YGJNIMeasureFunc : nullptr);
|
||||
}
|
||||
|
||||
static float YGJNIBaselineFunc(YGNodeConstRef node, float width, float height) {
|
||||
@@ -669,7 +672,7 @@ static void jni_YGNodeSetHasBaselineFuncJNI(
|
||||
jboolean hasBaselineFunc) {
|
||||
YGNodeSetBaselineFunc(
|
||||
_jlong2YGNodeRef(nativePointer),
|
||||
hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
|
||||
static_cast<bool>(hasBaselineFunc) ? YGJNIBaselineFunc : nullptr);
|
||||
}
|
||||
|
||||
static void jni_YGNodeSetAlwaysFormsContainingBlockJNI(
|
||||
@@ -678,7 +681,8 @@ static void jni_YGNodeSetAlwaysFormsContainingBlockJNI(
|
||||
jlong nativePointer,
|
||||
jboolean alwaysFormsContainingBlock) {
|
||||
YGNodeSetAlwaysFormsContainingBlock(
|
||||
_jlong2YGNodeRef(nativePointer), alwaysFormsContainingBlock);
|
||||
_jlong2YGNodeRef(nativePointer),
|
||||
static_cast<bool>(alwaysFormsContainingBlock));
|
||||
}
|
||||
|
||||
static jlong
|
||||
|
Reference in New Issue
Block a user