Make parsing a semantic analysis a little more robust following Sema
failures that involve malformed types, e.g., "typename X::foo" where
"foo" isn't a type, or "std::vector<void>" that doens't instantiate
properly.

Similarly, be a bit smarter in our handling of ambiguities that occur
in Sema::getTypeName, to eliminate duplicate error messages about
ambiguous name lookup.

This eliminates two XFAILs in test/SemaCXX, one of which was crying
out to us, trying to tell us that we were producing repeated error
messages.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68251 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 5db19a5..abc3ac0 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -870,8 +870,11 @@
   QualType Result = CheckTemplateIdType(Template, TemplateLoc, LAngleLoc,
                                         &TemplateArgs[0], TemplateArgs.size(),
                                         RAngleLoc);
-  
   TemplateArgsIn.release();
+
+  if (Result.isNull())
+    return true;
+
   return Result.getAsOpaquePtr();
 }
 
@@ -2102,6 +2105,8 @@
     return true;
 
   QualType T = CheckTypenameType(NNS, II, SourceRange(TypenameLoc, IdLoc));
+  if (T.isNull())
+    return true;
   return T.getAsOpaquePtr();
 }