diff options
author | Steve Naroff <snaroff@apple.com> | 2009-04-23 10:39:46 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-04-23 10:39:46 +0000 |
commit | 90cd1bb1baac2a0221f3642de0cbea3244b116e5 (patch) | |
tree | 5fc871b111c9848b029793228385bd2867596150 /include/clang | |
parent | 325f75896d346605a00b9cc3494ed20a2a5dfb4e (diff) |
Add PCH read/write support for Objective-C Selectors.
Note: This support is non-lazy. Once we get "Cocoa.h" humming, we can optimize this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69884 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 2 | ||||
-rw-r--r-- | include/clang/Frontend/PCHBitCodes.h | 12 | ||||
-rw-r--r-- | include/clang/Frontend/PCHReader.h | 15 | ||||
-rw-r--r-- | include/clang/Frontend/PCHWriter.h | 12 |
4 files changed, 35 insertions, 6 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 0553a98022..235c19081c 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -370,7 +370,6 @@ class Selector { InfoPtr = reinterpret_cast<uintptr_t>(SI); assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo"); } - Selector(uintptr_t V) : InfoPtr(V) {} IdentifierInfo *getAsIdentifierInfo() const { if (getIdentifierInfoFlag()) @@ -388,6 +387,7 @@ public: /// The default ctor should only be used when creating data structures that /// will contain selectors. Selector() : InfoPtr(0) {} + Selector(uintptr_t V) : InfoPtr(V) {} /// operator==/!= - Indicate whether the specified selectors are identical. bool operator==(Selector RHS) const { diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h index 2afcce3388..998b1109b4 100644 --- a/include/clang/Frontend/PCHBitCodes.h +++ b/include/clang/Frontend/PCHBitCodes.h @@ -45,6 +45,8 @@ namespace clang { /// file. typedef uint32_t IdentID; + typedef uint32_t SelectorID; + /// \brief Describes the various kinds of blocks that occur within /// a PCH file. enum BlockIDs { @@ -66,7 +68,10 @@ namespace clang { /// \brief The block containing the definitions of all of the /// declarations stored in the PCH file. - DECLS_BLOCK_ID + DECLS_BLOCK_ID, + + /// \brief The block containing ObjC selectors stored in the PCH file. + SELECTOR_BLOCK_ID }; /// \brief Record types that occur within the PCH block itself. @@ -160,7 +165,10 @@ namespace clang { /// \brief Record code for the array of locally-scoped external /// declarations. - LOCALLY_SCOPED_EXTERNAL_DECLS = 11 + LOCALLY_SCOPED_EXTERNAL_DECLS = 11, + + /// \brief Record code for the Objective-C Selector Table. + SELECTOR_TABLE = 12 }; /// \brief Record types used within a source manager block. diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h index 107779aa1d..05e3ac6a12 100644 --- a/include/clang/Frontend/PCHReader.h +++ b/include/clang/Frontend/PCHReader.h @@ -145,6 +145,9 @@ private: /// an IdentifierInfo* that has already been resolved. llvm::SmallVector<uint64_t, 16> IdentifierData; + /// \brief SelectorData, indexed by the selector ID minus one. + llvm::SmallVector<Selector, 16> SelectorData; + /// \brief The set of external definitions stored in the the PCH /// file. llvm::SmallVector<uint64_t, 16> ExternalDefinitions; @@ -198,13 +201,15 @@ private: /// \brief FIXME: document! llvm::SmallVector<uint64_t, 4> SpecialTypes; - PCHReadResult ReadPCHBlock(uint64_t &PreprocessorBlockOffset); + PCHReadResult ReadPCHBlock(uint64_t &PreprocessorBlockOffset, + uint64_t &SelectorBlockOffset); bool CheckPredefinesBuffer(const char *PCHPredef, unsigned PCHPredefLen, FileID PCHBufferID); PCHReadResult ReadSourceManagerBlock(); bool ReadPreprocessorBlock(); - + bool ReadSelectorBlock(); + bool ParseLanguageOptions(const llvm::SmallVectorImpl<uint64_t> &Record); QualType ReadTypeRecord(uint64_t Offset); void LoadedDecl(unsigned Index, Decl *D); @@ -313,6 +318,12 @@ public: IdentifierInfo *GetIdentifierInfo(const RecordData &Record, unsigned &Idx) { return DecodeIdentifierInfo(Record[Idx++]); } + + Selector DecodeSelector(unsigned Idx); + + Selector GetSelector(const RecordData &Record, unsigned &Idx) { + return DecodeSelector(Record[Idx++]); + } DeclarationName ReadDeclarationName(const RecordData &Record, unsigned &Idx); /// \brief Read an integral value diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h index e3d0603e08..d1fe1d4f44 100644 --- a/include/clang/Frontend/PCHWriter.h +++ b/include/clang/Frontend/PCHWriter.h @@ -93,11 +93,17 @@ private: /// discovery), starting at 1. An ID of zero refers to a NULL /// IdentifierInfo. llvm::DenseMap<const IdentifierInfo *, pch::IdentID> IdentifierIDs; - + /// \brief Offsets of each of the identifier IDs into the identifier /// table, shifted left by one bit with the low bit set. llvm::SmallVector<uint64_t, 16> IdentifierOffsets; + /// \brief Map that provides the ID numbers of each Selector. + llvm::DenseMap<Selector, pch::SelectorID> SelectorIDs; + + /// \brief A vector of all Selectors (ordered by ID). + llvm::SmallVector<Selector, 16> SelVector; + /// \brief Offsets of each of the macro identifiers into the /// bitstream. /// @@ -154,6 +160,7 @@ private: uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC); void WriteDeclsBlock(ASTContext &Context); void WriteIdentifierTable(Preprocessor &PP); + void WriteSelectorTable(); void WriteAttributeRecord(const Attr *Attr); public: @@ -179,6 +186,9 @@ public: /// \brief Emit a reference to an identifier void AddIdentifierRef(const IdentifierInfo *II, RecordData &Record); + /// \brief Emit a Selector (which is a smart pointer reference) + void AddSelectorRef(const Selector, RecordData &Record); + /// \brief Get the unique number used to refer to the given /// identifier. pch::IdentID getIdentifierRef(const IdentifierInfo *II); |