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/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp
index 2903f99..69aedcc 100644
--- a/Driver/RewriteObjC.cpp
+++ b/Driver/RewriteObjC.cpp
@@ -506,7 +506,7 @@
     RewriteFunctionDecl(FD);
   } else if (VarDecl *FVD = dyn_cast<VarDecl>(D)) {
     // declared in <Foundation/NSString.h>
-    if (strcmp(FVD->getName(), "_NSConstantStringClassReference") == 0) {
+    if (strcmp(FVD->getIdentifierName(), "_NSConstantStringClassReference") == 0) {
       ConstantStringClassReference = FVD;
       return;
     }
@@ -1088,13 +1088,13 @@
     elementTypeAsString = ElementType.getAsString();
     buf += elementTypeAsString;
     buf += " ";
-    elementName = D->getName();
+    elementName = D->getIdentifierName();
     buf += elementName;
     buf += ";\n\t";
   }
   else {
     DeclRefExpr *DR = cast<DeclRefExpr>(S->getElement());
-    elementName = DR->getDecl()->getName();
+    elementName = DR->getDecl()->getIdentifierName();
     elementTypeAsString 
       = cast<ValueDecl>(DR->getDecl())->getType().getAsString();
   }
@@ -1694,7 +1694,7 @@
 
 void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) {
   // declared in <objc/objc.h>
-  if (strcmp(FD->getName(), "sel_registerName") == 0) {
+  if (strcmp(FD->getIdentifierName(), "sel_registerName") == 0) {
     SelGetUidFunctionDecl = FD;
     return;
   }
@@ -2299,8 +2299,8 @@
   // Create a call to objc_getProtocol("ProtocolName").
   llvm::SmallVector<Expr*, 8> ProtoExprs;
   QualType argType = Context->getPointerType(Context->CharTy);
-  ProtoExprs.push_back(new StringLiteral(Exp->getProtocol()->getName(),
-                                       strlen(Exp->getProtocol()->getName()),
+  ProtoExprs.push_back(new StringLiteral(Exp->getProtocol()->getIdentifierName(),
+                                       strlen(Exp->getProtocol()->getIdentifierName()),
                                        false, argType, SourceLocation(),
                                        SourceLocation()));
   CallExpr *ProtoExp = SynthesizeCallToFunctionDecl(GetProtocolFunctionDecl,
@@ -2343,7 +2343,8 @@
 void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
                                                std::string &Result) {
   assert(CDecl && "Class missing in SynthesizeObjCInternalStruct");
-  assert(CDecl->getName() && "Name missing in SynthesizeObjCInternalStruct");
+  assert(CDecl->getIdentifierName() && 
+         "Name missing in SynthesizeObjCInternalStruct");
   // Do not synthesize more than once.
   if (ObjCSynthesizedStructs.count(CDecl))
     return;
@@ -2922,15 +2923,15 @@
   
   // Build _objc_method_list for class's instance methods if needed
   RewriteObjCMethodsMetaData(IDecl->instmeth_begin(), IDecl->instmeth_end(), 
-                             true, "", IDecl->getName(), Result);
+                             true, "", IDecl->getIdentifierName(), Result);
   
   // Build _objc_method_list for class's class methods if needed
   RewriteObjCMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(),
-                             false, "", IDecl->getName(), Result);
+                             false, "", IDecl->getIdentifierName(), Result);
     
   // Protocols referenced in class declaration?
   RewriteObjCProtocolsMetaData(CDecl->getReferencedProtocols(),
-                               "CLASS", CDecl->getName(), Result);
+                               "CLASS", CDecl->getIdentifierName(), Result);
     
   
   // Declaration of class/meta-class metadata
@@ -3429,7 +3430,7 @@
 
 void RewriteObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
   SourceLocation FunLocStart = FD->getTypeSpecStartLoc();
-  const char *FuncName = FD->getName();
+  const char *FuncName = FD->getIdentifierName();
   
   SynthesizeBlockLiterals(FunLocStart, FuncName);
 }
@@ -3489,13 +3490,13 @@
   const BlockPointerType *CPT = 0;
   
   if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) {
-    closureName = DRE->getDecl()->getName();
+    closureName = DRE->getDecl()->getIdentifierName();
     CPT = DRE->getType()->getAsBlockPointerType();
   } else if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(Exp->getCallee())) {
-    closureName = CDRE->getDecl()->getName();
+    closureName = CDRE->getDecl()->getIdentifierName();
     CPT = CDRE->getType()->getAsBlockPointerType();
   } else if (MemberExpr *MExpr = dyn_cast<MemberExpr>(Exp->getCallee())) {
-    closureName = MExpr->getMemberDecl()->getName();
+    closureName = MExpr->getMemberDecl()->getIdentifierName();
     CPT = MExpr->getType()->getAsBlockPointerType();
   } else {
     assert(1 && "RewriteBlockClass: Bad type");
@@ -3812,15 +3813,15 @@
          E = BlockByCopyDecls.end(); I != E; ++I) {
       if (isObjCType((*I)->getType())) {
         // FIXME: Conform to ABI ([[obj retain] autorelease]).
-        FD = SynthBlockInitFunctionDecl((*I)->getName());
+        FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
         Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
       } else if (isBlockPointerType((*I)->getType())) {
-        FD = SynthBlockInitFunctionDecl((*I)->getName());
+        FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
         Arg = new DeclRefExpr(FD, FD->getType(), SourceLocation());
         Exp = new CStyleCastExpr(Context->VoidPtrTy, Arg, 
                                  Context->VoidPtrTy, SourceLocation(), SourceLocation());
       } else {
-        FD = SynthBlockInitFunctionDecl((*I)->getName());
+        FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
         Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
       }
       InitExprs.push_back(Exp); 
@@ -3828,7 +3829,7 @@
     // Output all "by ref" declarations.
     for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(), 
          E = BlockByRefDecls.end(); I != E; ++I) {
-      FD = SynthBlockInitFunctionDecl((*I)->getName());
+      FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
       Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
       Exp = new UnaryOperator(Exp, UnaryOperator::AddrOf,
                               Context->getPointerType(Exp->getType()), 
@@ -4064,7 +4065,8 @@
     if (VD->getInit()) {
       GlobalVarDecl = VD;
       RewriteFunctionBodyOrGlobalInitializer(VD->getInit());
-      SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(), VD->getName());
+      SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(), 
+                              VD->getIdentifierName());
       GlobalVarDecl = 0;
 
       // This is needed for blocks.