forked from OSchip/llvm-project
[clang-tidy] Skip copy assignment operators with nonstandard return types
Skip copy assignment operators with nonstandard return types since they cannot be defaulted. Test plan: ninja check-clang-tools Differential revision: https://reviews.llvm.org/D133006
This commit is contained in:
parent
b5147937b2
commit
a7395b860b
|
@ -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 @@ void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
|
|||
// 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);
|
||||
}
|
||||
|
|
|
@ -145,7 +145,8 @@ Changes in existing checks
|
|||
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
|
||||
^^^^^^^^^^^^^^
|
||||
|
|
|
@ -444,6 +444,13 @@ IL &WRT::operator=(const WRT &Other) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
// Wrong return type.
|
||||
struct WRTConstRef {
|
||||
const WRTConstRef &operator = (const WRTConstRef &) {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
// Try-catch.
|
||||
struct ITC {
|
||||
ITC(const ITC &Other)
|
||||
|
|
Loading…
Reference in New Issue