Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang-tools-extra/include-cleaner/lib/WalkAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
return true;
}

bool VisitCleanupAttr(CleanupAttr *attr) {
report(attr->getLocation(), attr->getFunctionDecl());
return true;
}

// TypeLoc visitors.
void reportType(SourceLocation RefLoc, NamedDecl *ND) {
// Reporting explicit references to types nested inside classes can cause
Expand Down
6 changes: 6 additions & 0 deletions clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,5 +570,11 @@ TEST(WalkAST, OperatorNewDelete) {
testWalk("struct A { static void $ambiguous^operator delete(void*); };",
"void foo() { A a; ^delete &a; }");
}

TEST(WalkAST, CleanupAttr) {
testWalk("void* $explicit^freep(void *p);",
"void foo() { __attribute__((^__cleanup__(freep))) char* x = 0; }");
}

} // namespace
} // namespace clang::include_cleaner
Loading