Introduce local_begin()/local_end() methods in PreprocessingRecord which

return iterators for local, non-loaded, preprocessed entities.

llvm-svn: 140062
This commit is contained in:
Argyrios Kyrtzidis 2011-09-19 20:40:42 +00:00
parent 27bf76d6d2
commit 7f44836998
4 changed files with 24 additions and 19 deletions

View File

@ -484,8 +484,25 @@ namespace clang {
}; };
friend class iterator; friend class iterator;
iterator begin(bool OnlyLocalEntities = false); /// \brief Begin iterator for all preprocessed entities.
iterator end(bool OnlyLocalEntities = false); iterator begin() {
return iterator(this, -(int)LoadedPreprocessedEntities.size());
}
/// \brief End iterator for all preprocessed entities.
iterator end() {
return iterator(this, PreprocessedEntities.size());
}
/// \brief Begin iterator for local, non-loaded, preprocessed entities.
iterator local_begin() {
return iterator(this, 0);
}
/// \brief End iterator for local, non-loaded, preprocessed entities.
iterator local_end() {
return iterator(this, PreprocessedEntities.size());
}
/// \brief Returns a pair of [Begin, End) iterators of preprocessed entities /// \brief Returns a pair of [Begin, End) iterators of preprocessed entities
/// that source range \arg R encompasses. /// that source range \arg R encompasses.

View File

@ -1534,7 +1534,7 @@ void ASTUnit::RealizePreprocessedEntitiesFromPreamble() {
return; return;
PreprocessedEntities.insert(PreprocessedEntities.end(), PreprocessedEntities.insert(PreprocessedEntities.end(),
PPRec->begin(true), PPRec->end(true)); PPRec->local_begin(), PPRec->local_end());
} }
ASTUnit::pp_entity_iterator ASTUnit::pp_entity_begin() { ASTUnit::pp_entity_iterator ASTUnit::pp_entity_begin() {

View File

@ -44,18 +44,6 @@ PreprocessingRecord::PreprocessingRecord(SourceManager &SM,
{ {
} }
PreprocessingRecord::iterator
PreprocessingRecord::begin(bool OnlyLocalEntities) {
if (OnlyLocalEntities)
return iterator(this, 0);
return iterator(this, -(int)LoadedPreprocessedEntities.size());
}
PreprocessingRecord::iterator PreprocessingRecord::end(bool OnlyLocalEntities) {
return iterator(this, PreprocessedEntities.size());
}
/// \brief Returns a pair of [Begin, End) iterators of preprocessed entities /// \brief Returns a pair of [Begin, End) iterators of preprocessed entities
/// that source range \arg R encompasses. /// that source range \arg R encompasses.
std::pair<PreprocessingRecord::iterator, PreprocessingRecord::iterator> std::pair<PreprocessingRecord::iterator, PreprocessingRecord::iterator>

View File

@ -1711,7 +1711,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
} }
void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
if (PPRec.begin(Chain) == PPRec.end(Chain)) if (PPRec.local_begin() == PPRec.local_end())
return; return;
SmallVector<PPEntityOffset, 64> PreprocessedEntityOffsets; SmallVector<PPEntityOffset, 64> PreprocessedEntityOffsets;
@ -1744,8 +1744,8 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID; unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
RecordData Record; RecordData Record;
uint64_t BitsInChain = Chain? Chain->TotalModulesSizeInBits : 0; uint64_t BitsInChain = Chain? Chain->TotalModulesSizeInBits : 0;
for (PreprocessingRecord::iterator E = PPRec.begin(Chain), for (PreprocessingRecord::iterator E = PPRec.local_begin(),
EEnd = PPRec.end(Chain); EEnd = PPRec.local_end();
E != EEnd; E != EEnd;
(void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) { (void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
Record.clear(); Record.clear();