================
@@ -0,0 +1,35 @@
+//===--- SprintfToSnprintfCheck.h - clang-tidy ------------------*- C++ 
-*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPRINTFTOSNPRINTFCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPRINTFTOSNPRINTFCHECK_H
+
+#include "../ClangTidyCheck.h"
+#include <vector>
+
+namespace clang::tidy::bugprone {
+
+/// Finds calls to sprintf where the destination is a fixed-size character
+/// array and replaces them with the safer snprintf.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/bugprone/sprintf-to-snprintf.html
+class SprintfToSnprintfCheck : public ClangTidyCheck {
+public:
+  SprintfToSnprintfCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
----------------
ThanSin02426 wrote:

Should I add a dedicated .c test file Or is there a specific edge case in the 
matcher logic itself that I should adjust for C? because I removed the 
isLanguageVersionSupported override so the check now defaults to running on C 
code as well?
Please correct me if I am wrong somewhere :)

https://github.com/llvm/llvm-project/pull/182823
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to