]> granicus.if.org Git - clang/commitdiff
Add IdentiferInfo::getNameStr() -> StringRef.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 17 Oct 2009 03:28:48 +0000 (03:28 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 17 Oct 2009 03:28:48 +0000 (03:28 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84306 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
include/clang/AST/DeclObjC.h
include/clang/Basic/IdentifierTable.h

index 0b689c7de9d329e4247f4a7f420810f482fe22f4..19e7519d61f0374a96d750e274ca43d793267df2 100644 (file)
@@ -101,7 +101,7 @@ public:
   /// 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,
index 2b12bb5c1b6d22cd3a29a781c2831fc54010f9c3..f546e4cd27c6ba011049b8e987529ff3aa148153 100644 (file)
@@ -947,13 +947,17 @@ public:
   /// 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 @@ public:
   /// 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();
   }
index 84c2fc910d11b8ab568228d1fdf8665c74468f2b..ddd43688fe62fd8b7eb8169ba8c35ac8928452c3 100644 (file)
@@ -75,13 +75,13 @@ public:
   /// 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 @@ public:
     // 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 @@ public:
                                       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(),