Summary:
This is part of what's required to make mcrouter compile warning-free
with gcc -Wshadow. In case it's not obvious why this is worth doing,
see t2719164.
I've used two techniques:
rename one of the shadowed variables
bracket offending code with #pragma directives to disable the warning there.
* folly/Bits.h (BitIterator): Guard this function with #pragma
to avoid a warning about its member-shadowing "bitOffset" parameter.
* folly/Memory.h (StlAllocator): Rename parameter in trivial, one-line
function definition, s/alloc/a/, to avoid shadowing the member function.
Let me know if you'd prefer #pragma directives instead.
* folly/io/Cursor.h (pull,skip,clone): Rename parameter, s/length/len/,
not to shadow the member function name.
Test Plan:
build and run tests of a few tools that use these headers
Reviewed By: jon.coens@fb.com
FB internal diff:
D940493
* Construct a BitIterator that points at a given bit offset (default 0)
* in iter.
*/
+ #pragma GCC diagnostic push // bitOffset shadows a member
+ #pragma GCC diagnostic ignored "-Wshadow"
explicit BitIterator(const BaseIter& iter, size_t bitOffset=0)
: bititerator_detail::BitIteratorBase<BaseIter>::type(iter),
bitOffset_(bitOffset) {
assert(bitOffset_ < bitsPerBlock());
}
+ #pragma GCC diagnostic pop
size_t bitOffset() const {
return bitOffset_;
} // namespace folly
#endif /* FOLLY_BITS_H_ */
-
typedef const void* const_pointer;
StlAllocator() : alloc_(nullptr) { }
- explicit StlAllocator(Alloc* alloc) : alloc_(alloc) { }
+ explicit StlAllocator(Alloc* a) : alloc_(a) { }
Alloc* alloc() const {
return alloc_;
typedef size_t size_type;
StlAllocator() : alloc_(nullptr) { }
- explicit StlAllocator(Alloc* alloc) : alloc_(alloc) { }
+ explicit StlAllocator(Alloc* a) : alloc_(a) { }
template <class U> StlAllocator(const StlAllocator<Alloc, U>& other)
: alloc_(other.alloc()) { }
return std::make_pair(data(), available);
}
- void pull(void* buf, size_t length) {
- if (UNLIKELY(pullAtMost(buf, length) != length)) {
+ void pull(void* buf, size_t len) {
+ if (UNLIKELY(pullAtMost(buf, len) != len)) {
throw std::out_of_range("underflow");
}
}
- void clone(std::unique_ptr<folly::IOBuf>& buf, size_t length) {
- if (UNLIKELY(cloneAtMost(buf, length) != length)) {
+ void clone(std::unique_ptr<folly::IOBuf>& buf, size_t len) {
+ if (UNLIKELY(cloneAtMost(buf, len) != len)) {
throw std::out_of_range("underflow");
}
}
- void skip(size_t length) {
- if (UNLIKELY(skipAtMost(length) != length)) {
+ void skip(size_t len) {
+ if (UNLIKELY(skipAtMost(len) != len)) {
throw std::out_of_range("underflow");
}
}