[clang-tools-extra] [clang-tidy] Add bugprone-setvbuf-stack-buffer check (PR #187637)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 21 01:15:56 PDT 2026


================
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SetvbufStackBufferCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void SetvbufStackBufferCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+      callExpr(callee(functionDecl(hasAnyName("setvbuf", "::std::setvbuf"))))
----------------
zeyi2 wrote:

It would be nice if we can also cover `setbuf`, IIUC it may also face the same issue like `setvbuf`.

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


More information about the cfe-commits mailing list