diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-28 14:54:22 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-28 14:54:22 +0000 |
commit | 72e357fc60b5ee8912559eb746231a4a4dec70ce (patch) | |
tree | f763a21d54ab122ea4262d4ae07e21d5e1b3a9bd /clang | |
parent | 3f8f04f1e9fd775cfbbf9f5022a2d828ef9d7874 (diff) | |
download | bcm5719-llvm-72e357fc60b5ee8912559eb746231a4a4dec70ce.tar.gz bcm5719-llvm-72e357fc60b5ee8912559eb746231a4a4dec70ce.zip |
Make Sema::ReferencedSelectors lazily deserialized.
llvm-svn: 136357
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Sema/ExternalSemaSource.h | 12 | ||||
-rw-r--r-- | clang/include/clang/Serialization/ASTReader.h | 3 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 31 |
4 files changed, 40 insertions, 14 deletions
diff --git a/clang/include/clang/Sema/ExternalSemaSource.h b/clang/include/clang/Sema/ExternalSemaSource.h index c9da3fefbb7..d8d6abb6508 100644 --- a/clang/include/clang/Sema/ExternalSemaSource.h +++ b/clang/include/clang/Sema/ExternalSemaSource.h @@ -125,7 +125,17 @@ public: /// to introduce the same declarations repeatedly. virtual void ReadLocallyScopedExternalDecls( SmallVectorImpl<NamedDecl *> &Decls) {} - + + /// \brief Read the set of referenced selectors known to the + /// external Sema source. + /// + /// The external source should append its own referenced selectors to the + /// given vector of declarations. Note that this routine + /// may be invoked multiple times; the external source should take care not + /// to introduce the same selectors repeatedly. + virtual void ReadReferencedSelectors( + SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {} + // isa/cast/dyn_cast support static bool classof(const ExternalASTSource *Source) { return Source->SemaSource; diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 7de5ec1ffcf..0113e6f98d3 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -1391,6 +1391,9 @@ public: virtual void ReadLocallyScopedExternalDecls( SmallVectorImpl<NamedDecl *> &Decls); + virtual void ReadReferencedSelectors( + SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels); + /// \brief Load a selector from disk, registering its ID if it exists. void LoadSelector(Selector Sel); diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index e9a39b614e8..b91a81372ff 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -2765,6 +2765,14 @@ void Sema::CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, } void Sema::DiagnoseUseOfUnimplementedSelectors() { + // Load referenced selectors from the external source. + if (ExternalSource) { + SmallVector<std::pair<Selector, SourceLocation>, 4> Sels; + ExternalSource->ReadReferencedSelectors(Sels); + for (unsigned I = 0, N = Sels.size(); I != N; ++I) + ReferencedSelectors[Sels[I].first] = Sels[I].second; + } + // Warning will be issued only when selector table is // generated (which means there is at lease one implementation // in the TU). This is to match gcc's behavior. diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 0ae1f62aa31..a0f8f68dfd3 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4366,19 +4366,6 @@ void ASTReader::InitializeSema(Sema &S) { SemaObj->StdBadAlloc = SemaDeclRefs[1]; } - // If there are @selector references added them to its pool. This is for - // implementation of -Wselector. - if (!ReferencedSelectorsData.empty()) { - unsigned int DataSize = ReferencedSelectorsData.size()-1; - unsigned I = 0; - while (I < DataSize) { - Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]); - SourceLocation SelLoc - = SourceLocation::getFromRawEncoding(ReferencedSelectorsData[I++]); - SemaObj->ReferencedSelectors.insert(std::make_pair(Sel, SelLoc)); - } - } - // The special data sets below always come from the most recent PCH, // which is at the front of the chain. Module &F = ModuleMgr.getPrimaryModule(); @@ -4617,6 +4604,24 @@ ASTReader::ReadLocallyScopedExternalDecls(SmallVectorImpl<NamedDecl *> &Decls) { LocallyScopedExternalDecls.clear(); } +void ASTReader::ReadReferencedSelectors( + SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) { + if (ReferencedSelectorsData.empty()) + return; + + // If there are @selector references added them to its pool. This is for + // implementation of -Wselector. + unsigned int DataSize = ReferencedSelectorsData.size()-1; + unsigned I = 0; + while (I < DataSize) { + Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]); + SourceLocation SelLoc + = SourceLocation::getFromRawEncoding(ReferencedSelectorsData[I++]); + Sels.push_back(std::make_pair(Sel, SelLoc)); + } + ReferencedSelectorsData.clear(); +} + void ASTReader::LoadSelector(Selector Sel) { // It would be complicated to avoid reading the methods anyway. So don't. ReadMethodPool(Sel); |