diff options
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 7801304751..348ef1477f 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -62,10 +62,11 @@ 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); + /// isStr - Return true if this is the identifier for the specified string. + /// 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); } /// getName - Return the actual string for this identifier. The returned |