[Fix][-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callabl...
authorziqingluo-90 <ziqing@udel.edu>
Fri, 6 Jan 2023 22:29:19 +0000 (14:29 -0800)
committerziqingluo-90 <ziqing@udel.edu>
Fri, 6 Jan 2023 22:38:12 +0000 (14:38 -0800)
The original patch does include a `new` statement without a matching
`delete`, causing Sanitizer warnings in
https://lab.llvm.org/buildbot/#/builders/5/builds/30522/steps/13/logs/stdio.

This commit is a fix to it.

Differential Revision: https://reviews.llvm.org/D138329

clang/lib/Analysis/UnsafeBufferUsage.cpp

index d941cf5..7dd9e91 100644 (file)
@@ -108,8 +108,9 @@ private:
 };
 
 AST_MATCHER_P(Stmt, forEveryDescendant, internal::Matcher<Stmt>, innerMatcher) {
-  MatchDescendantVisitor Visitor(new DynTypedMatcher(innerMatcher), Finder,
-                                 Builder, ASTMatchFinder::BK_All);
+  const DynTypedMatcher &DTM = static_cast<DynTypedMatcher>(innerMatcher);
+  
+  MatchDescendantVisitor Visitor(&DTM, Finder, Builder, ASTMatchFinder::BK_All);  
   return Visitor.findMatch(DynTypedNode::create(Node));
 }
 } // namespace clang::ast_matchers