From: Bruno Ricci Date: Wed, 5 Dec 2018 17:16:55 +0000 (+0000) Subject: [Basic] Cleanups in IdentifierInfo following the removal of PTH X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18bea5216db162fe6d85ed88cbb242937a470c72;p=clang [Basic] Cleanups in IdentifierInfo following the removal of PTH The Entry pointer in IdentifierInfo was only null for IdentifierInfo 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. Differential Revision: https://reviews.llvm.org/D54866 Reviewed By: erichkeane git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348384 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 478c25e023..82e8c8c349 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -116,10 +116,19 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo { llvm::StringMapEntry *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. /// @@ -138,31 +147,10 @@ public: /// 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, where internal pointer - // points to the external string data. - using actualtype = std::pair; - - return ((const actualtype*) this)->second; - } + const char *getNameStart() const { 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, where internal pointer - // points to the external string data. - using actualtype = std::pair; - - const char* p = ((const actualtype*) this)->second - 2; - return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1; - } + unsigned getLength() const { return Entry->getKeyLength(); } /// Return the actual identifier string. StringRef getName() const { diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index 18580fca6c..b961c8333b 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/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 //===----------------------------------------------------------------------===//