In this patch I've tried to fix some issue which was reported by user. We have this code:
#include <memory>
struct Base{
virtual ~Base() = default;
virtual void onTest() {};
};
struct Derived : Base {
void onTest() override {
}
};
class A {
std::unique_ptr<Base> base_;
public:
A() {
base_ = std::unique_ptr<Base>(new Derived); // Missing warning
}
};
void foo()
{
A a;
}So I've added one more check for this specific case.
NB: by this change clang-tidy can report some breaking changes, e.g.:
// Types will be different auto origin = std::unique_ptr<Base>(new Derived); auto modified = std::make_unique<Derived>();
Suggestions are welcomed.
I think getTypePtr() is redundant here, as getAllocatedType() seems to be a QualType. You can just use -> on a QualType to go to the underying Type