[clang-tools-extra] [clang-tidy] Add a fully custom message to `bugprone-unsafe-functions` (PR #162443)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 8 01:47:14 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,c -- clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions-custom.c
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index 2470ea968..d24b4998b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -307,14 +307,14 @@ void UnsafeFunctionsCheck::check(const MatchFinder::MatchResult &Result) {
         // Omit the replacement, when a fully-custom reason is given.
         if (Reason.consume_front(">")) {
           diag(SourceExpr->getExprLoc(), "function %0 %1")
-               << FuncDecl << Reason.trim() << SourceExpr->getSourceRange();
-        // Do not recommend a replacement when it is not present.
+              << FuncDecl << Reason.trim() << SourceExpr->getSourceRange();
+          // Do not recommend a replacement when it is not present.
         } else if (Entry.Replacement.empty()) {
           diag(SourceExpr->getExprLoc(),
                "function %0 %1; it should not be used")
               << FuncDecl << Reason << Entry.Replacement
               << SourceExpr->getSourceRange();
-        // Otherwise, emit the replacement.
+          // Otherwise, emit the replacement.
         } else {
           diag(SourceExpr->getExprLoc(),
                "function %0 %1; '%2' should be used instead")

``````````

</details>


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


More information about the cfe-commits mailing list