Change a whole lot of diagnostics to take QualType's directly 
instead of converting them to strings first.  This also fixes a
bunch of minor inconsistencies in the diagnostics emitted by clang
and adds a bunch of FIXME's to DiagnosticKinds.def.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59948 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp
index c243fac..af1e2e0 100644
--- a/lib/Sema/SemaNamedCast.cpp
+++ b/lib/Sema/SemaNamedCast.cpp
@@ -109,8 +109,7 @@
     if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid) {
       // Cannot cast non-lvalue to reference type.
       Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
-        << "const_cast" << OrigDestType.getAsString()
-        << SrcExpr->getSourceRange();
+        << "const_cast" << OrigDestType << SrcExpr->getSourceRange();
       return;
     }
 
@@ -131,7 +130,7 @@
     // was a reference type, we converted it to a pointer above.
     // C++ 5.2.11p3: For two pointer types [...]
     Self.Diag(OpRange.getBegin(), diag::err_bad_const_cast_dest)
-      << OrigDestType.getAsString() << DestRange;
+      << OrigDestType << DestRange;
     return;
   }
   if (DestType->isFunctionPointerType()) {
@@ -139,7 +138,7 @@
     // C++ 5.2.11p2: [...] where T is any object type or the void type [...]
     // T is the ultimate pointee of source and target type.
     Self.Diag(OpRange.getBegin(), diag::err_bad_const_cast_dest)
-      << OrigDestType.getAsString() << DestRange;
+      << OrigDestType << DestRange;
     return;
   }
   SrcType = Self.Context.getCanonicalType(SrcType);
@@ -171,8 +170,7 @@
     if (SrcTypeArr->getSize() != DestTypeArr->getSize()) {
       // Different array sizes.
       Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
-        << "const_cast" << OrigDestType.getAsString()
-        << OrigSrcType.getAsString() << OpRange;
+        << "const_cast" << OrigDestType << OrigSrcType << OpRange;
       return;
     }
     SrcType = SrcTypeArr->getElementType().getUnqualifiedType();
@@ -184,8 +182,7 @@
   if (SrcType != DestType) {
     // Cast between unrelated types.
     Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
-      << "const_cast" << OrigDestType.getAsString()
-      << OrigSrcType.getAsString() << OpRange;
+      << "const_cast" << OrigDestType << OrigSrcType << OpRange;
     return;
   }
 }
@@ -207,8 +204,7 @@
     if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid) {
       // Cannot cast non-lvalue to reference type.
       Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
-        << "reinterpret_cast" << OrigDestType.getAsString()
-        << SrcExpr->getSourceRange();
+        << "reinterpret_cast" << OrigDestType << SrcExpr->getSourceRange();
       return;
     }
 
@@ -236,8 +232,7 @@
     // lvalue->reference, which is handled above, at least one of the two
     // arguments must be a pointer.
     Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
-      << "reinterpret_cast" << OrigDestType.getAsString()
-      << OrigSrcType.getAsString() << OpRange;
+      << "reinterpret_cast" << OrigDestType << OrigSrcType << OpRange;
     return;
   }
 
@@ -260,7 +255,7 @@
     if (Self.Context.getTypeSize(SrcType) >
         Self.Context.getTypeSize(DestType)) {
       Self.Diag(OpRange.getBegin(), diag::err_bad_reinterpret_cast_small_int)
-        << OrigDestType.getAsString() << DestRange;
+        << OrigDestType << DestRange;
     }
     return;
   }
@@ -276,16 +271,14 @@
     // With the valid non-pointer conversions out of the way, we can be even
     // more stringent.
     Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
-      << "reinterpret_cast" << OrigDestType.getAsString()
-      << OrigSrcType.getAsString() << OpRange;
+      << "reinterpret_cast" << OrigDestType << OrigSrcType << OpRange;
     return;
   }
 
   // C++ 5.2.10p2: The reinterpret_cast operator shall not cast away constness.
   if (CastsAwayConstness(Self, SrcType, DestType)) {
     Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away)
-      << "reinterpret_cast" << OrigDestType.getAsString()
-      << OrigSrcType.getAsString() << OpRange;
+      << "reinterpret_cast" << OrigDestType << OrigSrcType << OpRange;
     return;
   }
 
@@ -467,8 +460,7 @@
           // to a const violation.
           if (!DestPointee.isAtLeastAsQualifiedAs(SrcPointee)) {
             Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away)
-              << "static_cast" << DestType.getAsString()
-              << OrigSrcType.getAsString() << OpRange;
+              << "static_cast" << DestType << OrigSrcType << OpRange;
           }
           return;
         }
@@ -481,7 +473,7 @@
   // why every substep failed and, at the end, select the most specific and
   // report that.
   Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_generic)
-    << "static_cast" << DestType.getAsString() << OrigSrcType.getAsString()
+    << "static_cast" << DestType << OrigSrcType
     << OpRange;
 }
 
@@ -581,8 +573,7 @@
   // Must preserve cv, as always.
   if (!DestType.isAtLeastAsQualifiedAs(SrcType)) {
     Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away)
-      << "static_cast" << OrigDestType.getAsString()
-      << OrigSrcType.getAsString() << OpRange;
+      << "static_cast" << OrigDestType << OrigSrcType << OpRange;
     return TSC_Failed;
   }
 
@@ -610,8 +601,7 @@
     }
 
     Self.Diag(OpRange.getBegin(), diag::err_ambiguous_base_to_derived_cast)
-      << SrcType.getUnqualifiedType().getAsString()
-      << DestType.getUnqualifiedType().getAsString()
+      << SrcType.getUnqualifiedType() << DestType.getUnqualifiedType()
       << PathDisplayStr << OpRange;
     return TSC_Failed;
   }
@@ -619,8 +609,7 @@
   if (Paths.getDetectedVirtual() != 0) {
     QualType VirtualBase(Paths.getDetectedVirtual(), 0);
     Self.Diag(OpRange.getBegin(), diag::err_static_downcast_via_virtual)
-      << OrigSrcType.getAsString() << OrigDestType.getAsString()
-      << VirtualBase.getAsString() << OpRange;
+      << OrigSrcType << OrigDestType << VirtualBase << OpRange;
     return TSC_Failed;
   }
 
@@ -680,7 +669,7 @@
     DestPointee = DestReference->getPointeeType();
   } else {
     Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ref_or_ptr)
-      << OrigDestType.getAsString() << DestRange;
+      << OrigDestType << DestRange;
     return;
   }
 
@@ -690,12 +679,12 @@
   } else if (DestRecord) {
     if (!DestRecord->getDecl()->isDefinition()) {
       Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_incomplete)
-        << DestPointee.getUnqualifiedType().getAsString() << DestRange;
+        << DestPointee.getUnqualifiedType() << DestRange;
       return;
     }
   } else {
     Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class)
-      << DestPointee.getUnqualifiedType().getAsString() << DestRange;
+      << DestPointee.getUnqualifiedType() << DestRange;
     return;
   }
 
@@ -710,13 +699,13 @@
       SrcPointee = SrcPointer->getPointeeType();
     } else {
       Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ptr)
-        << OrigSrcType.getAsString() << SrcExpr->getSourceRange();
+        << OrigSrcType << SrcExpr->getSourceRange();
       return;
     }
   } else {
     if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid) {
       Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
-        << "dynamic_cast" << OrigDestType.getAsString() << OpRange;
+        << "dynamic_cast" << OrigDestType << OpRange;
     }
     SrcPointee = SrcType;
   }
@@ -725,14 +714,12 @@
   if (SrcRecord) {
     if (!SrcRecord->getDecl()->isDefinition()) {
       Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_incomplete)
-        << SrcPointee.getUnqualifiedType().getAsString()
-        << SrcExpr->getSourceRange();
+        << SrcPointee.getUnqualifiedType() << SrcExpr->getSourceRange();
       return;
     }
   } else {
     Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class)
-      << SrcPointee.getUnqualifiedType().getAsString()
-      << SrcExpr->getSourceRange();
+      << SrcPointee.getUnqualifiedType() << SrcExpr->getSourceRange();
     return;
   }
 
@@ -745,8 +732,7 @@
   // C++ 5.2.7p1: The dynamic_cast operator shall not cast away constness.
   if (!DestPointee.isAtLeastAsQualifiedAs(SrcPointee)) {
     Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_const_away)
-      << "dynamic_cast" << OrigDestType.getAsString()
-      << OrigSrcType.getAsString() << OpRange;
+      << "dynamic_cast" << OrigDestType << OrigSrcType << OpRange;
     return;
   }
 
@@ -760,7 +746,7 @@
   // Upcasts are resolved statically.
   if (DestRecord && Self.IsDerivedFrom(SrcPointee, DestPointee)) {
     Self.CheckDerivedToBaseConversion(SrcPointee, DestPointee,
-      OpRange.getBegin(), OpRange);
+                                      OpRange.getBegin(), OpRange);
     // Diagnostic already emitted on error.
     return;
   }
@@ -770,8 +756,7 @@
   assert(SrcDecl && "Definition missing");
   if (!cast<CXXRecordDecl>(SrcDecl)->isPolymorphic()) {
     Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic)
-      << SrcPointee.getUnqualifiedType().getAsString()
-      << SrcExpr->getSourceRange();
+      << SrcPointee.getUnqualifiedType() << SrcExpr->getSourceRange();
   }
 
   // Done. Everything else is run-time checks.