File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 2323#include " clang/Basic/IdentifierTable.h"
2424#include " clang/Basic/SourceLocation.h"
2525#include " clang/Basic/Specifiers.h"
26- #include " llvm/ADT/STLExtras.h"
2726#include " llvm/ADT/STLFunctionalExtras.h"
2827#include " llvm/ADT/SmallVector.h"
2928#include " llvm/Support/Casting.h"
@@ -350,6 +349,15 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
350349 RefType::Implicit);
351350 return true ;
352351 }
352+
353+ bool VisitCXXNewExpr (CXXNewExpr *E) {
354+ report (E->getExprLoc (), E->getOperatorNew ());
355+ return true ;
356+ }
357+ bool VisitCXXDeleteExpr (CXXDeleteExpr *E) {
358+ report (E->getExprLoc (), E->getOperatorDelete ());
359+ return true ;
360+ }
353361};
354362
355363} // namespace
Original file line number Diff line number Diff line change @@ -555,5 +555,12 @@ TEST(WalkAST, FriendDecl) {
555555 testWalk (" void $explicit^foo();" , " struct Bar { friend void ^foo(); };" );
556556 testWalk (" struct $explicit^Foo {};" , " struct Bar { friend struct ^Foo; };" );
557557}
558+
559+ TEST (WalkAST, OperatorNewDelete) {
560+ testWalk (" void* $explicit^operator new(unsigned long, void*);" ,
561+ " struct Bar { void foo() { Bar b; ^new (&b) Bar; } };" );
562+ testWalk (" struct A { static void $explicit^operator delete(void*); };" ,
563+ " void foo() { A a; ^delete &a; }" );
564+ }
558565} // namespace
559566} // namespace clang::include_cleaner
You can’t perform that action at this time.
0 commit comments