[clang-tools-extra] 65f9c08 - [clang-tidy] Rename 'cert-err34-c' to 'bugprone-unchecked-string-to-number-conversion' (#157285)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 9 08:27:18 PDT 2025


Author: Baranov Victor
Date: 2025-09-09T18:27:14+03:00
New Revision: 65f9c0868f943064a690d9e4e2c6101feecdcab9

URL: https://github.com/llvm/llvm-project/commit/65f9c0868f943064a690d9e4e2c6101feecdcab9
DIFF: https://github.com/llvm/llvm-project/commit/65f9c0868f943064a690d9e4e2c6101feecdcab9.diff

LOG: [clang-tidy] Rename 'cert-err34-c' to 'bugprone-unchecked-string-to-number-conversion' (#157285)

Part of the work in https://github.com/llvm/llvm-project/issues/157287.

Closes https://github.com/llvm/llvm-project/issues/157302.

Added: 
    clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp
    clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.h
    clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.rst
    clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-string-to-number-conversion.c
    clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-string-to-number-conversion.cpp

Modified: 
    clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
    clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
    clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
    clang-tools-extra/clang-tidy/cert/CMakeLists.txt
    clang-tools-extra/docs/ReleaseNotes.rst
    clang-tools-extra/docs/clang-tidy/checks/cert/err34-c.rst
    clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
    clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp
    clang-tools-extra/clang-tidy/cert/StrToNumCheck.h
    clang-tools-extra/test/clang-tidy/checkers/cert/err34-c.c
    clang-tools-extra/test/clang-tidy/checkers/cert/err34-c.cpp


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 824ebdfbd00dc..fe261e729539c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -89,6 +89,7 @@
 #include "ThrowKeywordMissingCheck.h"
 #include "TooSmallLoopVariableCheck.h"
 #include "UncheckedOptionalAccessCheck.h"
+#include "UncheckedStringToNumberConversionCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
 #include "UndelegatedConstructorCheck.h"
 #include "UnhandledExceptionAtNewCheck.h"
@@ -261,6 +262,8 @@ class BugproneModule : public ClangTidyModule {
         "bugprone-too-small-loop-variable");
     CheckFactories.registerCheck<UncheckedOptionalAccessCheck>(
         "bugprone-unchecked-optional-access");
+    CheckFactories.registerCheck<UncheckedStringToNumberConversionCheck>(
+        "bugprone-unchecked-string-to-number-conversion");
     CheckFactories.registerCheck<UndefinedMemoryManipulationCheck>(
         "bugprone-undefined-memory-manipulation");
     CheckFactories.registerCheck<UndelegatedConstructorCheck>(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 59928e5e47a09..46bc8efd44bc5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -91,6 +91,7 @@ add_clang_library(clangTidyBugproneModule STATIC
   ThrowKeywordMissingCheck.cpp
   TooSmallLoopVariableCheck.cpp
   UncheckedOptionalAccessCheck.cpp
+  UncheckedStringToNumberConversionCheck.cpp
   UndefinedMemoryManipulationCheck.cpp
   UndelegatedConstructorCheck.cpp
   UnhandledExceptionAtNewCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp
similarity index 95%
rename from clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp
rename to clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp
index 95536bb1cfdb2..d1e7b895f9a35 100644
--- a/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp
@@ -1,4 +1,4 @@
-//===-- StrToNumCheck.cpp - clang-tidy ------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "StrToNumCheck.h"
+#include "UncheckedStringToNumberConversionCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/FormatString.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -15,9 +15,10 @@
 
 using namespace clang::ast_matchers;
 
-namespace clang::tidy::cert {
+namespace clang::tidy::bugprone {
 
-void StrToNumCheck::registerMatchers(MatchFinder *Finder) {
+void UncheckedStringToNumberConversionCheck::registerMatchers(
+    MatchFinder *Finder) {
   // Match any function call to the C standard library string conversion
   // functions that do no error checking.
   Finder->addMatcher(
@@ -176,7 +177,8 @@ static StringRef classifyReplacement(ConversionKind K) {
   llvm_unreachable("Unknown conversion kind");
 }
 
-void StrToNumCheck::check(const MatchFinder::MatchResult &Result) {
+void UncheckedStringToNumberConversionCheck::check(
+    const MatchFinder::MatchResult &Result) {
   const auto *Call = Result.Nodes.getNodeAs<CallExpr>("expr");
   const FunctionDecl *FuncDecl = nullptr;
   ConversionKind Conversion = ConversionKind::None;
@@ -228,4 +230,4 @@ void StrToNumCheck::check(const MatchFinder::MatchResult &Result) {
       << classifyReplacement(Conversion);
 }
 
-} // namespace clang::tidy::cert
+} // namespace clang::tidy::bugprone

diff  --git a/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.h b/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.h
new file mode 100644
index 0000000000000..365b409f8311c
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_UNCHECKEDSTRINGTONUMBERCONVERSIONCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNCHECKEDSTRINGTONUMBERCONVERSIONCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::bugprone {
+
+/// Guards against use of string conversion functions that do not have
+/// reasonable error handling for conversion errors.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.html
+class UncheckedStringToNumberConversionCheck : public ClangTidyCheck {
+public:
+  UncheckedStringToNumberConversionCheck(StringRef Name,
+                                         ClangTidyContext *Context)
+      : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+    return LangOpts.CPlusPlus || LangOpts.C99;
+  }
+};
+
+} // namespace clang::tidy::bugprone
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNCHECKEDSTRINGTONUMBERCONVERSIONCHECK_H

diff  --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
index 66fedabaf3ca6..a0d0ac1007c3e 100644
--- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
@@ -17,6 +17,7 @@
 #include "../bugprone/SizeofExpressionCheck.h"
 #include "../bugprone/SpuriouslyWakeUpFunctionsCheck.h"
 #include "../bugprone/SuspiciousMemoryComparisonCheck.h"
+#include "../bugprone/UncheckedStringToNumberConversionCheck.h"
 #include "../bugprone/UnhandledSelfAssignmentCheck.h"
 #include "../bugprone/UnsafeFunctionsCheck.h"
 #include "../bugprone/UnusedReturnValueCheck.h"
@@ -39,7 +40,6 @@
 #include "ProperlySeededRandomGeneratorCheck.h"
 #include "SetLongJmpCheck.h"
 #include "StaticObjectExceptionCheck.h"
-#include "StrToNumCheck.h"
 #include "ThrownExceptionTypeCheck.h"
 #include "VariadicFunctionDefCheck.h"
 
@@ -297,7 +297,9 @@ class CERTModule : public ClangTidyModule {
     // ERR
     CheckFactories.registerCheck<bugprone::UnusedReturnValueCheck>(
         "cert-err33-c");
-    CheckFactories.registerCheck<StrToNumCheck>("cert-err34-c");
+    CheckFactories
+        .registerCheck<bugprone::UncheckedStringToNumberConversionCheck>(
+            "cert-err34-c");
     // EXP
     CheckFactories.registerCheck<bugprone::SuspiciousMemoryComparisonCheck>(
         "cert-exp42-c");

diff  --git a/clang-tools-extra/clang-tidy/cert/CMakeLists.txt b/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
index e3187b28399c7..eebbf907cc94e 100644
--- a/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
@@ -15,7 +15,6 @@ add_clang_library(clangTidyCERTModule STATIC
   ProperlySeededRandomGeneratorCheck.cpp
   SetLongJmpCheck.cpp
   StaticObjectExceptionCheck.cpp
-  StrToNumCheck.cpp
   ThrownExceptionTypeCheck.cpp
   VariadicFunctionDefCheck.cpp
 

diff  --git a/clang-tools-extra/clang-tidy/cert/StrToNumCheck.h b/clang-tools-extra/clang-tidy/cert/StrToNumCheck.h
deleted file mode 100644
index 5306bde77f2be..0000000000000
--- a/clang-tools-extra/clang-tidy/cert/StrToNumCheck.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===--- StrToNumCheck.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_CERT_STRTONUMCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_STRTONUMCHECK_H
-
-#include "../ClangTidyCheck.h"
-
-namespace clang::tidy::cert {
-
-/// Guards against use of string conversion functions that do not have
-/// reasonable error handling for conversion errors.
-///
-/// For the user-facing documentation see:
-/// http://clang.llvm.org/extra/clang-tidy/checks/cert/err34-c.html
-class StrToNumCheck : public ClangTidyCheck {
-public:
-  StrToNumCheck(StringRef Name, ClangTidyContext *Context)
-      : ClangTidyCheck(Name, Context) {}
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-};
-
-} // namespace clang::tidy::cert
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_STRTONUMCHECK_H

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 41a8a865f18ca..28620a92e4205 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -176,6 +176,11 @@ New checks
 New check aliases
 ^^^^^^^^^^^^^^^^^
 
+- Renamed :doc:`cert-err34-c <clang-tidy/checks/cert/err34-c>` to
+  :doc:`bugprone-unchecked-string-to-number-conversion
+  <clang-tidy/checks/bugprone/unchecked-string-to-number-conversion>`
+  keeping initial check as an alias to the new one.
+
 Changes in existing checks
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
 

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.rst
new file mode 100644
index 0000000000000..c3ea196511367
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.rst
@@ -0,0 +1,31 @@
+.. title:: clang-tidy - bugprone-unchecked-string-to-number-conversion
+
+bugprone-unchecked-string-to-number-conversion
+==============================================
+
+This check flags calls to string-to-number conversion functions that do not
+verify the validity of the conversion, such as ``atoi()`` or ``scanf()``. It
+does not flag calls to ``strtol()``, or other, related conversion functions that
+do perform better error checking.
+
+.. code-block:: c
+
+  #include <stdlib.h>
+
+  void func(const char *buff) {
+    int si;
+
+    if (buff) {
+      si = atoi(buff); /* 'atoi' used to convert a string to an integer, but function will
+                           not report conversion errors; consider using 'strtol' instead. */
+    } else {
+      /* Handle error */
+    }
+  }
+
+References
+----------
+
+This check corresponds to the CERT C Coding Standard rule
+`ERR34-C. Detect errors when converting a string to a number
+<https://www.securecoding.cert.org/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number>`_.

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/cert/err34-c.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/err34-c.rst
index 362aef2098d49..dc3f6329dfb67 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/err34-c.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/err34-c.rst
@@ -1,28 +1,10 @@
 .. title:: clang-tidy - cert-err34-c
+.. meta::
+   :http-equiv=refresh: 5;URL=../bugprone/unchecked-string-to-number-conversion.html
 
 cert-err34-c
 ============
 
-This check flags calls to string-to-number conversion functions that do not
-verify the validity of the conversion, such as ``atoi()`` or ``scanf()``. It
-does not flag calls to ``strtol()``, or other, related conversion functions that
-do perform better error checking.
-
-.. code-block:: c
-
-  #include <stdlib.h>
-
-  void func(const char *buff) {
-    int si;
-
-    if (buff) {
-      si = atoi(buff); /* 'atoi' used to convert a string to an integer, but function will
-                           not report conversion errors; consider using 'strtol' instead. */
-    } else {
-      /* Handle error */
-    }
-  }
-
-This check corresponds to the CERT C Coding Standard rule
-`ERR34-C. Detect errors when converting a string to a number
-<https://www.securecoding.cert.org/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number>`_.
+The cert-err34-c check is an alias, please see
+`bugprone-unchecked-string-to-number-conversion <../bugprone/unchecked-string-to-number-conversion.html>`_
+for more information.

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 9affebc1feb64..89ad491935f7f 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -157,6 +157,7 @@ Clang-Tidy Checks
    :doc:`bugprone-throw-keyword-missing <bugprone/throw-keyword-missing>`,
    :doc:`bugprone-too-small-loop-variable <bugprone/too-small-loop-variable>`,
    :doc:`bugprone-unchecked-optional-access <bugprone/unchecked-optional-access>`,
+   :doc:`bugprone-unchecked-string-to-number-conversion <bugprone/unchecked-string-to-number-conversion>`,
    :doc:`bugprone-undefined-memory-manipulation <bugprone/undefined-memory-manipulation>`,
    :doc:`bugprone-undelegated-constructor <bugprone/undelegated-constructor>`,
    :doc:`bugprone-unhandled-exception-at-new <bugprone/unhandled-exception-at-new>`,
@@ -173,7 +174,6 @@ Clang-Tidy Checks
    :doc:`cert-dcl58-cpp <cert/dcl58-cpp>`,
    :doc:`cert-env33-c <cert/env33-c>`,
    :doc:`cert-err33-c <cert/err33-c>`,
-   :doc:`cert-err34-c <cert/err34-c>`,
    :doc:`cert-err52-cpp <cert/err52-cpp>`,
    :doc:`cert-err58-cpp <cert/err58-cpp>`,
    :doc:`cert-err60-cpp <cert/err60-cpp>`,
@@ -437,6 +437,7 @@ Check aliases
    :doc:`cert-dcl54-cpp <cert/dcl54-cpp>`, :doc:`misc-new-delete-overloads <misc/new-delete-overloads>`,
    :doc:`cert-dcl59-cpp <cert/dcl59-cpp>`, :doc:`google-build-namespaces <google/build-namespaces>`,
    :doc:`cert-err09-cpp <cert/err09-cpp>`, :doc:`misc-throw-by-value-catch-by-reference <misc/throw-by-value-catch-by-reference>`,
+   :doc:`cert-err34-c <cert/err34-c>`, :doc:`bugprone-unchecked-string-to-number-conversion <bugprone/unchecked-string-to-number-conversion>`,
    :doc:`cert-err61-cpp <cert/err61-cpp>`, :doc:`misc-throw-by-value-catch-by-reference <misc/throw-by-value-catch-by-reference>`,
    :doc:`cert-exp42-c <cert/exp42-c>`, :doc:`bugprone-suspicious-memory-comparison <bugprone/suspicious-memory-comparison>`,
    :doc:`cert-fio38-c <cert/fio38-c>`, :doc:`misc-non-copyable-objects <misc/non-copyable-objects>`,

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/cert/err34-c.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-string-to-number-conversion.c
similarity index 77%
rename from clang-tools-extra/test/clang-tidy/checkers/cert/err34-c.c
rename to clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-string-to-number-conversion.c
index e2cfc2182b3ef..0546e0c2091d5 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/cert/err34-c.c
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-string-to-number-conversion.c
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cert-err34-c %t -- -- -std=c11
+// RUN: %check_clang_tidy %s bugprone-unchecked-string-to-number-conversion %t
 
 typedef __SIZE_TYPE__      size_t;
 typedef signed             ptr
diff _t;
@@ -8,9 +8,9 @@ typedef void *             FILE;
 
 extern FILE *stdin;
 
-extern int fscanf(FILE * restrict stream, const char * restrict format, ...);
-extern int scanf(const char * restrict format, ...);
-extern int sscanf(const char * restrict s, const char * restrict format, ...);
+extern int fscanf(FILE *stream, const char *format, ...);
+extern int scanf(const char *format, ...);
+extern int sscanf(const char *s, const char *format, ...);
 
 extern double atof(const char *nptr);
 extern int atoi(const char *nptr);
@@ -28,23 +28,23 @@ void f1(const char *in) {
   double d;
   long double ld;
 
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead [bugprone-unchecked-string-to-number-conversion]
   sscanf(in, "%d", &i);
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoll' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoll' instead
   fscanf(stdin, "%lld", &ll);
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to an unsigned integer value, but function will not report conversion errors; consider using 'strtoul' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to an unsigned integer value, but function will not report conversion errors; consider using 'strtoul' instead
   sscanf(in, "%u", &ui);
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to an unsigned integer value, but function will not report conversion errors; consider using 'strtoull' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to an unsigned integer value, but function will not report conversion errors; consider using 'strtoull' instead
   fscanf(stdin, "%llu", &ull);
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'scanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoimax' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'scanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoimax' instead
   scanf("%jd", &im);
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to an unsigned integer value, but function will not report conversion errors; consider using 'strtoumax' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to an unsigned integer value, but function will not report conversion errors; consider using 'strtoumax' instead
   fscanf(stdin, "%ju", &uim);
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtof' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtof' instead
   sscanf(in, "%f", &f); // to float
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtod' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtod' instead
   fscanf(stdin, "%lg", &d);
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtold' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtold' instead
   sscanf(in, "%Le", &ld);
 
   // These are conversions with other modifiers
@@ -70,13 +70,13 @@ void f1(const char *in) {
 }
 
 void f2(const char *in) {
-  // CHECK-MESSAGES: :[[@LINE+1]]:11: warning: 'atoi' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:11: warning: 'atoi' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead
   int i = atoi(in); // to int
-  // CHECK-MESSAGES: :[[@LINE+1]]:12: warning: 'atol' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:12: warning: 'atol' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead
   long l = atol(in); // to long
-  // CHECK-MESSAGES: :[[@LINE+1]]:18: warning: 'atoll' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoll' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:18: warning: 'atoll' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoll' instead
   long long ll = atoll(in); // to long long
-  // CHECK-MESSAGES: :[[@LINE+1]]:14: warning: 'atof' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtod' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:14: warning: 'atof' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtod' instead
   double d = atof(in); // to double
 }
 

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/cert/err34-c.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-string-to-number-conversion.cpp
similarity index 77%
rename from clang-tools-extra/test/clang-tidy/checkers/cert/err34-c.cpp
rename to clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-string-to-number-conversion.cpp
index 1c358bc3fb54c..c3e502113c8b7 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/cert/err34-c.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-string-to-number-conversion.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cert-err34-c %t
+// RUN: %check_clang_tidy %s bugprone-unchecked-string-to-number-conversion %t
 
 typedef void *             FILE;
 
@@ -22,22 +22,22 @@ void f1(const char *in) {
   int i;
   long long ll;
 
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'sscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead
   std::sscanf(in, "%d", &i);
-  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoll' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: 'fscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoll' instead
   std::fscanf(std::stdin, "%lld", &ll);
 }
 
 void f2(const char *in) {
-  // CHECK-MESSAGES: :[[@LINE+1]]:11: warning: 'atoi' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:11: warning: 'atoi' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead
   int i = std::atoi(in); // to int
-  // CHECK-MESSAGES: :[[@LINE+1]]:12: warning: 'atol' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:12: warning: 'atol' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead
   long l = std::atol(in); // to long
 
   using namespace std;
 
-  // CHECK-MESSAGES: :[[@LINE+1]]:18: warning: 'atoll' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoll' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:18: warning: 'atoll' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtoll' instead
   long long ll = atoll(in); // to long long
-  // CHECK-MESSAGES: :[[@LINE+1]]:14: warning: 'atof' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtod' instead [cert-err34-c]
+  // CHECK-MESSAGES: :[[@LINE+1]]:14: warning: 'atof' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtod' instead
   double d = atof(in); // to double
 }


        


More information about the cfe-commits mailing list