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)