Support the same attribute that the tidy version of this check already supports.
Also do some minor cleanups.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Yay, these look useful. Is there also an attribute for methods that should never be called on a 'moved-from' object?
I do not know about such attribute, but once contracts are implemented and wide-spread, a precondition on a method/function is a strong suggestion that it should not be used on a moved-from object.
Well, that actually sounds like a pretty good heuristic, as long as we know that a moved-from object cannot reliably satisfy these contracts. In other words, it'll probably be fine for most library classes, but my concern is that the more contracts do we document this way, the more false positives would we have, which is not a healthy correlation. Like, for example, if we add a contract "the object is in a consistent state" to all methods of an STL object, eg. something like this->_length == strlen(this->_buf) for std::string methods, it might be a valid contract, but all moved-from objects would trivially satisfy it (because they are guaranteed to be in a consistent albeit unspecified state), so we won't be able to all any method at all.