[clang] [alpha.webkit.UncountedCallArgsChecker] Check the safety of the object argument in a member function call. (PR #81400)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 11 00:16:46 PST 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 8ea7f1d20ad8ab8c381800eefda948d85c6860cc b7121ce4f2ef69b4a410f2399fbd9d9525156b93 -- clang/test/Analysis/Checkers/WebKit/call-args-inside-if-statement.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index fa6aeb4741..cda96b70ea 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -70,10 +70,11 @@ public:
// or std::function call operator).
unsigned ArgIdx = isa<CXXOperatorCallExpr>(CE) && isa_and_nonnull<CXXMethodDecl>(F);
- if (auto* MemberCallExpr = dyn_cast<CXXMemberCallExpr>(CE)) {
+ if (auto *MemberCallExpr = dyn_cast<CXXMemberCallExpr>(CE)) {
auto *E = MemberCallExpr->getImplicitObjectArgument();
auto *ArgType = MemberCallExpr->getObjectType().getTypePtrOrNull();
- std::optional<bool> IsUncounted = isUncounted(ArgType->getAsCXXRecordDecl());
+ std::optional<bool> IsUncounted =
+ isUncounted(ArgType->getAsCXXRecordDecl());
if (IsUncounted && *IsUncounted && !isPtrOriginSafe(E))
reportBugOnThis(E);
}
@@ -98,7 +99,7 @@ public:
continue;
const auto *Arg = CE->getArg(ArgIdx);
-
+
if (isPtrOriginSafe(Arg))
continue;
@@ -106,7 +107,7 @@ public:
}
}
}
-
+
bool isPtrOriginSafe(const Expr *Arg) const {
std::pair<const clang::Expr *, bool> ArgOrigin =
tryToFindPtrOrigin(Arg, true);
``````````
</details>
https://github.com/llvm/llvm-project/pull/81400
More information about the cfe-commits
mailing list