Fixes a bug for binding memoized match results.

Intorduces an abstraction for DynTypedNode which makes
is impossible to create in ways that introduced the bug;
also hides the implementation details of the template
magic away from the user and prepares the code for adding
QualType and TypeLoc bindings, as well as using DynTypedNode
instead of overloads for child and ancestor matching.

getNodeAs<T> was changed towards a non-pointer type, as
we'll want QualType and TypeLoc nodes to be returned
by value (the alternative would be to create new storage
which is prohibitively costly if we want to use it for
child / ancestor matching).

DynTypedNode is moved into a new header ASTTypeTraits.h,
as it is completely independent of the rest of the matcher
infrastructure - if the need comes up, we can move it to
a more common place.

The interface for users before the introduction of the
common storage change remains the same, minus the introduced
bug, for which a regression test was added.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162936 91177308-0d34-0410-b5e6-96231b3b80d8
5 files changed