[clang] 5be422b - [Fix][-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable declarations

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 6 14:49:44 PST 2023


Author: ziqingluo-90
Date: 2023-01-06T14:38:12-08:00
New Revision: 5be422b49288d7b9394312ad5ccba1fef42116e6

URL: https://github.com/llvm/llvm-project/commit/5be422b49288d7b9394312ad5ccba1fef42116e6
DIFF: https://github.com/llvm/llvm-project/commit/5be422b49288d7b9394312ad5ccba1fef42116e6.diff

LOG: [Fix][-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable declarations

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

Added: 
    

Modified: 
    clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index d941cf5fe74f5..7dd9e918b0c2e 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -108,8 +108,9 @@ class MatchDescendantVisitor
 };
 
 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


        


More information about the cfe-commits mailing list