[clang] [clang] Extend lifetimebound analysis to detect within-initializer assignments between pointer-like objects. (PR #97473)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 2 13:16:12 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 c3079ffcd34e8ee2faaf7576a69a49acc1a3653f e1bd3e3d813ecce1e93957c3cbe26a8c3182abd6 -- clang/lib/Sema/CheckExprLifetime.cpp clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp b/clang/lib/Sema/CheckExprLifetime.cpp
index f2fd3849b0..d30d17d461 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -325,7 +325,7 @@ static bool shouldTrackFirstArgument(const FunctionDecl *FD) {
// Assume that all assignment operators with a "normal" return type return
// *this, that is, an lvalue reference that is the same type as the implicit
// object parameter (or the LHS for a non-member operator$=).
-static bool isNormalAssignmentOperator(const FunctionDecl* FD) {
+static bool isNormalAssignmentOperator(const FunctionDecl *FD) {
if (!FD)
return false;
OverloadedOperatorKind OO = FD->getDeclName().getCXXOverloadedOperator();
@@ -346,7 +346,6 @@ static bool isNormalAssignmentOperator(const FunctionDecl* FD) {
return false;
}
-
static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call,
LocalVisitor Visit) {
auto VisitPointerArg = [&](const Decl *D, Expr *Arg, bool Value) {
@@ -441,7 +440,8 @@ static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) {
return true;
}
- // Track the implicit object parameter if this is a normal assignment operator.
+ // Track the implicit object parameter if this is a normal assignment
+ // operator.
return isNormalAssignmentOperator(FD);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/97473
More information about the cfe-commits
mailing list