[cfe-commits] r84306 - in /cfe/trunk/include/clang: AST/Decl.h AST/DeclObjC.h Basic/IdentifierTable.h

Daniel Dunbar daniel at zuster.org
Fri Oct 16 20:28:48 PDT 2009


Author: ddunbar
Date: Fri Oct 16 22:28:48 2009
New Revision: 84306

URL: http://llvm.org/viewvc/llvm-project?rev=84306&view=rev
Log:
Add IdentiferInfo::getNameStr() -> StringRef.

Also, add getNameStart as a synonym for getName(). getName() is now deprecated,
when all clients are updated then getNameStr() should be renamed to
getName(). PR5218.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/include/clang/Basic/IdentifierTable.h

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

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Oct 16 22:28:48 2009
@@ -101,7 +101,7 @@
   /// and that it be a simple identifier.
   const char *getNameAsCString() const {
     assert(getIdentifier() && "Name is not a simple identifier");
-    return getIdentifier()->getName();
+    return getIdentifier()->getNameStart();
   }
 
   /// getDeclName - Get the actual, stored name of the declaration,

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Oct 16 22:28:48 2009
@@ -947,13 +947,17 @@
   /// getNameAsCString - Get the name of identifier for the class
   /// interface associated with this implementation as a C string
   /// (const char*).
+  //
+  // FIXME: Move to StringRef API.
   const char *getNameAsCString() const {
-    return Id ? Id->getName() : "";
+    return Id ? Id->getNameStart() : "";
   }
 
   /// @brief Get the name of the class associated with this interface.
+  //
+  // FIXME: Move to StringRef API.
   std::string getNameAsString() const {
-    return Id ? Id->getName() : "";
+    return Id ? Id->getNameStr() : "";
   }
 
   static bool classof(const Decl *D) { return D->getKind() == ObjCCategoryImpl;}
@@ -998,12 +1002,16 @@
   /// getNameAsCString - Get the name of identifier for the class
   /// interface associated with this implementation as a C string
   /// (const char*).
+  //
+  // FIXME: Move to StringRef API.
   const char *getNameAsCString() const {
     assert(getIdentifier() && "Name is not a simple identifier");
-    return getIdentifier()->getName();
+    return getIdentifier()->getNameStart();
   }
 
   /// @brief Get the name of the class associated with this interface.
+  //
+  // FIXME: Move to StringRef API.
   std::string getNameAsString() const {
     return getClassInterface()->getNameAsString();
   }

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=84306&r1=84305&r2=84306&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Fri Oct 16 22:28:48 2009
@@ -75,13 +75,13 @@
   /// This is intended to be used for string literals only: II->isStr("foo").
   template <std::size_t StrLen>
   bool isStr(const char (&Str)[StrLen]) const {
-    return getLength() == StrLen-1 && !memcmp(getName(), Str, StrLen-1);
+    return getLength() == StrLen-1 && !memcmp(getNameStart(), Str, StrLen-1);
   }
 
-  /// getName - Return the actual string for this identifier.  The returned
-  /// string is properly null terminated.
+  /// getNameStart - Return the beginning of the actual string for this
+  /// identifier.  The returned string is properly null terminated.
   ///
-  const char *getName() const {
+  const char *getNameStart() const {
     if (Entry) return Entry->getKeyData();
     // FIXME: This is gross. It would be best not to embed specific details
     // of the PTH file format here.
@@ -101,8 +101,17 @@
     // std::pair<IdentifierInfo, const char*>, where internal pointer
     // points to the external string data.
     const char* p = ((std::pair<IdentifierInfo, const char*>*) this)->second-2;
-    return (((unsigned) p[0])
-        | (((unsigned) p[1]) << 8)) - 1;
+    return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
+  }
+
+  // FIXME: Deprecated.
+  const char *getName() const {
+    return getNameStart();
+  }
+
+  /// getNameStr - Return the actual identifier string.
+  llvm::StringRef getNameStr() const {
+    return llvm::StringRef(getNameStart(), getLength());
   }
 
   /// hasMacroDefinition - Return true if this identifier is #defined to some
@@ -463,7 +472,7 @@
                                       const IdentifierInfo *Name) {
     llvm::SmallString<100> SelectorName;
     SelectorName = "set";
-    SelectorName.append(Name->getName(), Name->getName()+Name->getLength());
+    SelectorName += Name->getNameStr();
     SelectorName[3] = toupper(SelectorName[3]);
     IdentifierInfo *SetterName =
       &Idents.get(SelectorName.data(),





More information about the cfe-commits mailing list