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);
}
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);
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits