Re-commit r183466 with a fix to make the TypeLoc casting machinery work
correctly in the presence of qualified types.

(I had to change the unittest because it was trying to cast a
QualifiedTypeLoc to TemplateSpecializationTypeLoc.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183563 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/AST/SourceLocationTest.cpp b/unittests/AST/SourceLocationTest.cpp
index 55356f1..990e6df 100644
--- a/unittests/AST/SourceLocationTest.cpp
+++ b/unittests/AST/SourceLocationTest.cpp
@@ -159,7 +159,7 @@
 protected:
   virtual SourceRange getRange(const TypeLoc &Node) {
     TemplateSpecializationTypeLoc T =
-        Node.castAs<TemplateSpecializationTypeLoc>();
+        Node.getUnqualifiedLoc().castAs<TemplateSpecializationTypeLoc>();
     assert(!T.isNull());
     return SourceRange(T.getLAngleLoc(), T.getRAngleLoc());
   }