Skip to content

Commit 52bb7ce

Browse files
authored
Fixes for devmain (facebook#58)
1 parent e4e31a0 commit 52bb7ce

File tree

9 files changed

+38
-5
lines changed

9 files changed

+38
-5
lines changed

Folly/folly/Conv.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,10 @@ class SignedValueHandler<T, true> {
488488
Expected<T, ConversionCode> finalize(U value) {
489489
T rv;
490490
if (negative_) {
491+
FOLLY_PUSH_WARNING
492+
FOLLY_MSVC_DISABLE_WARNING(4146) // unary minus operator applied to unsigned type, result still unsigned
491493
rv = T(-value);
494+
FOLLY_POP_WARNING
492495
if (UNLIKELY(rv > 0)) {
493496
return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
494497
}
@@ -574,7 +577,10 @@ inline Expected<Tgt, ConversionCode> digits_to(
574577
UT result = 0;
575578

576579
for (; e - b >= 4; b += 4) {
580+
FOLLY_PUSH_WARNING
581+
FOLLY_MSVC_DISABLE_WARNING(4309) // truncation of constant value
577582
result *= static_cast<UT>(10000);
583+
FOLLY_POP_WARNING
578584
const int32_t r0 = shift1000[static_cast<size_t>(b[0])];
579585
const int32_t r1 = shift100[static_cast<size_t>(b[1])];
580586
const int32_t r2 = shift10[static_cast<size_t>(b[2])];
@@ -700,7 +706,10 @@ Expected<Tgt, ConversionCode> str_to_integral(StringPiece* src) noexcept {
700706
if (UNLIKELY(err != ConversionCode::SUCCESS)) {
701707
return makeUnexpected(err);
702708
}
709+
FOLLY_PUSH_WARNING
710+
FOLLY_MSVC_DISABLE_WARNING(4127) // conditional expression is constant
703711
if (std::is_signed<Tgt>::value && UNLIKELY(b >= past)) {
712+
FOLLY_POP_WARNING
704713
return makeUnexpected(ConversionCode::NO_DIGITS);
705714
}
706715
if (UNLIKELY(!isdigit(*b))) {

Folly/folly/Conv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,10 @@ checkConversion(const Src& value) {
12761276
std::numeric_limits<Tgt>::max() - static_cast<Tgt>(mmax)) {
12771277
return false;
12781278
}
1279+
FOLLY_PUSH_WARNING
1280+
FOLLY_MSVC_DISABLE_WARNING(4127) // conditional expression is constant
12791281
} else if (std::is_signed<Tgt>::value && value <= tgtMinAsSrc) {
1282+
FOLLY_POP_WARNING
12801283
if (value < tgtMinAsSrc) {
12811284
return false;
12821285
}

Folly/folly/String-inl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ void internalSplit(
298298
}
299299
return;
300300
}
301+
FOLLY_PUSH_WARNING
302+
FOLLY_MSVC_DISABLE_WARNING(4127) // conditional expression is constant
301303
if (std::is_same<DelimT, StringPiece>::value && dSize == 1) {
304+
FOLLY_POP_WARNING
302305
// Call the char version because it is significantly faster.
303306
return internalSplit<OutStringT>(delimFront(delim), sp, out, ignoreEmpty);
304307
}
@@ -454,7 +457,10 @@ void internalJoinAppend(
454457
Iterator end,
455458
String& output) {
456459
assert(begin != end);
460+
FOLLY_PUSH_WARNING
461+
FOLLY_MSVC_DISABLE_WARNING(4127) // conditional expression is constant
457462
if (std::is_same<Delim, StringPiece>::value && delimSize(delimiter) == 1) {
463+
FOLLY_POP_WARNING
458464
internalJoinAppend(delimFront(delimiter), begin, end, output);
459465
return;
460466
}

Folly/folly/dirs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
DIRS = \
2+
container \
23
detail \
4+
hash \
5+
lang \
6+
memory \
37
portability{!droidarm,!droidarm64,!droidx64,!droidx86} \
48
android{droidarm,droidarm64,droidx64,droidx86} \
59
win32{apple,chpe,x64,x86} \

Folly/folly/hash/Hash.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,14 @@ size_t hash_combine_generic(
642642
const Ts&... ts) noexcept(noexcept(detail::c_array_size_t{h(t),
643643
h(ts)...})) {
644644
size_t seed = h(t);
645+
FOLLY_PUSH_WARNING
646+
FOLLY_MSVC_DISABLE_WARNING(4127) // conditional expression is constant
645647
if (sizeof...(ts) == 0) {
646648
return seed;
647649
}
648650
size_t remainder = hash_combine_generic(h, ts...);
649651
if /* constexpr */ (sizeof(size_t) == sizeof(uint32_t)) {
652+
FOLLY_POP_WARNING
650653
return twang_32from64((uint64_t(seed) << 32) | remainder);
651654
} else {
652655
return static_cast<size_t>(hash_128_to_64(seed, remainder));

Folly/folly/json.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,10 @@ void escapeStringImpl(
712712
word = folly::partialLoadUnaligned<uint64_t>(firstEsc, avail);
713713
}
714714
auto prefix = firstEscapableInWord<EnableExtraAsciiEscapes>(word, opts);
715+
FOLLY_PUSH_WARNING
716+
FOLLY_MSVC_DISABLE_WARNING(4018) // signed/unsigned mismatch
715717
DCHECK_LE(prefix, avail);
718+
FOLLY_POP_WARNING
716719
firstEsc += prefix;
717720
if (prefix < 8) {
718721
break;

Folly/folly/lang/Align.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ using max_align_v_ = max_align_t_<
8888
//
8989
// Apple's allocation reference: http://bit.ly/malloc-small
9090
constexpr std::size_t max_align_v = detail::max_align_v_::value;
91+
FOLLY_PUSH_WARNING
92+
FOLLY_MSVC_DISABLE_WARNING(4324) // structure was padded due to alignment specifier
9193
struct alignas(max_align_v) max_align_t {};
94+
FOLLY_POP_WARNING
9295

9396
// Memory locations within the same cache line are subject to destructive
9497
// interference, also known as false sharing, which is when concurrent

Folly/folly/lang/Bits.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ inline T partialLoadUnaligned(const void* p, size_t l) {
324324

325325
auto cp = static_cast<const char*>(p);
326326
T value = 0;
327+
FOLLY_PUSH_WARNING
328+
FOLLY_MSVC_DISABLE_WARNING(4324) // structure was padded due to alignment specifier
327329
if (!kHasUnalignedAccess || !kIsLittleEndian) {
330+
FOLLY_POP_WARNING
328331
// Unsupported, use memcpy.
329332
memcpy(&value, cp, l);
330333
return value;

Folly/folly/sources.inc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ LIBLETNAME = Folly
33
!include $(OPENSOURCE_REACTNATIVE)\OfficeISS\ReactCommon\make.inc
44

55
SOURCES_SHARED = \
6-
..\Assume.cpp \
76
..\Conv.cpp \
87
..\Demangle.cpp \
98
..\dynamic.cpp \
9+
..\Format.cpp \
1010
..\json.cpp \
11-
..\StringBase.cpp \
11+
..\json_pointer.cpp \
1212
..\ScopeGuard.cpp \
13+
..\String.cpp \
1314
..\Unicode.cpp \
1415

15-
SOURCES_WIN32 = \
16-
$(SOURCES_SHARED) \
17-
..\SpookyHashV2.cpp \
16+
SOURCES_WIN32 = $(SOURCES_SHARED) \
1817

1918
SOURCES_ANDROID = $(SOURCES_SHARED) \
2019

0 commit comments

Comments
 (0)