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

Fabian Wolff via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 4 11:45:22 PST 2021


fwolff marked 2 inline comments as done.
fwolff added a comment.

Thanks for your comments @whisperity. I think I've addressed them, could you have another look?



================
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; }
+};
----------------
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.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp:152
+  Alias3<T> &operator=(int) { return *this; }
+};
----------------
whisperity wrote:
> What about `Alias3<TypeAlias::Alias>& operator =(const Alias1&) { return *this; }`? That should trigger a warning as it is an unrelated type, right?
Yes, I've added a test for this (but with `double` as the argument type, because `const Alias1&` gives a warning:
```
warning: 'const' qualifier on reference type 'TemplateTypeAlias::Alias1' (aka 'TemplateTypeAlias<T> &') has no effect [-Wignored-qualifiers]
```


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

https://reviews.llvm.org/D114197



More information about the cfe-commits mailing list