[clang] [Clang][Sema] Diagnose function/variable templates that shadow their own template parameters (PR #78274)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 07:15:24 PST 2024


zmodem wrote:

Obviously we have some code where this fires :-)

First hit is https://source.chromium.org/chromium/chromium/src/+/main:third_party/libunwindstack/src/libartbase/base/stl_util.h;l=296

```
template <typename Iter, typename Filter>
static inline IterationRange<FilterIterator<Iter, Filter>> Filter(
    IterationRange<Iter> it, Filter cond) {
  auto end = it.end();
  auto start = std::find_if(it.begin(), end, cond);
  return MakeIterationRange(FilterIterator(start, cond, std::make_optional(end)),
                            FilterIterator(end, cond, std::make_optional(end)));
}
```

But there are likely to be more. The problem is that this is a third-party dependency (of a third-party dependency), which makes it more involved to fix. It also means others are likely to hit the same issue.

Is there any chance the new diagnostic could be a warning, at least during a transition period?

https://github.com/llvm/llvm-project/pull/78274


More information about the cfe-commits mailing list