smart pointers

Hi!

in an ealier mail I already suggested using smart pointers, of course only for
high-level classes where no performance hit is incurred.

I just want to document an example why this could be beneficial even if the
ownership is well defined and therefore the developers don't think it's
necessary.

The constructor of Diagnostic gets a pointer to DiagnosticClient. I assume (hope :wink: )
that Diagnostic takes the ownership. As it is not documented and I know
that writing documentation for a changing code base is boring, it would be clear
if it took a llvm::Pointer<DiagnosticClient> (a reference counting smart pointer).

Now the constructor of Preprocessor gets a reference to Diagnostic. I assume
that Preprocessor uses the reference only during the constructor. As it is not
documented I let Diagnostic live at least as long as Preprocessor (which
turns out to be right when looking into the source).
It would be clear if it took a llvm::Pointer<Diagnostic>.

I'd like to say that llvm and clang are a really great thing, but something like
void setDiagnostics(Diagnostic &D) { Diags = &D; }
(turning a reference into a pointer and then keeping the pointer longer than
the function call) is like a mine field in the land of plenty.

- Jochen