Static analyzer: add smart pointer checker

Hello,

I want to implement a smart pointer checker (std::shared_ptr,
std::unique) that catches specifying invalid type:

struct A
{
  A() { cout << "A()" << endl; }
  ~A() { cout << "~A()" << endl; }
};

void test()
{
  std::unique_ptr<A[]> p(new A[3]); // good, delete[] called
  std::unique_ptr<A> p(new A[3]); // bad, delete instead of delete[] called
}

Any comments?

Dmitri Gribenko

Seems fairly straightforward and wouldn't require much analysis. If this is specific to 'std', we could consider making this a compiler warning. I'm fine with trying this out as a static analyzer check first.

I should add that this seems useful and would have a low (possibly 0%) false positive rate. If it is always correct, it seems really worth doing as a compiler warning (with a FixIt) if that isn't unappealing to people.