[PATCH] D76990: [clang-tidy]: fix false positive of cert-oop54-cpp check.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 3 09:41:09 PDT 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a testing request. I agree that the Clang AST is a bit surprising, but not so surprising that I could definitely call it a bug.



================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp:286-299
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo;
+template <int a>
+bool operator!=(Foo &, Foo &) {
+  class Bar {
+    Bar &operator=(const Bar &other) {
+      if (this != &other) {
----------------
Thank you for this! Can you also add a test case where the diagnostic should trigger? e.g.,
```
class Foo;
template <int a>
bool operator!=(Foo &, Foo &) {
  class Bar {
    Bar &operator=(const Bar &other) {
      p = other.p;
      return *this;
    }

    int *p;
  };
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76990





More information about the cfe-commits mailing list