Enable -Wconversion (#1359)

Summary:
X-link: https://github.com/facebook/react-native/pull/39291

Pull Request resolved: https://github.com/facebook/yoga/pull/1359

This enables clang warnings around potentially unsafe conversions, such as those with mismatched signedness, or ones which may lead to truncation.

This should catch issues in local development which create errors for MSVC (e.g. Dash), who's default `/W3` includes warnings akin to `-Wshorten-64-to-32`.

This full set of warnings here is a tad spammy, but probably more useful than not.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D48954777

fbshipit-source-id: 1ccc07b99d09d1c2d428158149698ffd04025605
This commit is contained in:
Nick Gerleman
2023-09-06 08:16:42 -07:00
committed by Facebook GitHub Bot
parent 95a7b4497e
commit aee43a53bc
17 changed files with 149 additions and 125 deletions

View File

@@ -27,7 +27,7 @@ struct NodeFlags {
bool hasNewLayout : 1;
bool isReferenceBaseline : 1;
bool isDirty : 1;
uint8_t nodeType : 1;
uint32_t nodeType : 1;
bool measureUsesContext : 1;
bool baselineUsesContext : 1;
bool printUsesContext : 1;
@@ -181,8 +181,8 @@ public:
return resolvedDimensions_;
}
YGValue getResolvedDimension(int index) const {
return resolvedDimensions_[index];
YGValue getResolvedDimension(YGDimension dimension) const {
return resolvedDimensions_[static_cast<size_t>(dimension)];
}
static CompactValue computeEdgeValueForColumn(
@@ -257,7 +257,7 @@ public:
}
void setNodeType(YGNodeType nodeType) {
flags_.nodeType = static_cast<uint8_t>(nodeType);
flags_.nodeType = static_cast<uint32_t>(nodeType) & 0x01;
}
void setMeasureFunc(YGMeasureFunc measureFunc);
@@ -303,14 +303,16 @@ public:
void setLayoutComputedFlexBasis(const FloatOptional computedFlexBasis);
void setLayoutComputedFlexBasisGeneration(
uint32_t computedFlexBasisGeneration);
void setLayoutMeasuredDimension(float measuredDimension, int index);
void setLayoutMeasuredDimension(
float measuredDimension,
YGDimension dimension);
void setLayoutHadOverflow(bool hadOverflow);
void setLayoutDimension(float dimension, int index);
void setLayoutDimension(float dimensionValue, YGDimension dimension);
void setLayoutDirection(YGDirection direction);
void setLayoutMargin(float margin, int index);
void setLayoutBorder(float border, int index);
void setLayoutPadding(float padding, int index);
void setLayoutPosition(float position, int index);
void setLayoutMargin(float margin, YGEdge edge);
void setLayoutBorder(float border, YGEdge edge);
void setLayoutPadding(float padding, YGEdge edge);
void setLayoutPosition(float position, YGEdge edge);
void setPosition(
const YGDirection direction,
const float mainSize,
@@ -327,11 +329,11 @@ public:
void clearChildren();
/// Replaces the occurrences of oldChild with newChild
void replaceChild(Node* oldChild, Node* newChild);
void replaceChild(Node* child, uint32_t index);
void insertChild(Node* child, uint32_t index);
void replaceChild(Node* child, size_t index);
void insertChild(Node* child, size_t index);
/// Removes the first occurrence of child
bool removeChild(Node* child);
void removeChild(uint32_t index);
void removeChild(size_t index);
void cloneChildrenIfNeeded(void*);
void markDirtyAndPropagate();