[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 13 09:28:21 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 317e6ff6290c4c3065cb79c3eaf52f171e40cdfd b5a6a7de47741b2e6390acaa27f3f069bf5e1f8d -- clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h clang/lib/Analysis/UnsafeBufferUsage.cpp clang/lib/Sema/AnalysisBasedWarnings.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-function-attr.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 c7b4fcdce2..4b60498a76 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -3310,7 +3310,7 @@ void clang::checkUnsafeBufferUsage(const Decl *D,
assert(D);
- SmallVector<Stmt*> Stmts;
+ SmallVector<Stmt *> Stmts;
// We do not want to visit a Lambda expression defined inside a method
// independently. Instead, it should be visited along with the outer method.
@@ -3333,13 +3333,13 @@ void clang::checkUnsafeBufferUsage(const Decl *D,
Stmts.push_back(FD->getBody());
if (const auto *ID = dyn_cast<CXXConstructorDecl>(D)) {
- for (const CXXCtorInitializer* CI: ID->inits()) {
+ for (const CXXCtorInitializer *CI : ID->inits()) {
Stmts.push_back(CI->getInit());
}
}
}
- if (const auto* FD = dyn_cast<FieldDecl>(D)) {
+ if (const auto *FD = dyn_cast<FieldDecl>(D)) {
// Visit in-class initializers for fields.
if (!FD->hasInClassInitializer())
return;
``````````
</details>
https://github.com/llvm/llvm-project/pull/91991
More information about the cfe-commits
mailing list