riccibruno created this revision. riccibruno added a project: clang. Herald added a subscriber: cfe-commits.
Conditional on D54547 <https://reviews.llvm.org/D54547>: PTH-- Remove feature entirely- The `Entry` pointer in `IdentifierInfo` was only null for `IdentifierInfo`s created from a PTH. Now that PTH support has been removed we can remove some PTH specific code in `IdentifierInfo::getLength` and `IdentifierInfo::getNameStart`. Also make the constructor of `IdentifierInfo` private to make sure that they are only created by `IdentifierTable`, and move it to the header so that it can be inlined in `IdentifierTable::get` and `IdentifierTable::getOwn`. Repository: rC Clang https://reviews.llvm.org/D54866 Files: include/clang/Basic/IdentifierTable.h lib/Basic/IdentifierTable.cpp Index: lib/Basic/IdentifierTable.cpp =================================================================== --- lib/Basic/IdentifierTable.cpp +++ lib/Basic/IdentifierTable.cpp @@ -33,28 +33,6 @@ using namespace clang; -//===----------------------------------------------------------------------===// -// IdentifierInfo Implementation -//===----------------------------------------------------------------------===// - -IdentifierInfo::IdentifierInfo() { - TokenID = tok::identifier; - ObjCOrBuiltinID = 0; - HasMacro = false; - HadMacro = false; - IsExtension = false; - IsFutureCompatKeyword = false; - IsPoisoned = false; - IsCPPOperatorKeyword = false; - NeedsHandleIdentifier = false; - IsFromAST = false; - ChangedAfterLoad = false; - FEChangedAfterLoad = false; - RevertedTokenID = false; - OutOfDate = false; - IsModulesImport = false; -} - //===----------------------------------------------------------------------===// // IdentifierTable Implementation //===----------------------------------------------------------------------===// Index: include/clang/Basic/IdentifierTable.h =================================================================== --- include/clang/Basic/IdentifierTable.h +++ include/clang/Basic/IdentifierTable.h @@ -116,10 +116,19 @@ llvm::StringMapEntry<IdentifierInfo *> *Entry = nullptr; + IdentifierInfo() + : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false), + HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false), + IsPoisoned(false), IsCPPOperatorKeyword(false), + NeedsHandleIdentifier(false), IsFromAST(false), ChangedAfterLoad(false), + FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false), + IsModulesImport(false) {} + public: - IdentifierInfo(); IdentifierInfo(const IdentifierInfo &) = delete; IdentifierInfo &operator=(const IdentifierInfo &) = delete; + IdentifierInfo(IdentifierInfo &&) = delete; + IdentifierInfo &operator=(IdentifierInfo &&) = delete; /// Return true if this is the identifier for the specified string. /// @@ -139,29 +148,14 @@ /// Return the beginning of the actual null-terminated string for this /// identifier. 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. - // The 'this' pointer really points to a - // std::pair<IdentifierInfo, const char*>, where internal pointer - // points to the external string data. - using actualtype = std::pair<IdentifierInfo, const char *>; - - return ((const actualtype*) this)->second; + assert(Entry && "Entry is null!"); + return Entry->getKeyData(); } /// Efficiently return the length of this identifier info. unsigned getLength() const { - if (Entry) return Entry->getKeyLength(); - // FIXME: This is gross. It would be best not to embed specific details - // of the PTH file format here. - // The 'this' pointer really points to a - // std::pair<IdentifierInfo, const char*>, where internal pointer - // points to the external string data. - using actualtype = std::pair<IdentifierInfo, const char *>; - - const char* p = ((const actualtype*) this)->second - 2; - return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1; + assert(Entry && "Entry is null!"); + return Entry->getKeyLength(); } /// Return the actual identifier string.
Index: lib/Basic/IdentifierTable.cpp =================================================================== --- lib/Basic/IdentifierTable.cpp +++ lib/Basic/IdentifierTable.cpp @@ -33,28 +33,6 @@ using namespace clang; -//===----------------------------------------------------------------------===// -// IdentifierInfo Implementation -//===----------------------------------------------------------------------===// - -IdentifierInfo::IdentifierInfo() { - TokenID = tok::identifier; - ObjCOrBuiltinID = 0; - HasMacro = false; - HadMacro = false; - IsExtension = false; - IsFutureCompatKeyword = false; - IsPoisoned = false; - IsCPPOperatorKeyword = false; - NeedsHandleIdentifier = false; - IsFromAST = false; - ChangedAfterLoad = false; - FEChangedAfterLoad = false; - RevertedTokenID = false; - OutOfDate = false; - IsModulesImport = false; -} - //===----------------------------------------------------------------------===// // IdentifierTable Implementation //===----------------------------------------------------------------------===// Index: include/clang/Basic/IdentifierTable.h =================================================================== --- include/clang/Basic/IdentifierTable.h +++ include/clang/Basic/IdentifierTable.h @@ -116,10 +116,19 @@ llvm::StringMapEntry<IdentifierInfo *> *Entry = nullptr; + IdentifierInfo() + : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false), + HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false), + IsPoisoned(false), IsCPPOperatorKeyword(false), + NeedsHandleIdentifier(false), IsFromAST(false), ChangedAfterLoad(false), + FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false), + IsModulesImport(false) {} + public: - IdentifierInfo(); IdentifierInfo(const IdentifierInfo &) = delete; IdentifierInfo &operator=(const IdentifierInfo &) = delete; + IdentifierInfo(IdentifierInfo &&) = delete; + IdentifierInfo &operator=(IdentifierInfo &&) = delete; /// Return true if this is the identifier for the specified string. /// @@ -139,29 +148,14 @@ /// Return the beginning of the actual null-terminated string for this /// identifier. 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. - // The 'this' pointer really points to a - // std::pair<IdentifierInfo, const char*>, where internal pointer - // points to the external string data. - using actualtype = std::pair<IdentifierInfo, const char *>; - - return ((const actualtype*) this)->second; + assert(Entry && "Entry is null!"); + return Entry->getKeyData(); } /// Efficiently return the length of this identifier info. unsigned getLength() const { - if (Entry) return Entry->getKeyLength(); - // FIXME: This is gross. It would be best not to embed specific details - // of the PTH file format here. - // The 'this' pointer really points to a - // std::pair<IdentifierInfo, const char*>, where internal pointer - // points to the external string data. - using actualtype = std::pair<IdentifierInfo, const char *>; - - const char* p = ((const actualtype*) this)->second - 2; - return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1; + assert(Entry && "Entry is null!"); + return Entry->getKeyLength(); } /// Return the actual identifier string.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits