diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-11-08 19:52:41 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-11-08 19:52:41 +0000 |
commit | 93a9ab4bdc607b12fdcf6aa5cf56950dd45ae0f5 (patch) | |
tree | 03e4cbbcb8cc75b2afed4db44d9d70281588e608 /include/clang/Basic/IdentifierTable.h | |
parent | 474b29ee01a827075878ab1a101128d7969f2eba (diff) |
Rewrote serialization of IdentifierInfo and IdentifierTable to use methods Emit
and Materialize/Read instead of using specializations of SerializeTrait<>. The
resulting code is much cleaner. We are also setting the stage so that only the
parts of the IdentifierTable that are ever referenced within the ASTs are
serialized, and not the whole table.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index b505176c04..ca3f147062 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -18,7 +18,7 @@ #include "clang/Basic/TokenKinds.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/SmallString.h" -#include "llvm/Bitcode/Serialization.h" +#include "llvm/Bitcode/SerializationFwd.h" #include <string> #include <cassert> @@ -137,6 +137,12 @@ public: template<typename T> T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); } void setFETokenInfo(void *T) { FETokenInfo = T; } + + /// Emit - Serialize this IdentifierInfo to a bitstream. + void Emit(llvm::Serializer& S) const; + + /// Read - Deserialize an IdentifierInfo object from a bitstream. + void Read(llvm::Deserializer& D); }; /// IdentifierTable - This table implements an efficient mapping from strings to @@ -182,12 +188,19 @@ public: void AddKeywords(const LangOptions &LangOpts); + /// Emit - Serialize this IdentifierTable to a bitstream. This should + /// be called AFTER objects that externally reference the identifiers in the + /// table have been serialized. This is because only the identifiers that + /// are actually referenced are serialized. + void Emit(llvm::Serializer& S) const; + + /// Materialize - Deserialize an IdentifierTable from a bitstream. + static IdentifierTable* Materialize(llvm::Deserializer& D); + private: /// This ctor is not intended to be used by anyone except for object /// serialization. - IdentifierTable(); - - friend struct llvm::SerializeTrait<IdentifierTable>; + IdentifierTable(); }; /// Selector - This smart pointer class efficiently represents Objective-C @@ -304,25 +317,6 @@ struct DenseMapInfo<clang::Selector> { static bool isPod() { return true; } }; - -/// Define SerializeTrait to enable serialization for IdentifierInfos. -template <> -struct SerializeTrait<clang::IdentifierInfo> { - static void Emit(Serializer& S, const clang::IdentifierInfo& I); - static void Read(Deserializer& S, clang::IdentifierInfo& I); -}; - -/// Define SerializeTrait to enable serialization for IdentifierTables. -template <> -struct SerializeTrait<clang::IdentifierTable> { - static void Emit(Serializer& S, const clang::IdentifierTable& X); - static void Read(Deserializer& S, clang::IdentifierTable& X); - -private: - static clang::IdentifierTable* Materialize(Deserializer& D); - friend class Deserializer; -}; - } // end namespace llvm #endif |