Bug 1683213: Don't warn on range-loop-analysis r=sheehan,sg,firefox-build-system-reviewers,andi,glandium

As described in
https://quuxplusone.github.io/blog/2020/08/26/wrange-loop-analysis/
range-loop-analysis warnings sometimes recommend inferior code.

Also removes pragmas that manually disable this warning.

Differential Revision: https://phabricator.services.mozilla.com/D100155
This commit is contained in:
Mitchell Hentges 2021-01-11 15:30:45 +00:00
parent fe32930e22
commit 34e20029c0
2 changed files with 3 additions and 7 deletions

View File

@ -97,6 +97,9 @@ check_and_add_gcc_warning("-Wfloat-zero-conversion")
# catches issues around loops
check_and_add_gcc_warning("-Wloop-analysis")
# But, disable range-loop-analysis because it can raise unhelpful false
# positives.
check_and_add_gcc_warning("-Wno-range-loop-analysis")
# catches C++ version forward-compat issues
check_and_add_gcc_warning("-Wc++2a-compat", cxx_compiler)

View File

@ -452,10 +452,6 @@ void StringJoinAppend(
nsTSubstring<CharType>& aOutput,
const nsTLiteralString<CharType>& aSeparator, const InputRange& aInputRange,
Func&& aFunc = mozilla::detail::kStringJoinAppendDefault) {
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wrange-loop-analysis"
#endif
bool first = true;
for (const auto& item : aInputRange) {
if (first) {
@ -466,9 +462,6 @@ void StringJoinAppend(
aFunc(aOutput, item);
}
#ifdef __clang__
# pragma clang diagnostic pop
#endif
}
/**