[PATCH] D91000: [clang-tidy] Add cert-msc24-c checker.

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 30 05:57:04 PST 2021


whisperity added a comment.

Should/does this work in C++ mode for `std::whatever`?



================
Comment at: clang-tools-extra/clang-tidy/cert/ObsolescentFunctionsCheck.cpp:48
+  // Matching functions with safe replacements in annex K.
+  auto FunctionNamesWithAnnexKReplacementMatcher = hasAnyName(
+      "::asctime", "::ctime", "::fopen", "::freopen", "::bsearch", "::fprintf",
----------------
Is this ordering specific in any way? Is the rule listing them in this order? If not, can we have them listed alphabetically, for easier search and potential later change?


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-msc24-c.rst:10
+For the listed functions, an alternative, more secure replacement is suggested, if available.
+The checker heavily relies on the functions from annex K (Bounds-checking interfaces) of C11.
+
----------------
(And consistent capitalisation later.)


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-msc24-c.rst:29
+Both macros have to be defined to suggest replacement functions from annex K. `__STDC_LIB_EXT1__` is
+defined by the library implementation, and `__STDC_WANT_LIB_EXT1__` must be define to "1" by the user 
+before including any system headers.
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91000/new/

https://reviews.llvm.org/D91000



More information about the cfe-commits mailing list