[clang] Warning Libc functions (PR #101583)

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 16:45:24 PDT 2024


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 c89e9e7d9e9d7c4b30e2d911f4d68ec66e6c68d8 979910f06179225a310e37aedeb2b27c80988b24 --extensions cpp,h -- clang/test/SemaCXX/warn-unsafe-buffer-usage-in-string_view.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-libc-functions.cpp clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h clang/lib/Analysis/UnsafeBufferUsage.cpp clang/lib/Sema/AnalysisBasedWarnings.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-test-unreachable.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
index 32305d4137..f7c5b88775 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
@@ -152,7 +152,8 @@ public:
   ignoreUnsafeBufferInContainer(const SourceLocation &Loc) const = 0;
 
   /// \return true iff unsafe uses in string_views should NOT be reported at
-  /// `Loc`; false otherwise. Controlled by `-Wunsafe-buffer-usage-in-string-view`
+  /// `Loc`; false otherwise. Controlled by
+  /// `-Wunsafe-buffer-usage-in-string-view`
   virtual bool
   ignoreUnsafeBufferInStringView(const SourceLocation &Loc) const = 0;
 
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 9f92b5acc4..bd29296ee2 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -640,7 +640,8 @@ AST_MATCHER_P(CallExpr, isUnsafeLibcFunctionCall, internal::Matcher<Expr>,
                !isNullTermPointer(Arg, hasUnsafeStringView);
       };
 
-      if (Prefix.empty() || Prefix == "k") // printf: all pointer args should be null-terminated
+      if (Prefix.empty() ||
+          Prefix == "k") // printf: all pointer args should be null-terminated
         return llvm::any_of(Call->arguments(), AnyUnsafeStrPtr);
 
       if (Prefix == "f" && Call->getNumArgs() > 1) {

``````````

</details>


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


More information about the cfe-commits mailing list