Implement pretty diagnostics when doing on-the-fly vector sizing (for vector component access).

For example, before this commit, the following diagnostics would be emitted...

ocu.c:49:12: error: incompatible types assigning 'float  __attribute__((ocu_vector_type(3)))' to 'float4'
    vec4_2 = vec4.rgb; // shorten
    ~~~~~~ ^ ~~~~~~~~
ocu.c:51:7: error: incompatible types assigning 'float  __attribute__((ocu_vector_type(2)))' to 'float'
    f = vec2.xx; // shorten
    ~ ^ ~~~~~~~

Now, the diagnostics look as you would expect...

ocu.c:49:12: error: incompatible types assigning 'float3' to 'float4'
    vec4_2 = vec4.rgb; // shorten
    ~~~~~~ ^ ~~~~~~~~
ocu.c:51:7: error: incompatible types assigning 'float2' to 'float'
    f = vec2.xx; // shorten
    ~ ^ ~~~~~~~



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40579 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 445b6b5..8646c1a 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -387,7 +387,15 @@
   unsigned CompSize = strlen(CompName.getName());
   if (CompSize == 1)
     return vecType->getElementType();
-  return Context.getOCUVectorType(vecType->getElementType(), CompSize);
+    
+  QualType VT = Context.getOCUVectorType(vecType->getElementType(), CompSize);
+  // Now look up the TypeDefDecl from the vector type. Without this, 
+  // diagostics look bad. We want OCU vector types to appear built-in.
+  for (unsigned i = 0, e = OCUVectorDecls.size(); i != e; ++i) {
+    if (OCUVectorDecls[i]->getUnderlyingType() == VT)
+      return Context.getTypedefType(OCUVectorDecls[i]);
+  }
+  return VT; // should never get here (a typedef type should always be found).
 }
 
 Action::ExprResult Sema::