From 267e38a8cee0569f04baa0b649c0f65ad29b0440 Mon Sep 17 00:00:00 2001 From: Gaurav Jain Date: Tue, 12 Feb 2013 16:59:25 -0800 Subject: [PATCH] Minor clang compiler fixes Summary: Minor clang compiler fixes Test Plan: - fbmake runtest Reviewed By: andrewjcg@fb.com FB internal diff: D707663 --- folly/Bits.cpp | 12 +++++++++++- folly/Optional.h | 13 ------------- folly/io/IOBufQueue.cpp | 8 ++++---- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/folly/Bits.cpp b/folly/Bits.cpp index 1c825d2a..9513cd33 100644 --- a/folly/Bits.cpp +++ b/folly/Bits.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Facebook, Inc. + * Copyright 2013 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,12 +65,22 @@ namespace detail { // Call folly_popcount_ifunc on startup to resolve to either popcount_inst // or popcount_builtin int popcount(unsigned int x) +// Clang does not support ifuncs, so we call directly for now +#ifdef __clang__ +{ return popcount_builtin(x); } +#else __attribute__((ifunc("folly_popcount_ifunc"))); +#endif // Call folly_popcount_ifunc on startup to resolve to either popcountll_inst // or popcountll_builtin int popcountll(unsigned long long x) +// Clang does not support ifuncs, so we call directly for now +#ifdef __clang__ +{ return popcount_builtin(x); } +#else __attribute__((ifunc("folly_popcountll_ifunc"))); +#endif } // namespace detail } // namespace folly diff --git a/folly/Optional.h b/folly/Optional.h index 5b574f5b..8abbfbc0 100644 --- a/folly/Optional.h +++ b/folly/Optional.h @@ -69,17 +69,6 @@ typedef int detail::NoneHelper::*None; const None none = nullptr; -/** - * gcc-4.7 warns about use of uninitialized memory around the use of storage_ - * even though this is explicitly initialized at each point. - */ -#ifdef __GNUC__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wuninitialized" -# pragma GCC diagnostic ignored "-Wpragmas" -# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#endif // __GNUC__ - template class Optional : boost::totally_ordered, boost::totally_ordered, Value>> { @@ -245,8 +234,6 @@ class Optional : boost::totally_ordered, bool hasValue_; }; -#pragma GCC diagnostic pop - template const T* get_pointer(const Optional& opt) { return opt ? &opt.value() : nullptr; diff --git a/folly/io/IOBufQueue.cpp b/folly/io/IOBufQueue.cpp index a34021ee..35751e03 100644 --- a/folly/io/IOBufQueue.cpp +++ b/folly/io/IOBufQueue.cpp @@ -37,7 +37,7 @@ const size_t MAX_PACK_COPY = 4096; */ void appendToChain(unique_ptr& dst, unique_ptr&& src, bool pack) { - if (dst == NULL) { + if (dst == nullptr) { dst = std::move(src); } else { IOBuf* tail = dst->prev(); @@ -150,7 +150,7 @@ void IOBufQueue::append(const void* buf, size_t len) { auto src = static_cast(buf); while (len != 0) { - if ((head_ == NULL) || head_->prev()->isSharedOne() || + if ((head_ == nullptr) || head_->prev()->isSharedOne() || (head_->prev()->tailroom() == 0)) { appendToChain(head_, std::move( IOBuf::create(std::max(MIN_ALLOC_SIZE, @@ -183,7 +183,7 @@ IOBufQueue::wrapBuffer(const void* buf, size_t len, uint32_t blockSize) { pair IOBufQueue::preallocate(uint32_t min, uint32_t newAllocationSize, uint32_t max) { - if (head_ != NULL) { + if (head_ != nullptr) { // If there's enough space left over at the end of the queue, use that. IOBuf* last = head_->prev(); if (!last->isSharedOne()) { @@ -213,7 +213,7 @@ unique_ptr IOBufQueue::split(size_t n) { unique_ptr result; while (n != 0) { - if (head_ == NULL) { + if (head_ == nullptr) { throw std::underflow_error( "Attempt to remove more bytes than are present in IOBufQueue"); } else if (head_->length() <= n) { -- 2.34.1