diff options
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 0c278a1..1de9dd1 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -249,6 +249,9 @@ public: } bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; } + /// \brief Return true if this token is a keyword in the specified language. + bool isKeyword(const LangOptions &LangOpts); + /// getFETokenInfo/setFETokenInfo - The language front-end is allowed to /// associate arbitrary metadata with this token. template<typename T> @@ -444,26 +447,21 @@ public: /// \brief Return the identifier token info for the specified named /// identifier. IdentifierInfo &get(StringRef Name) { - llvm::StringMapEntry<IdentifierInfo*> &Entry = - HashTable.GetOrCreateValue(Name); + auto &Entry = *HashTable.insert(std::make_pair(Name, nullptr)).first; - IdentifierInfo *II = Entry.getValue(); + IdentifierInfo *&II = Entry.second; if (II) return *II; // No entry; if we have an external lookup, look there first. if (ExternalLookup) { II = ExternalLookup->get(Name); - if (II) { - // Cache in the StringMap for subsequent lookups. - Entry.setValue(II); + if (II) return *II; - } } // Lookups failed, make a new IdentifierInfo. void *Mem = getAllocator().Allocate<IdentifierInfo>(); II = new (Mem) IdentifierInfo(); - Entry.setValue(II); // Make sure getName() knows how to find the IdentifierInfo // contents. @@ -486,25 +484,23 @@ public: /// introduce or modify an identifier. If they called get(), they would /// likely end up in a recursion. IdentifierInfo &getOwn(StringRef Name) { - llvm::StringMapEntry<IdentifierInfo*> &Entry = - HashTable.GetOrCreateValue(Name); - - IdentifierInfo *II = Entry.getValue(); - if (!II) { - - // Lookups failed, make a new IdentifierInfo. - void *Mem = getAllocator().Allocate<IdentifierInfo>(); - II = new (Mem) IdentifierInfo(); - Entry.setValue(II); - - // Make sure getName() knows how to find the IdentifierInfo - // contents. - II->Entry = &Entry; - - // If this is the 'import' contextual keyword, mark it as such. - if (Name.equals("import")) - II->setModulesImport(true); - } + auto &Entry = *HashTable.insert(std::make_pair(Name, nullptr)).first; + + IdentifierInfo *&II = Entry.second; + if (II) + return *II; + + // Lookups failed, make a new IdentifierInfo. + void *Mem = getAllocator().Allocate<IdentifierInfo>(); + II = new (Mem) IdentifierInfo(); + + // Make sure getName() knows how to find the IdentifierInfo + // contents. + II->Entry = &Entry; + + // If this is the 'import' contextual keyword, mark it as such. + if (Name.equals("import")) + II->setModulesImport(true); return *II; } @@ -563,6 +559,7 @@ enum ObjCMethodFamily { OMF_retain, OMF_retainCount, OMF_self, + OMF_initialize, // performSelector families OMF_performSelector @@ -588,6 +585,12 @@ enum ObjCInstanceTypeFamily { OIT_ReturnsSelf }; +enum ObjCStringFormatFamily { + SFF_None, + SFF_NSString, + SFF_CFString +}; + /// \brief Smart pointer class that efficiently represents Objective-C method /// names. /// @@ -633,6 +636,8 @@ class Selector { } static ObjCMethodFamily getMethodFamilyImpl(Selector sel); + + static ObjCStringFormatFamily getStringFormatFamilyImpl(Selector sel); public: friend class SelectorTable; // only the SelectorTable can create these @@ -703,7 +708,11 @@ public: ObjCMethodFamily getMethodFamily() const { return getMethodFamilyImpl(*this); } - + + ObjCStringFormatFamily getStringFormatFamily() const { + return getStringFormatFamilyImpl(*this); + } + static Selector getEmptyMarker() { return Selector(uintptr_t(-1)); } |