[PATCH] D133006: [clang-tidy] Skip copy assignment operators with nonstandard return types
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 2 15:43:57 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7395b860bc2: [clang-tidy] Skip copy assignment operators with nonstandard return types (authored by alexander-shaposhnikov).
Changed prior to commit:
https://reviews.llvm.org/D133006?vs=456902&id=457725#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133006/new/
https://reviews.llvm.org/D133006
Files:
clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
@@ -444,6 +444,13 @@
return *this;
}
+// Wrong return type.
+struct WRTConstRef {
+ const WRTConstRef &operator = (const WRTConstRef &) {
+ return *this;
+ }
+};
+
// Try-catch.
struct ITC {
ITC(const ITC &Other)
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,8 @@
check.
The check now skips unions since in this case a default constructor with empty body
- is not equivalent to the explicitly defaulted one. The check is restricted to c++11-or-later.
+ is not equivalent to the explicitly defaulted one. The check also skips copy assignment
+ operators with nonstandard return types. The check is restricted to c++11-or-later.
Removed checks
^^^^^^^^^^^^^^
Index: clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -8,6 +8,7 @@
#include "UseEqualsDefaultCheck.h"
#include "../utils/LexerUtils.h"
+#include "../utils/Matchers.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"
@@ -247,7 +248,12 @@
// isCopyAssignmentOperator() allows the parameter to be
// passed by value, and in this case it cannot be
// defaulted.
- hasParameter(0, hasType(lValueReferenceType())))
+ hasParameter(0, hasType(lValueReferenceType())),
+ // isCopyAssignmentOperator() allows non lvalue reference
+ // return types, and in this case it cannot be defaulted.
+ returns(qualType(hasCanonicalType(
+ allOf(lValueReferenceType(pointee(type())),
+ unless(matchers::isReferenceToConst()))))))
.bind(SpecialFunction),
this);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133006.457725.patch
Type: text/x-patch
Size: 2451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220902/85973b35/attachment.bin>
More information about the llvm-commits
mailing list