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/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index 0074a93..905c697 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -400,8 +400,8 @@
     FullSourceLoc L(S->getLocStart(), BR.getSourceManager());
     
     if (VD->getType()->isPointerLikeType()) {
-      std::string msg = "'" + std::string(VD->getName()) +
-      "' now aliases '" + MostRecent->getName() + "'";
+      std::string msg = "'" + std::string(VD->getNameAsString()) +
+      "' now aliases '" + MostRecent->getNameAsString() + "'";
       
       PD.push_front(new PathDiagnosticPiece(L, msg));
     }
@@ -579,7 +579,7 @@
                 EnumConstantDecl* D = dyn_cast<EnumConstantDecl>(DR->getDecl());
                 if (D) {
                   GetRawInt = false;
-                  os << D->getName();
+                  os << D->getNameAsString();
                 }
               }
 
diff --git a/lib/Analysis/CheckDeadStores.cpp b/lib/Analysis/CheckDeadStores.cpp
index 2afc7e0..51943d50 100644
--- a/lib/Analysis/CheckDeadStores.cpp
+++ b/lib/Analysis/CheckDeadStores.cpp
@@ -41,7 +41,7 @@
   
   void Report(VarDecl* V, DeadStoreKind dsk, SourceLocation L, SourceRange R) {
 
-    std::string name(V->getName());
+    std::string name = V->getNameAsString();
     
     const char* BugType = 0;
     std::string msg;
diff --git a/lib/Analysis/CheckNSError.cpp b/lib/Analysis/CheckNSError.cpp
index f76b601..919c17d 100644
--- a/lib/Analysis/CheckNSError.cpp
+++ b/lib/Analysis/CheckNSError.cpp
@@ -251,7 +251,7 @@
     else
       os << "documented in CoreFoundation/CFError.h the parameter '";
     
-    os << Param->getName() << "' may be null.";
+    os << Param->getNameAsString() << "' may be null.";
     desc = os.str().c_str();
 
     BR.addNotableSymbol(SV->getSymbol());
diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp
index 6fba9ae..a9e5675 100644
--- a/lib/Analysis/CheckObjCDealloc.cpp
+++ b/lib/Analysis/CheckObjCDealloc.cpp
@@ -149,7 +149,7 @@
     
     std::string buf;
     llvm::raw_string_ostream os(buf);
-    os << "Objective-C class '" << D->getName()
+    os << "Objective-C class '" << D->getNameAsString()
        << "' lacks a 'dealloc' instance method";
     
     BR.EmitBasicReport(name, os.str().c_str(), D->getLocStart());
@@ -165,7 +165,8 @@
     
     std::string buf;
     llvm::raw_string_ostream os(buf);
-    os << "The 'dealloc' instance method in Objective-C class '" << D->getName()
+    os << "The 'dealloc' instance method in Objective-C class '"
+       << D->getNameAsString()
        << "' does not send a 'dealloc' message to its super class"
            " (missing [super dealloc])";
     
@@ -220,7 +221,7 @@
                ? "missing ivar release (leak)"
                : "missing ivar release (Hybrid MM, non-GC)";
         
-        os << "The '" << ID->getName()
+        os << "The '" << ID->getNameAsString()
            << "' instance variable was retained by a synthesized property but "
               "wasn't released in 'dealloc'";        
       } else {
@@ -228,7 +229,7 @@
                ? "extra ivar release (use-after-release)"
                : "extra ivar release (Hybrid MM, non-GC)";
         
-        os << "The '" << ID->getName()
+        os << "The '" << ID->getNameAsString()
            << "' instance variable was not retained by a synthesized property "
               "but was released in 'dealloc'";
       }
diff --git a/lib/Analysis/CheckObjCInstMethSignature.cpp b/lib/Analysis/CheckObjCInstMethSignature.cpp
index 00dbe9f..2d10079 100644
--- a/lib/Analysis/CheckObjCInstMethSignature.cpp
+++ b/lib/Analysis/CheckObjCInstMethSignature.cpp
@@ -49,16 +49,16 @@
     std::ostringstream os;
     
     os << "The Objective-C class '"
-       << MethDerived->getClassInterface()->getName()
+       << MethDerived->getClassInterface()->getNameAsString()
        << "', which is derived from class '"
-       << MethAncestor->getClassInterface()->getName()
+       << MethAncestor->getClassInterface()->getNameAsString()
        << "', defines the instance method '"
        << MethDerived->getSelector().getAsString()
        << "' whose return type is '"
        << ResDerived.getAsString()
        << "'.  A method with the same name (same selector) is also defined in "
           "class '"
-       << MethAncestor->getClassInterface()->getName()
+       << MethAncestor->getClassInterface()->getNameAsString()
        << "' and has a return type of '"
        << ResAncestor.getAsString()
        << "'.  These two types are incompatible, and may result in undefined "
diff --git a/lib/Analysis/CheckObjCUnusedIVars.cpp b/lib/Analysis/CheckObjCUnusedIVars.cpp
index c2deeef..ef7b318 100644
--- a/lib/Analysis/CheckObjCUnusedIVars.cpp
+++ b/lib/Analysis/CheckObjCUnusedIVars.cpp
@@ -98,8 +98,8 @@
     if (I->second == Unused) {
       
       std::ostringstream os;
-      os << "Instance variable '" << I->first->getName()
-         << "' in class '" << ID->getName() 
+      os << "Instance variable '" << I->first->getNameAsString()
+         << "' in class '" << ID->getNameAsString() 
          << "' is never used by the methods in its @implementation "
             "(although it may be used by category methods).";
 
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp
index 28a27b0..86f8571 100644
--- a/lib/Analysis/MemRegion.cpp
+++ b/lib/Analysis/MemRegion.cpp
@@ -145,7 +145,7 @@
 }
 
 void VarRegion::print(llvm::raw_ostream& os) const {
-  os << cast<VarDecl>(D)->getName();
+  os << cast<VarDecl>(D)->getNameAsString();
 }
 
 void SymbolicRegion::print(llvm::raw_ostream& os) const {
@@ -154,7 +154,7 @@
 
 void FieldRegion::print(llvm::raw_ostream& os) const {
   superRegion->print(os);
-  os << "->" << getDecl()->getName();
+  os << "->" << getDecl()->getNameAsString();
 }
 
 void ElementRegion::print(llvm::raw_ostream& os) const {
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 444ee7c..e862808 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -291,7 +291,7 @@
   // Create DIEnumerator elements for each enumerator.
   for (EnumConstantDecl *Elt = Decl->getEnumConstantList(); Elt;
        Elt = dyn_cast_or_null<EnumConstantDecl>(Elt->getNextDeclarator())) {
-    Enumerators.push_back(DebugFactory.CreateEnumerator(Elt->getName(),
+    Enumerators.push_back(DebugFactory.CreateEnumerator(Elt->getNameAsString(),
                                             Elt->getInitVal().getZExtValue()));
   }
   
@@ -484,7 +484,7 @@
   
   // Create the descriptor for the variable.
   llvm::DIVariable D = 
-    DebugFactory.CreateVariable(Tag, RegionStack.back(), Decl->getName(),
+    DebugFactory.CreateVariable(Tag, RegionStack.back(),Decl->getNameAsString(),
                                 Unit, Line,
                                 getOrCreateType(Decl->getType(), Unit));
   // Insert an llvm.dbg.declare into the current block.
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 4ad698a..bdbd5ca 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -649,7 +649,7 @@
 
   std::string FunctionName;
   if(const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl)) {
-    FunctionName = FD->getName();
+    FunctionName = FD->getNameAsString();
   } else {
     // Just get the mangled name.
     FunctionName = CurFn->getName();
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 32da770..3f2f99c 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -193,7 +193,7 @@
 // techniques can modify the name -> class mapping.
 llvm::Value *CGObjCGNU::GetClass(CGBuilderTy &Builder,
                                  const ObjCInterfaceDecl *OID) {
-  llvm::Value *ClassName = CGM.GetAddrOfConstantCString(OID->getName());
+  llvm::Value *ClassName = CGM.GetAddrOfConstantCString(OID->getNameAsString());
   ClassName = Builder.CreateStructGEP(ClassName, 0);
 
   llvm::Constant *ClassLookupFn =
@@ -565,7 +565,7 @@
 
 llvm::Value *CGObjCGNU::GenerateProtocolRef(CGBuilderTy &Builder, 
                                             const ObjCProtocolDecl *PD) {
-  return ExistingProtocols[PD->getName()];
+  return ExistingProtocols[PD->getNameAsString()];
 }
 
 void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
@@ -574,7 +574,7 @@
   llvm::SmallVector<std::string, 16> Protocols;
   for (ObjCProtocolDecl::protocol_iterator PI = PD->protocol_begin(),
        E = PD->protocol_end(); PI != E; ++PI)
-    Protocols.push_back((*PI)->getName());
+    Protocols.push_back((*PI)->getNameAsString());
   llvm::SmallVector<llvm::Constant*, 16> InstanceMethodNames;
   llvm::SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
   for (ObjCProtocolDecl::instmeth_iterator iter = PD->instmeth_begin(),
@@ -655,7 +655,7 @@
   const ObjCList<ObjCProtocolDecl> &Protos =ClassDecl->getReferencedProtocols();
   for (ObjCList<ObjCProtocolDecl>::iterator I = Protos.begin(),
        E = Protos.end(); I != E; ++I)
-    Protocols.push_back((*I)->getName());
+    Protocols.push_back((*I)->getNameAsString());
 
   std::vector<llvm::Constant*> Elements;
   Elements.push_back(MakeConstantString(CategoryName));
@@ -713,7 +713,8 @@
   for (ObjCInterfaceDecl::ivar_iterator iter = ClassDecl->ivar_begin(),
       endIter = ClassDecl->ivar_end() ; iter != endIter ; iter++) {
       // Store the name
-      IvarNames.push_back(CGM.GetAddrOfConstantCString((*iter)->getName()));
+      IvarNames.push_back(CGM.GetAddrOfConstantCString((*iter)
+                                                         ->getNameAsString()));
       // Get the type encoding for this ivar
       std::string TypeStr;
       Context.getObjCEncodingForType((*iter)->getType(), TypeStr);
@@ -751,7 +752,7 @@
   const ObjCList<ObjCProtocolDecl> &Protos =ClassDecl->getReferencedProtocols();
   for (ObjCList<ObjCProtocolDecl>::iterator I = Protos.begin(),
        E = Protos.end(); I != E; ++I)
-    Protocols.push_back((*I)->getName());
+    Protocols.push_back((*I)->getNameAsString());
 
 
 
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 975e386..67f6559 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -695,17 +695,17 @@
   Values[0] = EmitProtocolExtension(PD, OptInstanceMethods, OptClassMethods);
   Values[1] = GetClassName(PD->getIdentifier());
   Values[2] = 
-    EmitProtocolList(std::string("\01L_OBJC_PROTOCOL_REFS_")+PD->getName(),
+    EmitProtocolList("\01L_OBJC_PROTOCOL_REFS_" + PD->getNameAsString(),
                      PD->protocol_begin(),
                      PD->protocol_end());
   Values[3] = 
-    EmitMethodDescList(std::string("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_") 
-                       + PD->getName(),
+    EmitMethodDescList("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_"
+                          + PD->getNameAsString(),
                        "__OBJC,__cat_inst_meth,regular,no_dead_strip",
                        InstanceMethods);
   Values[4] = 
-    EmitMethodDescList(std::string("\01L_OBJC_PROTOCOL_CLASS_METHODS_") 
-                       + PD->getName(),
+    EmitMethodDescList("\01L_OBJC_PROTOCOL_CLASS_METHODS_" 
+                            + PD->getNameAsString(),
                        "__OBJC,__cat_cls_meth,regular,no_dead_strip",
                        ClassMethods);
   llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.ProtocolTy,
@@ -742,7 +742,7 @@
       new llvm::GlobalVariable(ObjCTypes.ProtocolTy, false,
                                llvm::GlobalValue::ExternalLinkage,
                                0,
-                               std::string("\01L_OBJC_PROTOCOL_")+PD->getName(),
+                               "\01L_OBJC_PROTOCOL_" + PD->getNameAsString(),
                                &CGM.getModule());
     Entry->setSection("__OBJC,__protocol,regular,no_dead_strip");
     UsedGlobals.push_back(Entry);
@@ -770,17 +770,17 @@
   std::vector<llvm::Constant*> Values(4);
   Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
   Values[1] = 
-    EmitMethodDescList(std::string("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_OPT_") 
-                       + PD->getName(),
+    EmitMethodDescList("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_OPT_" 
+                           + PD->getNameAsString(),
                        "__OBJC,__cat_inst_meth,regular,no_dead_strip",
                        OptInstanceMethods);
   Values[2] = 
-    EmitMethodDescList(std::string("\01L_OBJC_PROTOCOL_CLASS_METHODS_OPT_") 
-                       + PD->getName(),
+    EmitMethodDescList("\01L_OBJC_PROTOCOL_CLASS_METHODS_OPT_"
+                          + PD->getNameAsString(),
                        "__OBJC,__cat_cls_meth,regular,no_dead_strip",
                        OptClassMethods);
-  Values[3] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_PROTO_LIST_") + 
-                               PD->getName(),
+  Values[3] = EmitPropertyList("\01L_OBJC_$_PROP_PROTO_LIST_" + 
+                                   PD->getNameAsString(),
                                0,
                                PD->classprop_begin(),
                                PD->classprop_end());
@@ -796,8 +796,7 @@
       new llvm::GlobalVariable(ObjCTypes.ProtocolExtensionTy, false,
                                llvm::GlobalValue::InternalLinkage,
                                Init,
-                               (std::string("\01L_OBJC_PROTOCOLEXT_") + 
-                                PD->getName()),
+                               "\01L_OBJC_PROTOCOLEXT_" + PD->getNameAsString(),
                                &CGM.getModule());
   // No special section, but goes in llvm.used
   UsedGlobals.push_back(GV);
@@ -962,9 +961,8 @@
   const ObjCInterfaceDecl *Interface = OCD->getClassInterface();
   const ObjCCategoryDecl *Category = 
     Interface->FindCategoryDeclaration(OCD->getIdentifier());
-  std::string ExtName(std::string(Interface->getName()) +
-                      "_" +
-                      OCD->getName());
+  std::string ExtName(Interface->getNameAsString() + "_" +
+                      OCD->getNameAsString());
 
   std::vector<llvm::Constant*> InstanceMethods, ClassMethods;
   for (ObjCCategoryImplDecl::instmeth_iterator i = OCD->instmeth_begin(),
@@ -1081,7 +1079,7 @@
   ObjCInterfaceDecl *Interface = 
     const_cast<ObjCInterfaceDecl*>(ID->getClassInterface());
   llvm::Constant *Protocols = 
-    EmitProtocolList(std::string("\01L_OBJC_CLASS_PROTOCOLS_") + ID->getName(),
+    EmitProtocolList("\01L_OBJC_CLASS_PROTOCOLS_" + ID->getNameAsString(),
                      Interface->protocol_begin(),
                      Interface->protocol_end());
   const llvm::Type *InterfaceTy = 
@@ -1140,7 +1138,7 @@
   Values[ 5] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size);
   Values[ 6] = EmitIvarList(ID, false, InterfaceTy);
   Values[ 7] = 
-    EmitMethodList(std::string("\01L_OBJC_INSTANCE_METHODS_") + ID->getName(),
+    EmitMethodList("\01L_OBJC_INSTANCE_METHODS_" + ID->getNameAsString(),
                    "__OBJC,__inst_meth,regular,no_dead_strip",
                    InstanceMethods);
   // cache is always NULL.
@@ -1200,7 +1198,7 @@
   Values[ 5] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size);
   Values[ 6] = EmitIvarList(ID, true, InterfaceTy);
   Values[ 7] = 
-    EmitMethodList(std::string("\01L_OBJC_CLASS_METHODS_") + ID->getName(),
+    EmitMethodList("\01L_OBJC_CLASS_METHODS_" + ID->getNameAsString(),
                    "__OBJC,__inst_meth,regular,no_dead_strip",
                    Methods);
   // cache is always NULL.
@@ -1238,8 +1236,7 @@
 }
 
 llvm::Constant *CGObjCMac::EmitMetaClassRef(const ObjCInterfaceDecl *ID) {  
-  std::string Name("\01L_OBJC_METACLASS_");
-  Name += ID->getName();
+  std::string Name = "\01L_OBJC_METACLASS_" + ID->getNameAsString();
 
   // FIXME: Should we look these up somewhere other than the
   // module. Its a bit silly since we only generate these while
@@ -1278,8 +1275,7 @@
   Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
   // FIXME: Output weak_ivar_layout string.
   Values[1] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy);
-  Values[2] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_LIST_") + 
-                               ID->getName(),
+  Values[2] = EmitPropertyList("\01L_OBJC_$_PROP_LIST_" + ID->getNameAsString(),
                                ID,
                                ID->getClassInterface()->classprop_begin(),
                                ID->getClassInterface()->classprop_end());
@@ -1294,8 +1290,7 @@
     new llvm::GlobalVariable(ObjCTypes.ClassExtensionTy, false,
                              llvm::GlobalValue::InternalLinkage,
                              Init,
-                             (std::string("\01L_OBJC_CLASSEXT_") +
-                              ID->getName()),
+                             "\01L_OBJC_CLASSEXT_" + ID->getNameAsString(),
                              &CGM.getModule());
   // No special section, but goes in llvm.used
   UsedGlobals.push_back(GV);
@@ -1361,7 +1356,7 @@
     new llvm::GlobalVariable(Init->getType(), false,
                              llvm::GlobalValue::InternalLinkage,
                              Init,
-                             std::string(Prefix) + ID->getName(),
+                             Prefix + ID->getNameAsString(),
                              &CGM.getModule());
   if (ForClass) {
     GV->setSection("__OBJC,__cls_vars,regular,no_dead_strip");
@@ -2145,7 +2140,7 @@
   // FIXME: Find the mangling GCC uses.
   NameOut = (D->isInstance() ? "-" : "+");
   NameOut += '[';
-  NameOut += D->getClassInterface()->getName();
+  NameOut += D->getClassInterface()->getNameAsString();
   NameOut += ' ';
   NameOut += D->getSelector().getAsString();
   NameOut += ']';
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 2ff2bee..f0aa8b7 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -321,9 +321,7 @@
     llvm::GlobalValue *GA = 
       new llvm::GlobalAlias(aliasee->getType(),
                             llvm::Function::ExternalLinkage,
-                            D->getName(),
-                            aliasee,
-                            &getModule());
+                            D->getNameAsString(), aliasee, &getModule());
     
     llvm::GlobalValue *&Entry = GlobalDeclMap[D->getIdentifier()];
     if (Entry) {
@@ -482,7 +480,7 @@
   if (!Entry)
     Entry = new llvm::GlobalVariable(Ty, false, 
                                      llvm::GlobalValue::ExternalLinkage,
-                                     0, D->getName(), &getModule(), 0,
+                                     0, D->getNameAsString(), &getModule(), 0,
                                      ASTTy.getAddressSpace());
   
   // Make sure the result is of the correct type.
@@ -518,7 +516,7 @@
   if (!GV) {
     GV = new llvm::GlobalVariable(InitType, false, 
                                   llvm::GlobalValue::ExternalLinkage,
-                                  0, D->getName(), &getModule(), 0,
+                                  0, D->getNameAsString(), &getModule(), 0,
                                   ASTTy.getAddressSpace());
   } else if (GV->getType() != 
              llvm::PointerType::get(InitType, ASTTy.getAddressSpace())) {
@@ -542,7 +540,7 @@
     // Make a new global with the correct type
     GV = new llvm::GlobalVariable(InitType, false, 
                                   llvm::GlobalValue::ExternalLinkage,
-                                  0, D->getName(), &getModule(), 0,
+                                  0, D->getNameAsString(), &getModule(), 0,
                                   ASTTy.getAddressSpace());
     // Steal the name of the old global
     GV->takeName(OldGV);
@@ -630,7 +628,7 @@
   const llvm::Type *Ty = getTypes().ConvertType(D->getType());
   llvm::Function *F = llvm::Function::Create(cast<llvm::FunctionType>(Ty), 
                                              llvm::Function::ExternalLinkage,
-                                             D->getName(), &getModule());
+                                             D->getNameAsString(),&getModule());
   SetFunctionAttributes(D, F);
   return F;
 }
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index e49281d..18cfdea 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -291,7 +291,7 @@
     std::vector<const llvm::Type*> IvarTypes;
     CollectObjCIvarTypes(OIT.getDecl(), IvarTypes);
     llvm::Type *T = llvm::StructType::get(IvarTypes);
-    TheModule.addTypeName(std::string("struct.") + OIT.getDecl()->getName(), T);
+    TheModule.addTypeName("struct." + OIT.getDecl()->getNameAsString(), T);
     return T;
   }
       
@@ -315,9 +315,9 @@
     // Name the codegen type after the typedef name
     // if there is no tag type name available
     if (TD->getIdentifier())
-      TypeName += TD->getName();
+      TypeName += TD->getNameAsString();
     else if (const TypedefType *TdT = dyn_cast<TypedefType>(T))
-      TypeName += TdT->getDecl()->getName();
+      TypeName += TdT->getDecl()->getNameAsString();
     else
       TypeName += "anon";
     
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