summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/modernize
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize')
-rw-r--r--clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp42
-rw-r--r--clang-tools-extra/clang-tidy/modernize/MakeSharedCheck.cpp9
-rw-r--r--clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp25
3 files changed, 40 insertions, 36 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index ac0bceb1819..54bf941ffb2 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -161,17 +161,18 @@ StatementMatcher makeIteratorLoopMatcher() {
// overloaded operator*(). If the operator*() returns by value instead of by
// reference then the return type is tagged with DerefByValueResultName.
internal::Matcher<VarDecl> TestDerefReturnsByValue =
- hasType(cxxRecordDecl(hasMethod(allOf(
- hasOverloadedOperatorName("*"),
- anyOf(
- // Tag the return type if it's by value.
- returns(qualType(unless(hasCanonicalType(referenceType())))
- .bind(DerefByValueResultName)),
- returns(
- // Skip loops where the iterator's operator* returns an
- // rvalue reference. This is just weird.
- qualType(unless(hasCanonicalType(rValueReferenceType())))
- .bind(DerefByRefResultName)))))));
+ hasType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(cxxRecordDecl(hasMethod(allOf(
+ hasOverloadedOperatorName("*"),
+ anyOf(
+ // Tag the return type if it's by value.
+ returns(qualType(unless(hasCanonicalType(referenceType())))
+ .bind(DerefByValueResultName)),
+ returns(
+ // Skip loops where the iterator's operator* returns an
+ // rvalue reference. This is just weird.
+ qualType(unless(hasCanonicalType(rValueReferenceType())))
+ .bind(DerefByRefResultName))))))))));
return forStmt(
unless(isInTemplateInstantiation()),
@@ -242,16 +243,17 @@ StatementMatcher makePseudoArrayLoopMatcher() {
// functions called begin() and end() taking the container as an argument
// are also allowed.
TypeMatcher RecordWithBeginEnd = qualType(anyOf(
- qualType(isConstQualified(),
- hasDeclaration(cxxRecordDecl(
- hasMethod(cxxMethodDecl(hasName("begin"), isConst())),
- hasMethod(cxxMethodDecl(hasName("end"),
- isConst())))) // hasDeclaration
- ), // qualType
qualType(
- unless(isConstQualified()),
- hasDeclaration(cxxRecordDecl(hasMethod(hasName("begin")),
- hasMethod(hasName("end"))))) // qualType
+ isConstQualified(),
+ hasUnqualifiedDesugaredType(recordType(hasDeclaration(cxxRecordDecl(
+ hasMethod(cxxMethodDecl(hasName("begin"), isConst())),
+ hasMethod(cxxMethodDecl(hasName("end"),
+ isConst())))) // hasDeclaration
+ ))), // qualType
+ qualType(unless(isConstQualified()),
+ hasUnqualifiedDesugaredType(recordType(hasDeclaration(
+ cxxRecordDecl(hasMethod(hasName("begin")),
+ hasMethod(hasName("end"))))))) // qualType
));
StatementMatcher SizeCallMatcher = cxxMemberCallExpr(
diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSharedCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeSharedCheck.cpp
index 0495dca7503..541c2cb5af6 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSharedCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSharedCheck.cpp
@@ -20,10 +20,11 @@ MakeSharedCheck::MakeSharedCheck(StringRef Name, ClangTidyContext *Context)
MakeSharedCheck::SmartPtrTypeMatcher
MakeSharedCheck::getSmartPointerTypeMatcher() const {
- return qualType(hasDeclaration(classTemplateSpecializationDecl(
- hasName("::std::shared_ptr"), templateArgumentCountIs(1),
- hasTemplateArgument(
- 0, templateArgument(refersToType(qualType().bind(PointerType)))))));
+ return qualType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(classTemplateSpecializationDecl(
+ hasName("::std::shared_ptr"), templateArgumentCountIs(1),
+ hasTemplateArgument(0, templateArgument(refersToType(
+ qualType().bind(PointerType)))))))));
}
} // namespace modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
index fea452f32a0..4a9b3065e75 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -21,18 +21,19 @@ MakeUniqueCheck::MakeUniqueCheck(StringRef Name,
MakeUniqueCheck::SmartPtrTypeMatcher
MakeUniqueCheck::getSmartPointerTypeMatcher() const {
- return qualType(hasDeclaration(classTemplateSpecializationDecl(
- hasName("::std::unique_ptr"), templateArgumentCountIs(2),
- hasTemplateArgument(
- 0, templateArgument(refersToType(qualType().bind(PointerType)))),
- hasTemplateArgument(
- 1,
- templateArgument(refersToType(
- qualType(hasDeclaration(classTemplateSpecializationDecl(
- hasName("::std::default_delete"), templateArgumentCountIs(1),
- hasTemplateArgument(
- 0, templateArgument(refersToType(
- qualType(equalsBoundNode(PointerType))))))))))))));
+ return qualType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(classTemplateSpecializationDecl(
+ hasName("::std::unique_ptr"), templateArgumentCountIs(2),
+ hasTemplateArgument(
+ 0, templateArgument(refersToType(qualType().bind(PointerType)))),
+ hasTemplateArgument(
+ 1, templateArgument(refersToType(
+ qualType(hasDeclaration(classTemplateSpecializationDecl(
+ hasName("::std::default_delete"),
+ templateArgumentCountIs(1),
+ hasTemplateArgument(
+ 0, templateArgument(refersToType(qualType(
+ equalsBoundNode(PointerType))))))))))))))));
}
} // namespace modernize
OpenPOWER on IntegriCloud