diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-19 20:40:25 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-19 20:40:25 +0000 |
commit | 2dbaca748bc3eb6539f417bd8354c930bdf88fa4 (patch) | |
tree | dd761bb6948256b2dcb649f17768a74a0999c775 /include/clang/Serialization | |
parent | a64ccefdf0ea4e03ec88805d71b0af74950c7472 (diff) |
Introduce PreprocessingRecord::getPreprocessedEntitiesInRange()
which will do a binary search and return a pair of iterators
for preprocessed entities in the given source range.
Source ranges of preprocessed entities are stored twice currently in
the PCH/Module file but this will be fixed in a subsequent commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140058 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Serialization')
-rw-r--r-- | include/clang/Serialization/ASTBitCodes.h | 15 | ||||
-rw-r--r-- | include/clang/Serialization/ASTReader.h | 31 | ||||
-rw-r--r-- | include/clang/Serialization/Module.h | 2 |
3 files changed, 46 insertions, 2 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index f3dd8dc860..b8db49e76a 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -141,6 +141,21 @@ namespace clang { /// preprocessing record. typedef uint32_t PreprocessedEntityID; + /// \brief Source range/offset of a preprocessed entity. + struct PPEntityOffset { + /// \brief Raw source location of beginning of range. + unsigned Begin; + /// \brief Raw source location of end of range. + unsigned End; + /// \brief Offset in the AST file. + uint32_t BitOffset; + + PPEntityOffset(SourceRange R, uint32_t BitOffset) + : Begin(R.getBegin().getRawEncoding()), + End(R.getEnd().getRawEncoding()), + BitOffset(BitOffset) { } + }; + /// \brief The number of predefined preprocessed entity IDs. const unsigned int NUM_PREDEF_PP_ENTITY_IDS = 1; diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index cc5c1d76e0..96b5e5835c 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -248,6 +248,12 @@ private: /// \brief A map of negated SLocEntryIDs to the modules containing them. ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocEntryMap; + typedef ContinuousRangeMap<int, Module*, 64> GlobalSLocOffsetMapType; + + /// \brief A map of negated SourceLocation offsets to the modules containing + /// them. + GlobalSLocOffsetMapType GlobalSLocOffsetMap; + /// \brief Types that have already been loaded from the chain. /// /// When the pointer at index I is non-NULL, the type with @@ -680,7 +686,23 @@ private: RecordLocation getLocalBitOffset(uint64_t GlobalOffset); uint64_t getGlobalBitOffset(Module &M, uint32_t LocalOffset); - + + /// \brief Returns the first preprocessed entity ID that ends after \arg BLoc. + serialization::PreprocessedEntityID + findBeginPreprocessedEntity(SourceLocation BLoc) const; + + /// \brief Returns the first preprocessed entity ID that begins after \arg ELoc. + serialization::PreprocessedEntityID + findEndPreprocessedEntity(SourceLocation ELoc) const; + + /// \brief \arg SLocMapI points at a chunk of a module that contains no + /// preprocessed entities or the entities it contains are not the ones we are + /// looking for. Find the next module that contains entities and return the ID + /// of the first entry. + serialization::PreprocessedEntityID + findNextPreprocessedEntity( + GlobalSLocOffsetMapType::const_iterator SLocMapI) const; + void PassInterestingDeclsToConsumer(); /// \brief Produce an error diagnostic and return true. @@ -723,6 +745,8 @@ public: ~ASTReader(); + SourceManager &getSourceManager() const { return SourceMgr; } + /// \brief Load the AST file designated by the given file name. ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type); @@ -772,6 +796,11 @@ public: /// entity from being loaded. virtual PreprocessedEntity *ReadPreprocessedEntity(unsigned Index); + /// \brief Returns a pair of [Begin, End) indices of preallocated + /// preprocessed entities that \arg Range encompasses. + virtual std::pair<unsigned, unsigned> + findPreprocessedEntitiesInRange(SourceRange Range); + /// \brief Read the preprocessed entity at the given offset. virtual PreprocessedEntity *ReadPreprocessedEntityAtOffset(uint64_t Offset); diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h index 9f063316c1..42b5a58e08 100644 --- a/include/clang/Serialization/Module.h +++ b/include/clang/Serialization/Module.h @@ -177,7 +177,7 @@ public: /// \brief Remapping table for preprocessed entity IDs in this module. ContinuousRangeMap<uint32_t, int, 2> PreprocessedEntityRemap; - const uint32_t *PreprocessedEntityOffsets; + const PPEntityOffset *PreprocessedEntityOffsets; unsigned NumPreprocessedEntities; // === Header search information === |