================
@@ -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();
+ return nullptr;
+}
+
+static bool isNotDeferLockUniqueLock(const CallEvent &Call) {
+ // Use the constructor's declared parameter type to identify the defer_lock_t
+ // overload.
+ ArrayRef<ParmVarDecl *> Params = Call.parameters();
+ if (Params.size() < 2)
+ return true;
+ QualType ParamType = Params[1]->getType().getNonReferenceType();
+ if (const auto *RD = ParamType->getAsRecordDecl();
+ RD && RD->getName() == "defer_lock_t" && RD->isInStdNamespace())
----------------
steakhal wrote:
Same sentiment here.
```suggestion
const auto *RD = ParamType->getAsRecordDecl();
if (RD && RD->getName() == "defer_lock_t" && RD->isInStdNamespace())
```
Actually, thinking about this a bit longer we should just have:
```c++
return !(<cond>);
```
https://github.com/llvm/llvm-project/pull/224230
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits