summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/DanglingHandleCheck.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2017-08-02 13:13:11 +0000
committerManuel Klimek <klimek@google.com>2017-08-02 13:13:11 +0000
commit7b9c117b82eb6b7facfb2406d582e6d08f4ff424 (patch)
tree8d17f5ec9f3de5c55591d1eb32aff893ed5076f7 /clang-tools-extra/clang-tidy/misc/DanglingHandleCheck.cpp
parent696e505278663ef76f996fa5c196ba01e2904be2 (diff)
downloadbcm5719-llvm-7b9c117b82eb6b7facfb2406d582e6d08f4ff424.tar.gz
bcm5719-llvm-7b9c117b82eb6b7facfb2406d582e6d08f4ff424.zip
Adapt clang-tidy checks to changing semantics of hasDeclaration.
Differential Revision: https://reviews.llvm.org/D36154 llvm-svn: 309810
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/DanglingHandleCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/misc/DanglingHandleCheck.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/DanglingHandleCheck.cpp b/clang-tools-extra/clang-tidy/misc/DanglingHandleCheck.cpp
index 67f83d27b42..86220f41502 100644
--- a/clang-tools-extra/clang-tidy/misc/DanglingHandleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/DanglingHandleCheck.cpp
@@ -71,11 +71,13 @@ ast_matchers::internal::BindableMatcher<Stmt> makeContainerMatcher(
// For sequences: assign, push_back, resize.
cxxMemberCallExpr(
callee(functionDecl(hasAnyName("assign", "push_back", "resize"))),
- on(expr(hasType(recordDecl(isASequence()))))),
+ on(expr(hasType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(recordDecl(isASequence())))))))),
// For sequences and sets: insert.
- cxxMemberCallExpr(
- callee(functionDecl(hasName("insert"))),
- on(expr(hasType(recordDecl(anyOf(isASequence(), isASet())))))),
+ cxxMemberCallExpr(callee(functionDecl(hasName("insert"))),
+ on(expr(hasType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(recordDecl(
+ anyOf(isASequence(), isASet()))))))))),
// For maps: operator[].
cxxOperatorCallExpr(callee(cxxMethodDecl(ofClass(isAMap()))),
hasOverloadedOperatorName("[]"))));
@@ -103,7 +105,8 @@ void DanglingHandleCheck::registerMatchersForVariables(MatchFinder *Finder) {
// Find 'Handle foo(ReturnsAValue());'
Finder->addMatcher(
- varDecl(hasType(cxxRecordDecl(IsAHandle)),
+ varDecl(hasType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(cxxRecordDecl(IsAHandle))))),
hasInitializer(
exprWithCleanups(has(ignoringParenImpCasts(ConvertedHandle)))
.bind("bad_stmt"))),
@@ -112,7 +115,9 @@ void DanglingHandleCheck::registerMatchersForVariables(MatchFinder *Finder) {
// Find 'Handle foo = ReturnsAValue();'
Finder->addMatcher(
varDecl(
- hasType(cxxRecordDecl(IsAHandle)), unless(parmVarDecl()),
+ hasType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(cxxRecordDecl(IsAHandle))))),
+ unless(parmVarDecl()),
hasInitializer(exprWithCleanups(has(ignoringParenImpCasts(handleFrom(
IsAHandle, ConvertedHandle))))
.bind("bad_stmt"))),
@@ -139,13 +144,15 @@ void DanglingHandleCheck::registerMatchersForReturn(MatchFinder *Finder) {
// We have to match both.
has(ignoringImplicit(handleFrom(
IsAHandle,
- handleFrom(IsAHandle, declRefExpr(to(varDecl(
- // Is function scope ...
- hasAutomaticStorageDuration(),
- // ... and it is a local array or Value.
- anyOf(hasType(arrayType()),
- hasType(recordDecl(
- unless(IsAHandle))))))))))),
+ handleFrom(IsAHandle,
+ declRefExpr(to(varDecl(
+ // Is function scope ...
+ hasAutomaticStorageDuration(),
+ // ... and it is a local array or Value.
+ anyOf(hasType(arrayType()),
+ hasType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(recordDecl(
+ unless(IsAHandle)))))))))))))),
// Temporary fix for false positives inside lambdas.
unless(hasAncestor(lambdaExpr())))
.bind("bad_stmt"),
OpenPOWER on IntegriCloud