[clang] [NFC][analyzer] Replace BlockInCriticalSection MutexDescriptor with C… (PR #224230)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 06:38:11 PDT 2026
================
@@ -25,16 +25,52 @@
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include <iterator>
#include <utility>
-#include <variant>
using namespace clang;
using namespace ento;
+static const MemRegion *getFirstArgRegion(const CallEvent &Call) {
+ return Call.getArgSVal(0).getAsRegion();
+}
+
+static const MemRegion *getCXXThisRegion(const CallEvent &Call) {
+ return cast<CXXMemberCall>(Call).getCXXThisVal().getAsRegion();
+}
+
+static const MemRegion *getObjectUnderConstruction(const CallEvent &Call) {
+ if (std::optional<SVal> Object = Call.getReturnValueUnderConstruction())
+ return Object->getAsRegion();
+ return nullptr;
+}
+
+static const MemRegion *getCXXDestructorThisRegion(const CallEvent &Call) {
+ // An explicit destructor call (p->~T()) is a CXXMemberCall, not a
+ // CXXDestructorCall, so accept both.
+ if (const auto *Dtor = dyn_cast<CXXDestructorCall>(&Call))
+ return Dtor->getCXXThisVal().getAsRegion();
+ if (const auto *Member = dyn_cast<CXXMemberCall>(&Call);
+ Member && isa_and_nonnull<CXXDestructorDecl>(Member->getDecl()))
+ return Member->getCXXThisVal().getAsRegion();
----------------
steakhal wrote:
This way the whole condition expr fits in a single line - usually easier to read.
Alternatively, you can keep the previous code but add braces.
```suggestion
const auto *Member = dyn_cast<CXXMemberCall>(&Call);
if (Member && isa_and_nonnull<CXXDestructorDecl>(Member->getDecl()))
return Member->getCXXThisVal().getAsRegion();
```
https://github.com/llvm/llvm-project/pull/224230
More information about the cfe-commits
mailing list