llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: kadir çetinkaya (kadircet) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/104033.diff 2 Files Affected: - (modified) clang-tools-extra/include-cleaner/lib/WalkAST.cpp (+9-1) - (modified) clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp (+7) ``````````diff diff --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp index f7cc9d19123635..5a6bd85a30e469 100644 --- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp +++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp @@ -23,7 +23,6 @@ #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Casting.h" @@ -352,6 +351,15 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> { RefType::Implicit); return true; } + + bool VisitCXXNewExpr(CXXNewExpr *E) { + report(E->getExprLoc(), E->getOperatorNew()); + return true; + } + bool VisitCXXDeleteExpr(CXXDeleteExpr *E) { + report(E->getExprLoc(), E->getOperatorDelete()); + return true; + } }; } // namespace diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp index 282abce3246ca3..79371f5978fc33 100644 --- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -555,5 +555,12 @@ TEST(WalkAST, FriendDecl) { testWalk("void $explicit^foo();", "struct Bar { friend void ^foo(); };"); testWalk("struct $explicit^Foo {};", "struct Bar { friend struct ^Foo; };"); } + +TEST(WalkAST, OperatorNewDelete) { + testWalk("void* $explicit^operator new(unsigned long, void*);", + "struct Bar { void foo() { Bar b; ^new (&b) Bar; } };"); + testWalk("struct A { static void $explicit^operator delete(void*); };", + "void foo() { A a; ^delete &a; }"); +} } // namespace } // namespace clang::include_cleaner `````````` </details> https://github.com/llvm/llvm-project/pull/104033 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits