]> granicus.if.org Git - clang/commitdiff
add a new helper method. It is unclear to me why this doesn't work, but GCC
authorChris Lattner <sabre@nondot.org>
Wed, 19 Nov 2008 07:49:14 +0000 (07:49 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 19 Nov 2008 07:49:14 +0000 (07:49 +0000)
won't match it:

  template<std::size_t StrLen>
  bool isName(const char Str[StrLen]) const {
    return getLength() == StrLen-1 && !memcmp(getName(), Str, StrLen-1);
  }

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

include/clang/Basic/IdentifierTable.h

index cbd27547ac3805765d5e4c40406c2420473fdbb9..78013047519183eadd5bcbc1db354df5a04dfecc 100644 (file)
@@ -62,6 +62,12 @@ class IdentifierInfo {
 public:
   IdentifierInfo();
 
+  /// isName - Return true if this is the identifier for the specified string.
+  bool isName(const char *Str) const {
+    unsigned Len = strlen(Str);
+    return getLength() == Len && !memcmp(getName(), Str, Len);
+  }
+  
   /// getName - Return the actual string for this identifier.  The returned 
   /// string is properly null terminated.
   ///