Introduction the DeclarationName class, as a single, general method of
representing the names of declarations in the C family of
languages. DeclarationName is used in NamedDecl to store the name of
the declaration (naturally), and ObjCMethodDecl is now a NamedDecl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59441 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 1ecaaa3..4807369 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -877,9 +877,13 @@
       bool isInvalidDecl = CheckConstructorDeclarator(D, R, SC);
 
       // Create the new declaration
+      QualType ClassType = Context.getTypeDeclType(cast<CXXRecordDecl>(DC));
+      ClassType = Context.getCanonicalType(ClassType);
+      DeclarationName ConName
+        = Context.DeclarationNames.getCXXConstructorName(ClassType);
       NewFD = CXXConstructorDecl::Create(Context, 
                                          cast<CXXRecordDecl>(DC),
-                                         D.getIdentifierLoc(), II, R,
+                                         D.getIdentifierLoc(), ConName, R,
                                          isExplicit, isInline,
                                          /*isImplicitlyDeclared=*/false);
 
@@ -890,9 +894,14 @@
       if (DC->isCXXRecord()) {
         bool isInvalidDecl = CheckDestructorDeclarator(D, R, SC);
 
+        QualType ClassType = Context.getTypeDeclType(cast<CXXRecordDecl>(DC));
+        ClassType = Context.getCanonicalType(ClassType);
+        DeclarationName DesName
+          = Context.DeclarationNames.getCXXDestructorName(ClassType);
+
         NewFD = CXXDestructorDecl::Create(Context,
                                           cast<CXXRecordDecl>(DC),
-                                          D.getIdentifierLoc(), II, R, 
+                                          D.getIdentifierLoc(), DesName, R, 
                                           isInline,
                                           /*isImplicitlyDeclared=*/false);
 
@@ -916,9 +925,14 @@
       } else {
         bool isInvalidDecl = CheckConversionDeclarator(D, R, SC);
 
+        QualType ConvType = R->getAsFunctionType()->getResultType();
+        ConvType = Context.getCanonicalType(ConvType);
+        DeclarationName ConvName
+          = Context.DeclarationNames.getCXXConversionFunctionName(ConvType);
+
         NewFD = CXXConversionDecl::Create(Context, 
                                           cast<CXXRecordDecl>(DC),
-                                          D.getIdentifierLoc(), II, R,
+                                          D.getIdentifierLoc(), ConvName, R,
                                           isInline, isExplicit);
         
         if (isInvalidDecl)
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index f8369b3..2fb1332 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -725,6 +725,9 @@
 /// [special]p1).  This routine can only be executed just before the
 /// definition of the class is complete.
 void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
+  QualType ClassType = Context.getTypeDeclType(ClassDecl);
+  ClassType = Context.getCanonicalType(ClassType);
+
   if (!ClassDecl->hasUserDeclaredConstructor()) {
     // C++ [class.ctor]p5:
     //   A default constructor for a class X is a constructor of class X
@@ -732,10 +735,11 @@
     //   user-declared constructor for class X, a default constructor is
     //   implicitly declared. An implicitly-declared default constructor
     //   is an inline public member of its class.
+    DeclarationName Name 
+      = Context.DeclarationNames.getCXXConstructorName(ClassType);
     CXXConstructorDecl *DefaultCon = 
       CXXConstructorDecl::Create(Context, ClassDecl,
-                                 ClassDecl->getLocation(),
-                                 &Context.Idents.getConstructorId(),
+                                 ClassDecl->getLocation(), Name,
                                  Context.getFunctionType(Context.VoidTy,
                                                          0, 0, false, 0),
                                  /*isExplicit=*/false,
@@ -798,10 +802,11 @@
 
     //  An implicitly-declared copy constructor is an inline public
     //  member of its class.
+    DeclarationName Name 
+      = Context.DeclarationNames.getCXXConstructorName(ClassType);
     CXXConstructorDecl *CopyConstructor
       = CXXConstructorDecl::Create(Context, ClassDecl,
-                                   ClassDecl->getLocation(),
-                                   &Context.Idents.getConstructorId(),
+                                   ClassDecl->getLocation(), Name,
                                    Context.getFunctionType(Context.VoidTy,
                                                            &ArgType, 1,
                                                            false, 0),
@@ -825,10 +830,11 @@
     //   If a class has no user-declared destructor, a destructor is
     //   declared implicitly. An implicitly-declared destructor is an
     //   inline public member of its class.
+    DeclarationName Name 
+      = Context.DeclarationNames.getCXXDestructorName(ClassType);
     CXXDestructorDecl *Destructor 
       = CXXDestructorDecl::Create(Context, ClassDecl,
-                                  ClassDecl->getLocation(),
-                                  &Context.Idents.getConstructorId(),
+                                  ClassDecl->getLocation(), Name,
                                   Context.getFunctionType(Context.VoidTy,
                                                           0, 0, false, 0),
                                   /*isInline=*/true,
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 6c17d5f..8eeb2d3 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -302,7 +302,8 @@
          E = IDecl->classprop_end(); I != E; ++I) {
       ObjCPropertyDecl *PDecl = (*I);
       if (SuperPDecl->getIdentifier() == PDecl->getIdentifier())
-          DiagnosePropertyMismatch(PDecl, SuperPDecl, SDecl->getName());
+          DiagnosePropertyMismatch(PDecl, SuperPDecl, 
+                                   SDecl->getIdentifierName());
     }
   }
 }
@@ -329,7 +330,7 @@
       mergeProperties.push_back(Pr);
     else
       // Property protocol already exist in class. Diagnose any mismatch.
-      DiagnosePropertyMismatch((*CP), Pr, PDecl->getName());
+      DiagnosePropertyMismatch((*CP), Pr, PDecl->getIdentifierName());
     }
   IDecl->mergeProperties(&mergeProperties[0], mergeProperties.size());
 }
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 58ab5aa..f18b98f 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -209,7 +209,7 @@
     Before.DebugPrint();
     fprintf(stderr, " -> ");
   }
-  fprintf(stderr, "'%s'", ConversionFunction->getName());
+  fprintf(stderr, "'%s'", ConversionFunction->getName().c_str());
   if (After.First || After.Second || After.Third) {
     fprintf(stderr, " -> ");
     After.DebugPrint();