Commit 46de7098 authored by Jim Meyering's avatar Jim Meyering Committed by Jordan DeLong

folly: accommodate use of -Wshadow in other projects

Summary:
Without this change, any folly-using project that attempts to enable
gcc's -Wshadow option will be overwhelmed by warnings about violations
in folly's class definitions.  Violations are often due to local
variable or parameter names shadowed by a member function.

Bracket offending content with directives like this:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
...
#pragma GCC diagnostic pop

This set of modified files is the minimal set to allow tao
to use -Wshadow with no folly-related warning.

Test Plan:
fbmake folly/test && fbmake opt

Reviewed By: simpkins@fb.com

FB internal diff: D848455
parent 76ade918
......@@ -101,6 +101,10 @@
#include <limits>
#include <type_traits>
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#ifdef _LIBSTDCXX_FBSTRING
namespace std _GLIBCXX_VISIBILITY(default) {
_GLIBCXX_BEGIN_NAMESPACE_VERSION
......@@ -2323,6 +2327,8 @@ _GLIBCXX_END_NAMESPACE_VERSION
} // namespace folly
#pragma GCC diagnostic pop
#ifndef _LIBSTDCXX_FBSTRING
namespace std {
......
......@@ -36,6 +36,10 @@
#include "folly/small_vector.h"
#include "folly/FormatArg.h"
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
namespace folly {
// forward declarations
......@@ -268,5 +272,6 @@ void formatFormatter(const Formatter<containerMode, Args...>& formatter,
#include "folly/Format-inl.h"
#endif /* FOLLY_FORMAT_H_ */
#pragma GCC diagnostic pop
#endif /* FOLLY_FORMAT_H_ */
......@@ -35,6 +35,10 @@
#include "folly/Traits.h"
#include "folly/Likely.h"
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
namespace folly {
template <class T> class Range;
......@@ -707,6 +711,8 @@ inline size_t qfind_first_of(const Range<const unsigned char*>& haystack,
}
} // !namespace folly
#pragma GCC diagnostic pop
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(folly::Range);
#endif // FOLLY_RANGE_H_
......@@ -14,6 +14,10 @@
* limitations under the License.
*/
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
namespace folly { namespace gen {
/**
......@@ -1829,3 +1833,5 @@ inline detail::Skip skip(size_t count) {
}
}} //folly::gen
#pragma GCC diagnostic pop
......@@ -34,6 +34,10 @@
#include "folly/Range.h"
#include "folly/FBVector.h"
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
namespace folly {
/**
......@@ -1214,4 +1218,6 @@ inline IOBuf::Iterator IOBuf::end() const { return cend(); }
} // folly
#pragma GCC diagnostic pop
#endif // FOLLY_IO_IOBUF_H_
......@@ -64,6 +64,10 @@
# endif
#endif
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
namespace folly {
//////////////////////////////////////////////////////////////////////
......@@ -1180,6 +1184,8 @@ void swap(small_vector<T,MaxInline,A,B,C>& a,
}
#pragma GCC diagnostic pop
#ifdef FB_PACKED
# undef FB_PACKED
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment