If a method is resetting the state of an object that was moved from, it should
be safe to use this object again. However if the method was defined in a parent
class, but used in a child class, the reset didn't happen from the checker's
perspective.
Differential Revision: https://reviews.llvm.org/D31538
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315301
91177308-0d34-0410-b5e6-
96231b3b80d8
return;
if (isStateResetMethod(MethodDecl)) {
- State = State->remove<TrackedRegionMap>(ThisRegion);
+ // A state reset method resets the whole object, not only sub-object
+ // of a parent class in which it is defined.
+ const MemRegion *WholeObjectRegion = ThisRegion;
+ while (const CXXBaseObjectRegion *BR =
+ dyn_cast<CXXBaseObjectRegion>(WholeObjectRegion))
+ WholeObjectRegion = BR->getSuperRegion();
+
+ State = State->remove<TrackedRegionMap>(WholeObjectRegion);
C.addTransition(State);
return;
}
a.b.foo(); // no-warning
}
}
+
+class C: public A {};
+void resetSuperClass() {
+ C c;
+ C c1 = std::move(c);
+ c.clear();
+ C c2 = c; // no-warning
+}