[PATCH] D114197: [clang-tidy] Fix false positives involving type aliases in `misc-unconventional-assign-operator` check

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 4 11:59:06 PST 2021


Quuxplusone added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp:151
+  using Alias3 = TemplateTypeAlias<U>;
+  Alias3<T> &operator=(int) { return *this; }
+};
----------------
fwolff wrote:
> whisperity wrote:
> > This is a no-warn due to the parameter being a completely unrelated type, right? Might worth a comment. I don't see at first glance why a warning should not happen here.
> Exactly. I've added a comment in the `TypeAlias` struct above, because that one comes first. I've also updated the documentation for this check to make this clearer.
> This is a no-warn due to the parameter being a completely unrelated type, right?

No. If that were the case, this would be a terrible test case, full of irrelevant cruft. :)

Once you look past all the levels of type aliases, this is equivalent to
```
template<class T>
struct TTA {
    TTA<T>& operator=(int) { return *this; }
};
```
and so no warning is given because it's correct code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114197/new/

https://reviews.llvm.org/D114197



More information about the cfe-commits mailing list