[cfe-commits] r59936 - in /cfe/trunk: Driver/RewriteBlocks.cpp Driver/RewriteObjC.cpp include/clang/AST/Decl.h include/clang/Basic/DiagnosticKinds.def lib/AST/DeclObjC.cpp lib/AST/StmtDumper.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGObjCGNU.cpp lib/CodeGen/CGObjCMac.cpp lib/CodeGen/CodeGenFunction.cpp lib/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp test/SemaObjC/property-3.m test/SemaObjC/property-4.m

Chris Lattner sabre at nondot.org
Sun Nov 23 19:54:41 PST 2008


Author: lattner
Date: Sun Nov 23 21:54:41 2008
New Revision: 59936

URL: http://llvm.org/viewvc/llvm-project?rev=59936&view=rev
Log:
Rename NamedDecl::getIdentifierName() to ::getNameAsCString() and make it
assert if the name is not an identifier.  Update callers to do the right
thing and avoid this method in unsafe cases.  This also fixes an objc
warning that was missing a space, and migrates a couple more to taking
IdentifierInfo and QualTypes instead of std::strings.


Modified:
    cfe/trunk/Driver/RewriteBlocks.cpp
    cfe/trunk/Driver/RewriteObjC.cpp
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/AST/StmtDumper.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/property-3.m
    cfe/trunk/test/SemaObjC/property-4.m

Modified: cfe/trunk/Driver/RewriteBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteBlocks.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteBlocks.cpp (original)
+++ cfe/trunk/Driver/RewriteBlocks.cpp Sun Nov 23 21:54:41 2008
@@ -618,7 +618,7 @@
 
 void RewriteBlocks::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
   SourceLocation FunLocStart = FD->getTypeSpecStartLoc();
-  const char *FuncName = FD->getIdentifierName();
+  const char *FuncName = FD->getNameAsCString();
   
   SynthesizeBlockLiterals(FunLocStart, FuncName);
 }
@@ -675,13 +675,13 @@
   const BlockPointerType *CPT = 0;
   
   if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) {
-    closureName = DRE->getDecl()->getIdentifierName();
+    closureName = DRE->getDecl()->getNameAsCString();
     CPT = DRE->getType()->getAsBlockPointerType();
   } else if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(Exp->getCallee())) {
-    closureName = CDRE->getDecl()->getIdentifierName();
+    closureName = CDRE->getDecl()->getNameAsCString();
     CPT = CDRE->getType()->getAsBlockPointerType();
   } else if (MemberExpr *MExpr = dyn_cast<MemberExpr>(Exp->getCallee())) {
-    closureName = MExpr->getMemberDecl()->getIdentifierName();
+    closureName = MExpr->getMemberDecl()->getNameAsCString();
     CPT = MExpr->getType()->getAsBlockPointerType();
   } else {
     assert(1 && "RewriteBlockClass: Bad type");
@@ -1110,7 +1110,7 @@
           // Do the rewrite, using S.size() which contains the rewritten size.
           ReplaceText(CBE->getLocStart(), S.size(), Init.c_str(), Init.size());
           SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(), 
-                                  VD->getIdentifierName());
+                                  VD->getNameAsCString());
         } else if (CastExpr *CE = dyn_cast<CastExpr>(VD->getInit())) {
           RewriteCastExpr(CE);
         }

Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Sun Nov 23 21:54:41 2008
@@ -505,7 +505,7 @@
     RewriteFunctionDecl(FD);
   } else if (VarDecl *FVD = dyn_cast<VarDecl>(D)) {
     // declared in <Foundation/NSString.h>
-    if (strcmp(FVD->getIdentifierName(), "_NSConstantStringClassReference") == 0) {
+    if (strcmp(FVD->getNameAsCString(), "_NSConstantStringClassReference") == 0) {
       ConstantStringClassReference = FVD;
       return;
     }
@@ -1085,13 +1085,13 @@
     elementTypeAsString = ElementType.getAsString();
     buf += elementTypeAsString;
     buf += " ";
-    elementName = D->getIdentifierName();
+    elementName = D->getNameAsCString();
     buf += elementName;
     buf += ";\n\t";
   }
   else {
     DeclRefExpr *DR = cast<DeclRefExpr>(S->getElement());
-    elementName = DR->getDecl()->getIdentifierName();
+    elementName = DR->getDecl()->getNameAsCString();
     elementTypeAsString 
       = cast<ValueDecl>(DR->getDecl())->getType().getAsString();
   }
@@ -1703,7 +1703,7 @@
 
 void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) {
   // declared in <objc/objc.h>
-  if (strcmp(FD->getIdentifierName(), "sel_registerName") == 0) {
+  if (strcmp(FD->getNameAsCString(), "sel_registerName") == 0) {
     SelGetUidFunctionDecl = FD;
     return;
   }
@@ -2308,8 +2308,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()->getIdentifierName(),
-                                       strlen(Exp->getProtocol()->getIdentifierName()),
+  ProtoExprs.push_back(new StringLiteral(Exp->getProtocol()->getNameAsCString(),
+                                       strlen(Exp->getProtocol()->getNameAsCString()),
                                        false, argType, SourceLocation(),
                                        SourceLocation()));
   CallExpr *ProtoExp = SynthesizeCallToFunctionDecl(GetProtocolFunctionDecl,
@@ -2352,7 +2352,7 @@
 void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
                                                std::string &Result) {
   assert(CDecl && "Class missing in SynthesizeObjCInternalStruct");
-  assert(CDecl->getIdentifierName() && 
+  assert(CDecl->getNameAsCString() && 
          "Name missing in SynthesizeObjCInternalStruct");
   // Do not synthesize more than once.
   if (ObjCSynthesizedStructs.count(CDecl))
@@ -2932,15 +2932,15 @@
   
   // Build _objc_method_list for class's instance methods if needed
   RewriteObjCMethodsMetaData(IDecl->instmeth_begin(), IDecl->instmeth_end(), 
-                             true, "", IDecl->getIdentifierName(), Result);
+                             true, "", IDecl->getNameAsCString(), Result);
   
   // Build _objc_method_list for class's class methods if needed
   RewriteObjCMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(),
-                             false, "", IDecl->getIdentifierName(), Result);
+                             false, "", IDecl->getNameAsCString(), Result);
     
   // Protocols referenced in class declaration?
   RewriteObjCProtocolsMetaData(CDecl->getReferencedProtocols(),
-                               "CLASS", CDecl->getIdentifierName(), Result);
+                               "CLASS", CDecl->getNameAsCString(), Result);
     
   
   // Declaration of class/meta-class metadata
@@ -3439,7 +3439,7 @@
 
 void RewriteObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
   SourceLocation FunLocStart = FD->getTypeSpecStartLoc();
-  const char *FuncName = FD->getIdentifierName();
+  const char *FuncName = FD->getNameAsCString();
   
   SynthesizeBlockLiterals(FunLocStart, FuncName);
 }
@@ -3499,13 +3499,13 @@
   const BlockPointerType *CPT = 0;
   
   if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) {
-    closureName = DRE->getDecl()->getIdentifierName();
+    closureName = DRE->getDecl()->getNameAsCString();
     CPT = DRE->getType()->getAsBlockPointerType();
   } else if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(Exp->getCallee())) {
-    closureName = CDRE->getDecl()->getIdentifierName();
+    closureName = CDRE->getDecl()->getNameAsCString();
     CPT = CDRE->getType()->getAsBlockPointerType();
   } else if (MemberExpr *MExpr = dyn_cast<MemberExpr>(Exp->getCallee())) {
-    closureName = MExpr->getMemberDecl()->getIdentifierName();
+    closureName = MExpr->getMemberDecl()->getNameAsCString();
     CPT = MExpr->getType()->getAsBlockPointerType();
   } else {
     assert(1 && "RewriteBlockClass: Bad type");
@@ -3822,15 +3822,15 @@
          E = BlockByCopyDecls.end(); I != E; ++I) {
       if (isObjCType((*I)->getType())) {
         // FIXME: Conform to ABI ([[obj retain] autorelease]).
-        FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
+        FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
         Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
       } else if (isBlockPointerType((*I)->getType())) {
-        FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
+        FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
         Arg = new DeclRefExpr(FD, FD->getType(), SourceLocation());
         Exp = new CStyleCastExpr(Context->VoidPtrTy, Arg, 
                                  Context->VoidPtrTy, SourceLocation(), SourceLocation());
       } else {
-        FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
+        FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
         Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
       }
       InitExprs.push_back(Exp); 
@@ -3838,7 +3838,7 @@
     // Output all "by ref" declarations.
     for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(), 
          E = BlockByRefDecls.end(); I != E; ++I) {
-      FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
+      FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
       Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
       Exp = new UnaryOperator(Exp, UnaryOperator::AddrOf,
                               Context->getPointerType(Exp->getType()), 
@@ -4075,7 +4075,7 @@
       GlobalVarDecl = VD;
       RewriteFunctionBodyOrGlobalInitializer(VD->getInit());
       SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(), 
-                              VD->getIdentifierName());
+                              VD->getNameAsCString());
       GlobalVarDecl = 0;
 
       // This is needed for blocks.

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sun Nov 23 21:54:41 2008
@@ -79,15 +79,12 @@
   /// name (C++ constructor, Objective-C selector, etc.).
   IdentifierInfo *getIdentifier() const { return Name.getAsIdentifierInfo(); }
 
-  /// getIdentifierName - Get the name of identifier for this
-  /// declaration as a string. If the declaration has no name, or if
-  /// the name is a special name (C++ constructor, Objective-C
-  /// selector, etc.), returns NULL.
-  const char *getIdentifierName() const {
-    if (IdentifierInfo *II = getIdentifier())
-      return II->getName();
-    else
-      return 0;
+  /// getNameAsCString - Get the name of identifier for this declaration as a
+  /// C string (const char*).  This requires that the declaration have a name
+  /// and that it be a simple identifier.
+  const char *getNameAsCString() const {
+    assert(getIdentifier() && "Name is not a simple identifier");
+    return getIdentifier()->getName();
   }
 
   /// getDeclName - Get the actual, stored name of the declaration,

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Sun Nov 23 21:54:41 2008
@@ -557,12 +557,12 @@
      "setter method is needed to assign to object using property"
      " assignment syntax")
 DIAG(warn_readonly_property, WARNING,
-     "attribute 'readonly' of property '%0' restricts attribute "
-     "'readwrite' of property inherited from '%1'")
+     "attribute 'readonly' of property %0 restricts attribute "
+     "'readwrite' of property inherited from %1")
 DIAG(warn_property_attribute, WARNING,
-     "property '%0' '%1' attribute does not match the property inherited from'%2' ")
+     "property %0 '%1' attribute does not match the property inherited from %2")
 DIAG(warn_property_type, WARNING,
-     "property type '%0' does not match property type inherited from '%1'")
+     "property type %0 does not match property type inherited from %1")
 
 /// C++ parser diagnostics
 DIAG(err_expected_unqualified_id, ERROR,

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sun Nov 23 21:54:41 2008
@@ -758,11 +758,11 @@
   // syntesized method name is a concatenation of -/+[class-name selector]
   // Get length of this name.
   unsigned length = 3;  // _I_ or _C_
-  length += strlen(getClassInterface()->getIdentifierName()) +1; // extra for _
+  length += getClassInterface()->getNameAsString().size()+1; // extra for _
   NamedDecl *MethodContext = getMethodContext();
   if (ObjCCategoryImplDecl *CID = 
       dyn_cast<ObjCCategoryImplDecl>(MethodContext))
-    length += strlen(CID->getIdentifierName()) +1;
+    length += CID->getNameAsString().size()+1;
   length += getSelector().getAsString().size(); // selector name
   return length; 
 }

Modified: cfe/trunk/lib/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtDumper.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtDumper.cpp (original)
+++ cfe/trunk/lib/AST/StmtDumper.cpp Sun Nov 23 21:54:41 2008
@@ -203,7 +203,7 @@
   if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
     fprintf(F, "\"typedef %s %s\"",
             localType->getUnderlyingType().getAsString().c_str(),
-            localType->getIdentifierName());
+            localType->getNameAsString().c_str());
   } else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
     fprintf(F, "\"");
     // Emit storage class for vardecls.
@@ -304,8 +304,7 @@
   DumpExpr(Node);
 
   fprintf(F, " %sDecl='%s' %p", Node->getDecl()->getDeclKindName(), 
-                            Node->getDecl()->getIdentifierName(), 
-          (void*)Node->getDecl());
+          Node->getDecl()->getNameAsString().c_str(), (void*)Node->getDecl());
   if (Node->isFreeIvar())
     fprintf(F, " isFreeIvar");
 }
@@ -464,14 +463,14 @@
   DumpExpr(Node);
   
   fprintf(F, " ");
-  fprintf(F, "%s", Node->getProtocol()->getIdentifierName());
+  fprintf(F, "%s", Node->getProtocol()->getNameAsString().c_str());
 }
 
 void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
   DumpExpr(Node);
 
   fprintf(F, " Kind=PropertyRef Property=\"%s\"", 
-          Node->getProperty()->getIdentifierName());
+          Node->getProperty()->getNameAsString().c_str());
 }
 
 void StmtDumper::VisitObjCKVCRefExpr(ObjCKVCRefExpr *Node) {

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sun Nov 23 21:54:41 2008
@@ -152,7 +152,7 @@
   
   // We don't set size information, but do specify where the typedef was
   // declared.
-  const char *TyName = Ty->getDecl()->getIdentifierName();
+  std::string TyName = Ty->getDecl()->getNameAsString();
   SourceLocation DefLoc = Ty->getDecl()->getLocation();
   llvm::DICompileUnit DefUnit = getOrCreateCompileUnit(DefLoc);
 
@@ -206,8 +206,7 @@
   SourceManager &SM = M->getContext().getSourceManager();
 
   // Get overall information about the record type for the debug info.
-  const char *Name = Decl->getIdentifierName();
-  if (Name == 0) Name = "";
+  std::string Name = Decl->getNameAsString();
 
   llvm::DICompileUnit DefUnit = getOrCreateCompileUnit(Decl->getLocation());
   uint64_t Line = SM.getLogicalLineNumber(Decl->getLocation());
@@ -241,9 +240,8 @@
        E = Decl->field_end(); I != E; ++I, ++FieldNo) {
     FieldDecl *Field = *I;
     llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit);
-    
-    const char *FieldName = Field->getIdentifierName();
-    if (FieldName == 0) FieldName = "";
+
+    std::string FieldName = Field->getNameAsString();
 
     // Get the location for the field.
     SourceLocation FieldDefLoc = Field->getLocation();
@@ -301,8 +299,7 @@
   llvm::DIArray EltArray =
     DebugFactory.GetOrCreateArray(&Enumerators[0], Enumerators.size());
 
-  const char *EnumName 
-    = Decl->getIdentifierName() ? Decl->getIdentifierName() : "";
+  std::string EnumName = Decl->getNameAsString();
   SourceLocation DefLoc = Decl->getLocation();
   llvm::DICompileUnit DefUnit = getOrCreateCompileUnit(DefLoc);
   SourceManager &SM = M->getContext().getSourceManager();
@@ -516,7 +513,8 @@
   llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation());
   SourceManager &SM = M->getContext().getSourceManager();
   uint64_t LineNo = SM.getLogicalLineNumber(Decl->getLocation());
-  const char *Name = Decl->getIdentifierName();
+
+  std::string Name = Decl->getNameAsString();
   
   DebugFactory.CreateGlobalVariable(Unit, Name, Name, "", Unit, LineNo,
                                     getOrCreateType(Decl->getType(), Unit),

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Sun Nov 23 21:54:41 2008
@@ -146,7 +146,8 @@
     if (!Target.useGlobalsForAutomaticVariables()) {
       // A normal fixed sized variable becomes an alloca in the entry block.
       const llvm::Type *LTy = ConvertType(Ty);
-      llvm::AllocaInst * Alloc = CreateTempAlloca(LTy, D.getIdentifierName());
+      llvm::AllocaInst *Alloc =
+        CreateTempAlloca(LTy, D.getIdentifier()->getName());
       unsigned align = getContext().getTypeAlign(Ty);
       if (const AlignedAttr* AA = D.getAttr<AlignedAttr>())
         align = std::max(align, AA->getAlignment());
@@ -164,7 +165,8 @@
     // FIXME: VLA: Add VLA support. For now just make up enough to let
     // the compile go through.
     const llvm::Type *LTy = ConvertType(Ty);
-    llvm::AllocaInst * Alloc = CreateTempAlloca(LTy, D.getIdentifierName());
+    llvm::AllocaInst *Alloc = 
+      CreateTempAlloca(LTy, D.getIdentifier()->getName());
     DeclPtr = Alloc;
   }
   

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Sun Nov 23 21:54:41 2008
@@ -570,7 +570,7 @@
 
 void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
   ASTContext &Context = CGM.getContext();
-  const char *ProtocolName = PD->getIdentifierName();
+  std::string ProtocolName = PD->getNameAsString();
   llvm::SmallVector<std::string, 16> Protocols;
   for (ObjCProtocolDecl::protocol_iterator PI = PD->protocol_begin(),
        E = PD->protocol_end(); PI != E; ++PI)
@@ -625,8 +625,8 @@
 }
 
 void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
-  const char *ClassName = OCD->getClassInterface()->getIdentifierName();
-  const char *CategoryName = OCD->getIdentifierName();
+  std::string ClassName = OCD->getClassInterface()->getNameAsString();
+  std::string CategoryName = OCD->getNameAsString();
   // Collect information about instance methods
   llvm::SmallVector<Selector, 16> InstanceMethodSels;
   llvm::SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
@@ -682,14 +682,13 @@
   // Get the superclass name.
   const ObjCInterfaceDecl * SuperClassDecl = 
     OID->getClassInterface()->getSuperClass();
-  const char * SuperClassName = NULL;
-  if (SuperClassDecl) {
-    SuperClassName = SuperClassDecl->getIdentifierName();
-  }
+  std::string SuperClassName;
+  if (SuperClassDecl)
+    SuperClassName = SuperClassDecl->getNameAsString();
 
   // Get the class name
   ObjCInterfaceDecl * ClassDecl = (ObjCInterfaceDecl*)OID->getClassInterface();
-  const char * ClassName = ClassDecl->getIdentifierName();
+  std::string ClassName = ClassDecl->getNameAsString();
 
   // Get the size of instances.  For runtimes that support late-bound instances
   // this should probably be something different (size just of instance
@@ -758,7 +757,7 @@
 
   // Get the superclass pointer.
   llvm::Constant *SuperClass;
-  if (SuperClassName) {
+  if (!SuperClassName.empty()) {
     SuperClass = MakeConstantString(SuperClassName, ".super_class_name");
   } else {
     SuperClass = llvm::ConstantPointerNull::get(
@@ -778,8 +777,9 @@
       NULLPtr, 0x2L, /*name*/"", 0, Zeros[0], GenerateIvarList(
         empty, empty, empty), ClassMethodList, NULLPtr);
   // Generate the class structure
-  llvm::Constant *ClassStruct = GenerateClassStructure(MetaClassStruct,
-      SuperClass, 0x1L, ClassName, 0,
+  llvm::Constant *ClassStruct =
+    GenerateClassStructure(MetaClassStruct, SuperClass, 0x1L,
+                           ClassName.c_str(), 0,
       llvm::ConstantInt::get(llvm::Type::Int32Ty, instanceSize), IvarList,
       MethodList, GenerateProtocolList(Protocols));
   // Add class structure to list to be added to the symtab later

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Nov 23 21:54:41 2008
@@ -664,7 +664,7 @@
   // over.
   LazySymbols.insert(&CGM.getContext().Idents.get("Protocol"));
 
-  const char *ProtocolName = PD->getIdentifierName();
+  const char *ProtocolName = PD->getNameAsCString();
 
   // Construct method lists.
   std::vector<llvm::Constant*> InstanceMethods, ClassMethods;
@@ -1076,7 +1076,7 @@
 void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
   DefinedSymbols.insert(ID->getIdentifier());
 
-  const char *ClassName = ID->getIdentifierName();
+  std::string ClassName = ID->getNameAsString();
   // FIXME: Gross
   ObjCInterfaceDecl *Interface = 
     const_cast<ObjCInterfaceDecl*>(ID->getClassInterface());
@@ -1169,7 +1169,6 @@
                                          llvm::Constant *Protocols,
                                          const llvm::Type *InterfaceTy,
                                          const ConstantVector &Methods) {
-  const char *ClassName = ID->getIdentifierName();
   unsigned Flags = eClassFlags_Meta;
   unsigned Size = CGM.getTargetData().getABITypeSize(ObjCTypes.ClassTy);
 
@@ -1215,7 +1214,7 @@
                                                    Values);
 
   std::string Name("\01L_OBJC_METACLASS_");
-  Name += ClassName;
+  Name += ID->getNameAsCString();
 
   // Check for a forward reference.
   llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sun Nov 23 21:54:41 2008
@@ -121,7 +121,8 @@
   if (CGDebugInfo *DI = CGM.getDebugInfo()) {
     DI->setLocation(StartLoc);
     if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
-      DI->EmitFunctionStart(FD->getIdentifierName(), RetTy, CurFn, Builder);
+      DI->EmitFunctionStart(FD->getIdentifier()->getName(),
+                            RetTy, CurFn, Builder);
     } else {
       // Just use LLVM function name.
       DI->EmitFunctionStart(Fn->getName().c_str(), 

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Sun Nov 23 21:54:41 2008
@@ -1029,7 +1029,7 @@
                                    unsigned &Attributes);
   void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, 
                                 ObjCPropertyDecl *SuperProperty,
-                                const char *Name);
+                                const IdentifierInfo *Name);
   void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
   
   void MergeProtocolPropertiesIntoClass(ObjCInterfaceDecl *IDecl,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Nov 23 21:54:41 2008
@@ -242,7 +242,7 @@
 void
 Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property, 
                                ObjCPropertyDecl *SuperProperty,
-                               const char *inheritedName) {
+                               const IdentifierInfo *inheritedName) {
   ObjCPropertyDecl::PropertyAttributeKind CAttr = 
   Property->getPropertyAttributes();
   ObjCPropertyDecl::PropertyAttributeKind SAttr = 
@@ -250,31 +250,31 @@
   if ((CAttr & ObjCPropertyDecl::OBJC_PR_readonly)
       && (SAttr & ObjCPropertyDecl::OBJC_PR_readwrite))
     Diag(Property->getLocation(), diag::warn_readonly_property)
-      << Property->getName() << inheritedName;
+      << Property->getDeclName() << inheritedName;
   if ((CAttr & ObjCPropertyDecl::OBJC_PR_copy)
       != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
     Diag(Property->getLocation(), diag::warn_property_attribute)
-      << Property->getName() << "copy" << inheritedName;
+      << Property->getDeclName() << "copy" << inheritedName;
   else if ((CAttr & ObjCPropertyDecl::OBJC_PR_retain)
            != (SAttr & ObjCPropertyDecl::OBJC_PR_retain))
     Diag(Property->getLocation(), diag::warn_property_attribute)
-      << Property->getName() << "retain" << inheritedName;
+      << Property->getDeclName() << "retain" << inheritedName;
   
   if ((CAttr & ObjCPropertyDecl::OBJC_PR_nonatomic)
       != (SAttr & ObjCPropertyDecl::OBJC_PR_nonatomic))
     Diag(Property->getLocation(), diag::warn_property_attribute)
-      << Property->getName() << "atomic" << inheritedName;
+      << Property->getDeclName() << "atomic" << inheritedName;
   if (Property->getSetterName() != SuperProperty->getSetterName())
     Diag(Property->getLocation(), diag::warn_property_attribute)
-      << Property->getName() << "setter" << inheritedName; 
+      << Property->getDeclName() << "setter" << inheritedName; 
   if (Property->getGetterName() != SuperProperty->getGetterName())
     Diag(Property->getLocation(), diag::warn_property_attribute)
-      << Property->getName() << "getter" << inheritedName;
+      << Property->getDeclName() << "getter" << inheritedName;
   
   if (Context.getCanonicalType(Property->getType()) != 
           Context.getCanonicalType(SuperProperty->getType()))
     Diag(Property->getLocation(), diag::warn_property_type)
-      << Property->getType().getAsString() << inheritedName;
+      << Property->getType() << inheritedName;
   
 }
 
@@ -297,7 +297,7 @@
       ObjCPropertyDecl *PDecl = (*I);
       if (SuperPDecl->getIdentifier() == PDecl->getIdentifier())
           DiagnosePropertyMismatch(PDecl, SuperPDecl, 
-                                   SDecl->getIdentifierName());
+                                   SDecl->getIdentifier());
     }
   }
 }
@@ -307,8 +307,7 @@
 /// of properties for current class if it is not there already.
 void
 Sema::MergeOneProtocolPropertiesIntoClass(ObjCInterfaceDecl *IDecl,
-                                          ObjCProtocolDecl *PDecl)
-{
+                                          ObjCProtocolDecl *PDecl) {
   llvm::SmallVector<ObjCPropertyDecl*, 16> mergeProperties;
   for (ObjCProtocolDecl::classprop_iterator P = PDecl->classprop_begin(),
        E = PDecl->classprop_end(); P != E; ++P) {
@@ -324,7 +323,7 @@
       mergeProperties.push_back(Pr);
     else
       // Property protocol already exist in class. Diagnose any mismatch.
-      DiagnosePropertyMismatch((*CP), Pr, PDecl->getIdentifierName());
+      DiagnosePropertyMismatch((*CP), Pr, PDecl->getIdentifier());
     }
   IDecl->mergeProperties(&mergeProperties[0], mergeProperties.size());
 }

Modified: cfe/trunk/test/SemaObjC/property-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-3.m?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/property-3.m (original)
+++ cfe/trunk/test/SemaObjC/property-3.m Sun Nov 23 21:54:41 2008
@@ -9,6 +9,6 @@
 @end
 
 @interface NOW : I
- at property (readonly, retain) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from'I'}}
+ at property (readonly, retain) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from 'I'}}
 @property (readwrite, copy) I* d2; // expected-warning {{property type 'I *' does not match property type inherited from 'I'}}
 @end

Modified: cfe/trunk/test/SemaObjC/property-4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-4.m?rev=59936&r1=59935&r2=59936&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/property-4.m (original)
+++ cfe/trunk/test/SemaObjC/property-4.m Sun Nov 23 21:54:41 2008
@@ -24,7 +24,7 @@
    int newO;
    int oldO;
 }
- at property (retain) id MayCauseError;  // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from'GCObject'}} \
-				      expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from'ProtocolObject'}}
+ at property (retain) id MayCauseError;  // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'GCObject'}} \
+				      expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'ProtocolObject'}}
 @end
 





More information about the cfe-commits mailing list