[clang] [alpha.webkit.NoDeleteChecker] Blame the code that is actually unsafe (PR #224728)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 3 23:54:48 PDT 2026
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 h,cpp -- clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp clang/test/Analysis/Checkers/WebKit/nodelete-lazy-initialize.cpp --diff_from_common_commit
``````````
: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/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp
index fb53534ad..17c4dd120 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoDeleteChecker.cpp
@@ -94,7 +94,7 @@ public:
Field = TFA.fieldWithNonTrivialCtor(Ctor->getParent());
if (!Field) {
for (auto *CtorInit : Ctor->inits()) {
- auto* Init = CtorInit->getInit();
+ auto *Init = CtorInit->getInit();
if (!TFA.isTrivial(Init)) {
OffendingInit = Init;
break;
@@ -143,7 +143,8 @@ public:
SrcLocToReport = FD->getBeginLoc();
Range = Field->getSourceRange();
} else {
- Reason = TrivialFunctionAnalysis::computeReason(OffendingInit ? OffendingInit : Body);
+ Reason = TrivialFunctionAnalysis::computeReason(
+ OffendingInit ? OffendingInit : Body);
Os << "code that could destruct an object.";
const Stmt *Offender = Reason.OffendingStmt;
SrcLocToReport = Offender ? Offender->getBeginLoc() : FD->getBeginLoc();
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
index 343ebf1e4..8fb77c87a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
@@ -229,12 +229,8 @@ struct NonTrivialityReason {
class TrivialFunctionAnalysis {
public:
/// \returns true if \p D is a "trivial" function.
- bool isTrivial(const Decl *D) const {
- return isTrivialImpl(D, TheCache);
- }
- bool isTrivial(const Stmt *S) const {
- return isTrivialImpl(S, TheCache);
- }
+ bool isTrivial(const Decl *D) const { return isTrivialImpl(D, TheCache); }
+ bool isTrivial(const Stmt *S) const { return isTrivialImpl(S, TheCache); }
bool hasTrivialDtor(const VarDecl *VD) const {
return hasTrivialDtorImpl(VD, TheCache);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/224728
More information about the cfe-commits
mailing list