[clang] [analyzer] [MallocChecker] suspect all release functions as candite for supression (PR #104599)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 31 09:49:39 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 f0df4fbd0c7b6bb369ceaa1fd6f9e0c88d781ae5 0ab7a5a7ee72a60b3a478a7c508779458348f993 --extensions cpp,c -- clang/test/Analysis/malloc-refcounted.c clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp clang/test/Analysis/NewDelete-atomics.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index f1194eb20f..1f2dd42ed9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -3552,8 +3552,8 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N,
const LocationContext *CurrentLC = N->getLocationContext();
// If we find an atomic fetch_add or fetch_sub within the function in which
- // the pointer was released (before the release), this is likely a release point
- // of reference-counted object (like shared pointer).
+ // the pointer was released (before the release), this is likely a release
+ // point of reference-counted object (like shared pointer).
//
// Because we don't model atomics, and also because we don't know that the
// original reference count is positive, we should not report use-after-frees
@@ -3567,7 +3567,8 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N,
if (Op == AtomicExpr::AO__c11_atomic_fetch_add ||
Op == AtomicExpr::AO__c11_atomic_fetch_sub) {
BR.markInvalid(getTag(), S);
- // After report is considered invalid there is no need to proceed futher.
+ // After report is considered invalid there is no need to proceed
+ // futher.
return nullptr;
}
} else if (const auto *CE = dyn_cast<CallExpr>(S)) {
@@ -3666,14 +3667,16 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N,
// object, so suppress the report for now.
BR.markInvalid(getTag(), DD);
- // After report is considered invalid there is no need to proceed futher.
+ // After report is considered invalid there is no need to proceed
+ // futher.
return nullptr;
}
// Switch suspection to outer destructor to catch patterns like:
//
// SmartPointr::~SmartPointr() {
- // if (__c11_atomic_fetch_sub(refcount, 1, memory_order_relaxed) == 1)
+ // if (__c11_atomic_fetch_sub(refcount, 1, memory_order_relaxed) ==
+ // 1)
// release_resources();
// }
// void SmartPointr::release_resources() {
@@ -3683,15 +3686,15 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N,
// This way ReleaseFunctionLC will point to outermost destructor and
// it would be possible to catch wider range of FP.
//
- // NOTE: it would be great to support smth like that in C, since currently
- // patterns like following won't be supressed:
- //
- // void doFree(struct Data *data) { free(data); }
- // void putData(struct Data *data)
- // {
- // if (refPut(data))
- // doFree(data);
- // }
+ // NOTE: it would be great to support smth like that in C, since
+ // currently patterns like following won't be supressed:
+ //
+ // void doFree(struct Data *data) { free(data); }
+ // void putData(struct Data *data)
+ // {
+ // if (refPut(data))
+ // doFree(data);
+ // }
ReleaseFunctionLC = LC->getStackFrame();
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/104599
More information about the cfe-commits
mailing list