[clang] [-Wunsafe-buffer-usage] Support adding unsafe_buffer_usage attribute to struct fields (PR #101585)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 1 16:51:01 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 5b4e5f8ac6c6f7e25f7c87a26f2d2eaa0ebba8e3 1ecd91c03f6de92153809402b10f99e5f649787f --extensions cpp -- clang/test/SemaCXX/warn-unsafe-buffer-usage-field-attr.cpp clang/lib/Analysis/UnsafeBufferUsage.cpp clang/lib/Sema/AnalysisBasedWarnings.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index b2645c814c..0051580b95 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -939,16 +939,15 @@ public:
}
static Matcher matcher() {
- auto HasUnsafeFielDecl =
- member(fieldDecl(allOf(
- anyOf(hasPointerType(), hasArrayType()),
- hasAttr(attr::UnsafeBufferUsage))));
-
+ auto HasUnsafeFielDecl =
+ member(fieldDecl(allOf(anyOf(hasPointerType(), hasArrayType()),
+ hasAttr(attr::UnsafeBufferUsage))));
+
auto HasUnsafeFnDecl =
callee(functionDecl(hasAttr(attr::UnsafeBufferUsage)));
- return stmt(expr(anyOf(callExpr(HasUnsafeFnDecl).bind(OpTag),
- memberExpr(HasUnsafeFielDecl).bind(OpTag))));
+ return stmt(expr(anyOf(callExpr(HasUnsafeFnDecl).bind(OpTag),
+ memberExpr(HasUnsafeFielDecl).bind(OpTag))));
}
void handleUnsafeOperation(UnsafeBufferUsageHandler &Handler,
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 687b8df4fa..d4514ed80a 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2292,11 +2292,12 @@ public:
"Variables blamed for unsafe buffer usage without suggestions!");
S.Diag(Loc, diag::note_unsafe_buffer_operation) << MsgParam << Range;
} else {
- if(!name.empty()) {
- S.Diag(Loc, diag::warn_unsafe_buffer_operation) << MsgParam <<name << Range;
+ if (!name.empty()) {
+ S.Diag(Loc, diag::warn_unsafe_buffer_operation)
+ << MsgParam << name << Range;
} else {
S.Diag(Loc, diag::warn_unsafe_buffer_operation) << MsgParam << Range;
- }
+ }
if (SuggestSuggestions) {
S.Diag(Loc, diag::note_safe_buffer_usage_suggestions_disabled);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/101585
More information about the cfe-commits
mailing list