[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 12:32:30 PDT 2025


================
@@ -68,32 +70,57 @@ static std::string getDREAncestorString(const DeclRefExpr *DRE,
 
     if (StParents.size() > 1)
       return "unavailable due to multiple parents";
-    if (StParents.size() == 0)
+    if (StParents.empty())
       break;
     St = StParents.begin()->get<Stmt>();
     if (St)
       SS << " ==> ";
   } while (St);
   return SS.str();
 }
+
 } // namespace
 #endif /* NDEBUG */
 
-namespace clang::ast_matchers {
+namespace {
+// Using a custom matcher instead of ASTMatchers to achieve better performance.
----------------
ziqingluo-90 wrote:

nvm, I realized that `FastMatcher` is mainly an adapter to our interfaces. 

https://github.com/llvm/llvm-project/pull/125492


More information about the cfe-commits mailing list