This is an archive of the discontinued LLVM Phabricator instance.

Fix some `-Wshadow` diagnostics emitted by Clang trunk
AbandonedPublic

Authored by Quuxplusone on Nov 17 2018, 6:44 PM.

Details

Reviewers
EricWF
Summary

This is what I see when building make -j5 check-cxx with Clang trunk (built from source) on OS X.

In file included from /llvm/projects/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp:22:
/llvm/projects/libcxx/test/support/filesystem_test_helper.hpp:455:62: error: declaration shadows a field of 'ExceptionChecker' [-Werror,-Wshadow]
  explicit ExceptionChecker(std::errc first_err, const char* func_name,
                                                             ^
/llvm/projects/libcxx/test/support/filesystem_test_helper.hpp:452:15: note: previous declaration is here
  const char* func_name;
              ^
In file included from /llvm/projects/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp:17:
/llvm/projects/libcxx/include/charconv:473:35: error: declaration shadows a local variable [-Werror,-Wshadow]
    auto __find_non_zero = [](_It __first, _It __last) {
                                  ^
/llvm/projects/libcxx/include/charconv:470:30: note: previous declaration is here
__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
                             ^

The -Werror,-Wshadow seems to be coming from here. I don't know why non-Apple platforms don't see these same warnings.

$ git grep Wshadow utils/libcxx/
utils/libcxx/test/config.py:        self.cxx.addWarningFlagIfSupported('-Wshadow')

Diff Detail

Repository
rCXX libc++

Event Timeline

I'm not sure these warnings normally hit users because they should include us with -isystem, right?

include/charconv
549

In this case, would it be less intrusive to rename the parameter from __first to __first_it or something like that? I think the parameters are used less often here.

include/charconv
549

That sounds good for __first and __last, but what about __value and __base?

This is what I see when building make -j5 check-cxx with Clang trunk (built from source) on OS X.

I discovered yesterday that make check-cxx actually uses the system compiler by default, so therefore I had not been using Clang trunk; I had been using

$ clang --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

With Clang trunk, I don't see -Wshadow warnings after all.

Quuxplusone abandoned this revision.Mar 21 2019, 6:33 PM