Rename NamedDecl::getName() to getNameAsString().  Replace a bunch of 
uses of getName() with uses of getDeclName().  This upgrades a bunch of
diags to take DeclNames instead of std::strings.

This also tweaks a couple of diagnostics to be cleaner and changes
CheckInitializerTypes/PerformInitializationByConstructor to pass
around DeclarationNames instead of std::strings.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59947 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 1b37051..4d0340b 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -776,7 +776,7 @@
   PerformInitializationByConstructor(QualType ClassType,
                                      Expr **Args, unsigned NumArgs,
                                      SourceLocation Loc, SourceRange Range,
-                                     std::string InitEntity,
+                                     DeclarationName InitEntity,
                                      InitializationKind Kind);
 
   /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
@@ -1262,7 +1262,7 @@
   /// type checking declaration initializers (C99 6.7.8)
   friend class InitListChecker;
   bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType,
-                             SourceLocation InitLoc, std::string InitEntity);
+                             SourceLocation InitLoc,DeclarationName InitEntity);
   bool CheckSingleInitializer(Expr *&simpleInit, QualType declType);
   bool CheckForConstantInitializer(Expr *e, QualType t);
   bool CheckArithmeticConstantExpression(const Expr* e);
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 8ffafad..4f71f06 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -492,7 +492,7 @@
   // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
   // TODO: This is totally simplistic.  It should handle merging functions
   // together etc, merging extern int X; int X; ...
-  Diag(New->getLocation(), diag::err_conflicting_types) << New->getName();
+  Diag(New->getLocation(), diag::err_conflicting_types) << New->getDeclName();
   Diag(Old->getLocation(), PrevDiag);
   return New;
 }
@@ -576,14 +576,14 @@
   if (New->getStorageClass() == VarDecl::Static &&
       (Old->getStorageClass() == VarDecl::None ||
        Old->getStorageClass() == VarDecl::Extern)) {
-    Diag(New->getLocation(), diag::err_static_non_static) << New->getName();
+    Diag(New->getLocation(), diag::err_static_non_static) << New->getDeclName();
     Diag(Old->getLocation(), diag::note_previous_definition);
     return New;
   }
   // C99 6.2.2p4: Check if we have a non-static decl followed by a static.
   if (New->getStorageClass() != VarDecl::Static &&
       Old->getStorageClass() == VarDecl::Static) {
-    Diag(New->getLocation(), diag::err_non_static_static) << New->getName();
+    Diag(New->getLocation(), diag::err_non_static_static) << New->getDeclName();
     Diag(Old->getLocation(), diag::note_previous_definition);
     return New;
   }
@@ -611,7 +611,7 @@
     if (Param->getType()->isIncompleteType() &&
         !Param->isInvalidDecl()) {
       Diag(Param->getLocation(), diag::err_typecheck_decl_incomplete_type)
-        << Param->getType().getAsString();
+        << Param->getType();
       Param->setInvalidDecl();
       HasInvalidParm = true;
     }
@@ -676,9 +676,9 @@
 
 bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
                                  SourceLocation InitLoc,
-                                 std::string InitEntity) {
+                                 DeclarationName InitEntity) {
   // C++ [dcl.init.ref]p1:
-  //   A variable declared to be a T&, that is “reference to type T”
+  //   A variable declared to be a T&, that isâ "reference to type Tâ"
   //   (8.3.2), shall be initialized by an object, or function, of
   //   type T or by an object that can be converted into a T.
   if (DeclType->isReferenceType())
@@ -734,7 +734,7 @@
         return false;
       
       return Diag(InitLoc, diag::err_typecheck_convert_incompatible)
-        << DeclType.getAsString() << InitEntity << "initializing"
+        << DeclType << InitEntity << "initializing"
         << Init->getSourceRange();
     }
 
@@ -859,7 +859,7 @@
         Diag(L, diag::err_invalid_declarator_in_function) << Name << R;
       } else {
         Diag(L, diag::err_invalid_declarator_scope)
-          << Name.getAsString() << cast<NamedDecl>(DC)->getName() << R;
+          << Name << cast<NamedDecl>(DC)->getDeclName() << R;
       }
     }
   }
@@ -1761,7 +1761,7 @@
       VDecl->setInvalidDecl();
     } else if (!VDecl->isInvalidDecl()) {
       if (CheckInitializerTypes(Init, DclT, VDecl->getLocation(),
-                                VDecl->getName()))
+                                VDecl->getDeclName()))
         VDecl->setInvalidDecl();
       
       // C++ 3.6.2p2, allow dynamic initialization of static initializers.
@@ -1775,7 +1775,7 @@
       Diag(VDecl->getLocation(), diag::warn_extern_init);
     if (!VDecl->isInvalidDecl())
       if (CheckInitializerTypes(Init, DclT, VDecl->getLocation(),
-                                VDecl->getName()))
+                                VDecl->getDeclName()))
         VDecl->setInvalidDecl();
     
     // C++ 3.6.2p2, allow dynamic initialization of static initializers.
@@ -1815,7 +1815,8 @@
     //   specifier is explicitly used.
     if (Type->isReferenceType() && Var->getStorageClass() != VarDecl::Extern) {
       Diag(Var->getLocation(), diag::err_reference_var_requires_init)
-       << Var->getName() << SourceRange(Var->getLocation(), Var->getLocation());
+        << Var->getDeclName()
+        << SourceRange(Var->getLocation(), Var->getLocation());
       Var->setInvalidDecl();
       return;
     }
@@ -1837,7 +1838,7 @@
                                                Var->getLocation(),
                                                SourceRange(Var->getLocation(),
                                                            Var->getLocation()),
-                                               Var->getName(),
+                                               Var->getDeclName(),
                                                IK_Default);
         if (!Constructor)
           Var->setInvalidDecl();
@@ -1918,8 +1919,7 @@
     if (IDecl->isBlockVarDecl() && 
         IDecl->getStorageClass() != VarDecl::Extern) {
       if (T->isIncompleteType() && !IDecl->isInvalidDecl()) {
-        Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type)
-          << T.getAsString();
+        Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type)<<T;
         IDecl->setInvalidDecl();
       }
     }
@@ -1936,8 +1936,7 @@
         // C99 6.9.2p3: If the declaration of an identifier for an object is
         // a tentative definition and has internal linkage (C99 6.2.2p3), the  
         // declared type shall not be an incomplete type.
-        Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type)
-          << T.getAsString();
+        Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type)<<T;
         IDecl->setInvalidDecl();
       }
     }
@@ -2716,7 +2715,7 @@
       // We discover this when we complete the outer S.  Reject and ignore the
       // outer S.
       Diag(DefRecord->getLocation(), diag::err_nested_redefinition)
-        << DefRecord->getKindName();
+        << DefRecord->getDeclName();
       Diag(RecLoc, diag::note_previous_definition);
       Record->setInvalidDecl();
       return;
@@ -2741,7 +2740,7 @@
     // C99 6.7.2.1p2 - A field may not be a function type.
     if (FDTy->isFunctionType()) {
       Diag(FD->getLocation(), diag::err_field_declared_as_function)
-        << FD->getName();
+        << FD->getDeclName();
       FD->setInvalidDecl();
       EnclosingDecl->setInvalidDecl();
       continue;
@@ -2749,7 +2748,7 @@
     // C99 6.7.2.1p2 - A field may not be an incomplete type except...
     if (FDTy->isIncompleteType()) {
       if (!Record) {  // Incomplete ivar type is always an error.
-        Diag(FD->getLocation(), diag::err_field_incomplete) << FD->getName();
+        Diag(FD->getLocation(), diag::err_field_incomplete) <<FD->getDeclName();
         FD->setInvalidDecl();
         EnclosingDecl->setInvalidDecl();
         continue;
@@ -2757,14 +2756,14 @@
       if (i != NumFields-1 ||                   // ... that the last member ...
           !Record->isStruct() ||  // ... of a structure ...
           !FDTy->isArrayType()) {         //... may have incomplete array type.
-        Diag(FD->getLocation(), diag::err_field_incomplete) << FD->getName();
+        Diag(FD->getLocation(), diag::err_field_incomplete) <<FD->getDeclName();
         FD->setInvalidDecl();
         EnclosingDecl->setInvalidDecl();
         continue;
       }
       if (NumNamedMembers < 1) {  //... must have more than named member ...
         Diag(FD->getLocation(), diag::err_flexible_array_empty_struct)
-          << FD->getName();
+          << FD->getDeclName();
         FD->setInvalidDecl();
         EnclosingDecl->setInvalidDecl();
         continue;
@@ -2786,7 +2785,7 @@
           // structures.
           if (i != NumFields-1) {
             Diag(FD->getLocation(), diag::err_variable_sized_type_in_struct)
-              << FD->getName();
+              << FD->getDeclName();
             FD->setInvalidDecl();
             EnclosingDecl->setInvalidDecl();
             continue;
@@ -2794,7 +2793,7 @@
           // We support flexible arrays at the end of structs in other structs
           // as an extension.
           Diag(FD->getLocation(), diag::ext_flexible_array_in_struct)
-            << FD->getName();
+            << FD->getDeclName();
           if (Record)
             Record->setHasFlexibleArrayMember(true);
         }
@@ -2942,7 +2941,8 @@
     //   enum e0 {
     //     E0 = sizeof(enum e0 { E1 })
     //   };
-    Diag(Enum->getLocation(), diag::err_nested_redefinition) << Enum->getName();
+    Diag(Enum->getLocation(), diag::err_nested_redefinition)
+      << Enum->getDeclName();
     Diag(EnumLoc, diag::note_previous_definition);
     Enum->setInvalidDecl();
     return;
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index d9f3bc6..b99f2e0 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -938,7 +938,7 @@
   TypeDecl *DeclaratorTypeD = (TypeDecl *)D.getDeclaratorIdType();
   if (const TypedefDecl *TypedefD = dyn_cast<TypedefDecl>(DeclaratorTypeD)) {
     Diag(D.getIdentifierLoc(),  diag::err_destructor_typedef_name)
-      << TypedefD->getName();
+      << TypedefD->getDeclName();
     isInvalid = true;
   }
 
@@ -1352,7 +1352,7 @@
                                            VDecl->getLocation(),
                                            SourceRange(VDecl->getLocation(),
                                                        RParenLoc),
-                                           VDecl->getName(),
+                                           VDecl->getDeclName(),
                                            IK_Direct);
     if (!Constructor) {
       RealDecl->setInvalidDecl();
@@ -1400,7 +1400,7 @@
 Sema::PerformInitializationByConstructor(QualType ClassType,
                                          Expr **Args, unsigned NumArgs,
                                          SourceLocation Loc, SourceRange Range,
-                                         std::string InitEntity,
+                                         DeclarationName InitEntity,
                                          InitializationKind Kind) {
   const RecordType *ClassRec = ClassType->getAsRecordType();
   assert(ClassRec && "Can only initialize a class type here");
@@ -1810,8 +1810,7 @@
   if (CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
     if (MethodDecl->isStatic())
       return Diag(FnDecl->getLocation(),
-                  diag::err_operator_overload_static)
-        << FnDecl->getName();
+                  diag::err_operator_overload_static) << FnDecl->getDeclName();
   } else {
     bool ClassOrEnumParam = false;
     for (FunctionDecl::param_iterator Param = FnDecl->param_begin(),
@@ -1827,7 +1826,7 @@
     if (!ClassOrEnumParam)
       return Diag(FnDecl->getLocation(),
                   diag::err_operator_overload_needs_class_or_enum)
-        << FnDecl->getName();
+        << FnDecl->getDeclName();
   }
 
   // C++ [over.oper]p8:
@@ -1842,7 +1841,7 @@
       if (Expr *DefArg = (*Param)->getDefaultArg())
         return Diag((*Param)->getLocation(),
                     diag::err_operator_overload_default_arg)
-          << FnDecl->getName() << DefArg->getSourceRange();
+          << FnDecl->getDeclName() << DefArg->getSourceRange();
     }
   }
 
@@ -1880,21 +1879,21 @@
     }
 
     return Diag(FnDecl->getLocation(), diag::err_operator_overload_must_be)
-      << FnDecl->getName() << NumParams << ErrorKind;
+      << FnDecl->getDeclName() << NumParams << ErrorKind;
   }
       
   // Overloaded operators other than operator() cannot be variadic.
   if (Op != OO_Call &&
       FnDecl->getType()->getAsFunctionTypeProto()->isVariadic()) {
     return Diag(FnDecl->getLocation(), diag::err_operator_overload_variadic)
-      << FnDecl->getName();
+      << FnDecl->getDeclName();
   }
 
   // Some operators must be non-static member functions.
   if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
     return Diag(FnDecl->getLocation(),
                 diag::err_operator_overload_must_be_member)
-      << FnDecl->getName();
+      << FnDecl->getDeclName();
   }
 
   // C++ [over.inc]p1:
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 9141cb5..4d4c82b 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -75,7 +75,7 @@
   if (IDecl) {
     // Class already seen. Is it a forward declaration?
     if (!IDecl->isForwardDecl()) {
-      Diag(AtInterfaceLoc, diag::err_duplicate_class_def) << IDecl->getName();
+      Diag(AtInterfaceLoc, diag::err_duplicate_class_def)<<IDecl->getDeclName();
       Diag(IDecl->getLocation(), diag::note_previous_definition);
 
       // Return the previous class interface.
@@ -1264,7 +1264,7 @@
     // Look for this property declaration in the @implementation's @interface
     property = IDecl->FindPropertyDeclaration(PropertyId);
     if (!property) {
-      Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getName();
+      Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getDeclName();
       return 0;
     }
   }
@@ -1289,7 +1289,7 @@
     property = Category->FindPropertyDeclaration(PropertyId);
     if (!property) {
       Diag(PropertyLoc, diag::error_bad_category_property_decl)
-        << Category->getName();
+        << Category->getDeclName();
       return 0;
     }
   }
@@ -1316,7 +1316,7 @@
     if (PropType != IvarType) {
       if (CheckAssignmentConstraints(PropType, IvarType) != Compatible) {
         Diag(PropertyLoc, diag::error_property_ivar_type)
-          << property->getName() << Ivar->getName();
+          << property->getDeclName() << Ivar->getDeclName();
         return 0;
       }
     }
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index fd72651..f81c2b8 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -431,11 +431,11 @@
       if (MD->isStatic())
         // "invalid use of member 'x' in static member function"
         return Diag(Loc, diag::err_invalid_member_use_in_static_method)
-           << FD->getName();
+           << FD->getDeclName();
       if (cast<CXXRecordDecl>(MD->getParent()) != FD->getParent())
         // "invalid use of nonstatic data member 'x'"
         return Diag(Loc, diag::err_invalid_non_static_member_use)
-          << FD->getName();
+          << FD->getDeclName();
 
       if (FD->isInvalidDecl())
         return true;
@@ -445,14 +445,15 @@
         FD->getType().getWithAdditionalQualifiers(MD->getTypeQualifiers()),Loc);
     }
 
-    return Diag(Loc, diag::err_invalid_non_static_member_use) << FD->getName();
+    return Diag(Loc, diag::err_invalid_non_static_member_use)
+      << FD->getDeclName();
   }
   if (isa<TypedefDecl>(D))
-    return Diag(Loc, diag::err_unexpected_typedef) << Name.getAsString();
+    return Diag(Loc, diag::err_unexpected_typedef) << Name;
   if (isa<ObjCInterfaceDecl>(D))
-    return Diag(Loc, diag::err_unexpected_interface) << Name.getAsString();
+    return Diag(Loc, diag::err_unexpected_interface) << Name;
   if (isa<NamespaceDecl>(D))
-    return Diag(Loc, diag::err_unexpected_namespace) << Name.getAsString();
+    return Diag(Loc, diag::err_unexpected_namespace) << Name;
 
   // Make the DeclRefExpr or BlockDeclRefExpr for the decl.
   if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D))
@@ -462,7 +463,7 @@
   
   // check if referencing an identifier with __attribute__((deprecated)).
   if (VD->getAttr<DeprecatedAttr>())
-    Diag(Loc, diag::warn_deprecated) << VD->getName();
+    Diag(Loc, diag::warn_deprecated) << VD->getDeclName();
 
   // Only create DeclRefExpr's for valid Decl's.
   if (VD->isInvalidDecl())
@@ -1135,7 +1136,7 @@
     RecordDecl *RDecl = RTy->getDecl();
     if (RTy->isIncompleteType())
       return Diag(OpLoc, diag::err_typecheck_incomplete_tag)
-               << RDecl->getName() << BaseExpr->getSourceRange();
+               << RDecl->getDeclName() << BaseExpr->getSourceRange();
     // The record definition is complete, now make sure the member is valid.
     FieldDecl *MemberDecl = RDecl->getMember(&Member);
     if (!MemberDecl)
@@ -1164,7 +1165,7 @@
       return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr, 
                                  OpKind == tok::arrow);
     return Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)
-             << IFTy->getDecl()->getName() << &Member
+             << IFTy->getDecl()->getDeclName() << &Member
              << BaseExpr->getSourceRange();
   }
   
@@ -1315,14 +1316,14 @@
     case OR_No_Viable_Function:
       Diag(Fn->getSourceRange().getBegin(), 
            diag::err_ovl_no_viable_function_in_call)
-        << Ovl->getName() << (unsigned)CandidateSet.size()
+        << Ovl->getDeclName() << (unsigned)CandidateSet.size()
         << Fn->getSourceRange();
       PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
       return true;
 
     case OR_Ambiguous:
       Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_ambiguous_call)
-        << Ovl->getName() << Fn->getSourceRange();
+        << Ovl->getDeclName() << Fn->getSourceRange();
       PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
       return true;
     }
@@ -1451,12 +1452,12 @@
         << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd());
   } else if (literalType->isIncompleteType()) {
     return Diag(LParenLoc, diag::err_typecheck_decl_incomplete_type)
-      << literalType.getAsString()
+      << literalType
       << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd());
   }
 
   if (CheckInitializerTypes(literalExpr, literalType, LParenLoc, 
-                            "temporary"))
+                            DeclarationName()))
     return true;
 
   bool isFileScope = !getCurFunctionDecl() && !getCurMethodDecl();
@@ -2399,8 +2400,7 @@
     } else {
       if ((lType->isObjCQualifiedIdType() && rType->isObjCQualifiedIdType())) {
         Diag(Loc, diag::warn_incompatible_qualified_id_operands)
-          << lType.getAsString() << rType.getAsString()
-          << lex->getSourceRange() << rex->getSourceRange();
+          << lType << rType << lex->getSourceRange() << rex->getSourceRange();
         ImpCastExprToType(rex, lType);
         return ResultTy;
       }
@@ -3696,7 +3696,7 @@
     break;
   }
   
-  Diag(Loc, DiagKind) << DstType.getAsString() << SrcType.getAsString()
-    << Flavor << SrcExpr->getSourceRange();
+  Diag(Loc, DiagKind) << DstType << SrcType << Flavor
+    << SrcExpr->getSourceRange();
   return isInvalid;
 }
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 80b5f20..f5f05f2 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -189,9 +189,8 @@
   QualType CheckType = AllocType;
   // To leverage the existing parser as much as possible, array types are
   // parsed as VLAs. Unwrap for checking.
-  if (const VariableArrayType *VLA = Context.getAsVariableArrayType(AllocType)){
+  if (const VariableArrayType *VLA = Context.getAsVariableArrayType(AllocType))
     CheckType = VLA->getElementType();
-  }
 
   // Validate the type, and unwrap an array if any.
   if (CheckAllocatedType(CheckType, StartLoc, SourceRange(TyStart, TyEnd)))
@@ -240,13 +239,13 @@
   // 2) Otherwise, the object is direct-initialized.
   CXXConstructorDecl *Constructor = 0;
   Expr **ConsArgs = (Expr**)ConstructorArgs;
-  if (CheckType->isRecordType()) {
+  if (const RecordType *RT = CheckType->getAsRecordType()) {
     // FIXME: This is incorrect for when there is an empty initializer and
     // no user-defined constructor. Must zero-initialize, not default-construct.
     Constructor = PerformInitializationByConstructor(
                       CheckType, ConsArgs, NumConsArgs,
                       TyStart, SourceRange(TyStart, ConstructorRParen),
-                      CheckType.getAsString(),
+                      RT->getDecl()->getDeclName(),
                       NumConsArgs != 0 ? IK_Direct : IK_Default);
     if (!Constructor)
       return true;
@@ -262,8 +261,9 @@
       // Object is value-initialized. Do nothing.
     } else if (NumConsArgs == 1) {
       // Object is direct-initialized.
+      // FIXME: WHAT DeclarationName do we pass in here?
       if (CheckInitializerTypes(ConsArgs[0], CheckType, StartLoc,
-                                CheckType.getAsString()))
+                                DeclarationName() /*CheckType.getAsString()*/))
         return true;
     } else {
       Diag(StartLoc, diag::err_builtin_direct_init_more_than_one_arg)
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 2225d67..094f3ec 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -193,7 +193,7 @@
       ClassDecl = getCurMethodDecl()->getClassInterface()->getSuperClass();
       if (!ClassDecl)
         return Diag(lbrac, diag::error_no_super_class)
-          << getCurMethodDecl()->getClassInterface()->getName();
+          << getCurMethodDecl()->getClassInterface()->getDeclName();
       if (getCurMethodDecl()->isInstance()) {
         QualType superTy = Context.getObjCInterfaceType(ClassDecl);
         superTy = Context.getPointerType(superTy);
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 3c2c0ab..976b4f7 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -210,7 +210,7 @@
     Before.DebugPrint();
     fprintf(stderr, " -> ");
   }
-  fprintf(stderr, "'%s'", ConversionFunction->getName().c_str());
+  fprintf(stderr, "'%s'", ConversionFunction->getNameAsString().c_str());
   if (After.First || After.Second || After.Third) {
     fprintf(stderr, " -> ");
     After.DebugPrint();
@@ -1401,17 +1401,17 @@
 
     return DiagnoseAssignmentResult(ConvTy, From->getLocStart(), ToType,
                                     FromType, From, Flavor);
-  } else if (ToType->isReferenceType()) {
-    return CheckReferenceInit(From, ToType);
-  } else {
-    if (PerformImplicitConversion(From, ToType))
-      return Diag(From->getSourceRange().getBegin(),
-                  diag::err_typecheck_convert_incompatible)
-        << ToType.getAsString() << From->getType().getAsString()
-        << Flavor << From->getSourceRange();
-    else
-      return false;
   }
+  
+  if (ToType->isReferenceType())
+    return CheckReferenceInit(From, ToType);
+
+  if (!PerformImplicitConversion(From, ToType))
+    return false;
+  
+  return Diag(From->getSourceRange().getBegin(),
+              diag::err_typecheck_convert_incompatible)
+    << ToType << From->getType() << Flavor << From->getSourceRange();
 }
 
 /// TryObjectArgumentInitialization - Try to initialize the object