aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/PCHReader.cpp21
-rw-r--r--lib/Frontend/PCHWriter.cpp22
2 files changed, 43 insertions, 0 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 1ccd851ae3..b4564885a8 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -1630,6 +1630,13 @@ PCHReader::ReadPCHBlock(PerFileData &F) {
TotalSelectorsInMethodPool = Record[1];
break;
+ case pch::REFERENCED_SELECTOR_POOL: {
+ unsigned int numEl = Record[0]*2;
+ for (unsigned int i = 1; i <= numEl; i++)
+ F.ReferencedSelectorsData.push_back(Record[i]);
+ }
+ break;
+
case pch::PP_COUNTER_VALUE:
if (!Record.empty() && Listener)
Listener->ReadCounter(Record[0]);
@@ -3126,6 +3133,20 @@ void PCHReader::InitializeSema(Sema &S) {
for (unsigned I = 0, N = DynamicClasses.size(); I != N; ++I)
SemaObj->DynamicClasses.push_back(
cast<CXXRecordDecl>(GetDecl(DynamicClasses[I])));
+
+ // If there are @selector references added them to its pool. This is for
+ // implementation of -Wselector.
+ PerFileData &F = *Chain[0];
+ if (!F.ReferencedSelectorsData.empty()) {
+ unsigned int DataSize = F.ReferencedSelectorsData.size()-1;
+ unsigned I = 0;
+ while (I < DataSize) {
+ Selector Sel = DecodeSelector(F.ReferencedSelectorsData[I++]);
+ SourceLocation SelLoc =
+ SourceLocation::getFromRawEncoding(F.ReferencedSelectorsData[I++]);
+ SemaObj->ReferencedSelectors.insert(std::make_pair(Sel, SelLoc));
+ }
+ }
}
IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) {
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index b97aecbd8c..0b8c5b4258 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -630,6 +630,7 @@ void PCHWriter::WriteBlockInfoBlock() {
RECORD(UNUSED_STATIC_FUNCS);
RECORD(MACRO_DEFINITION_OFFSETS);
RECORD(CHAINED_METADATA);
+ RECORD(REFERENCED_SELECTOR_POOL);
// SourceManager Block.
BLOCK(SOURCE_MANAGER_BLOCK);
@@ -1737,6 +1738,26 @@ void PCHWriter::WriteMethodPool(Sema &SemaRef) {
}
}
+/// \brief Write the selectors referenced in @selector expression into PCH file.
+void PCHWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
+ using namespace llvm;
+ if (SemaRef.ReferencedSelectors.empty())
+ return;
+
+ RecordData Record;
+
+ Record.push_back(SemaRef.ReferencedSelectors.size());
+ for (DenseMap<Selector, SourceLocation>::iterator S =
+ SemaRef.ReferencedSelectors.begin(),
+ E = SemaRef.ReferencedSelectors.end(); S != E; ++S) {
+ Selector Sel = (*S).first;
+ SourceLocation Loc = (*S).second;
+ AddSelectorRef(Sel, Record);
+ AddSourceLocation(Loc, Record);
+ }
+ Stream.EmitRecord(pch::REFERENCED_SELECTOR_POOL, Record);
+}
+
//===----------------------------------------------------------------------===//
// Identifier Table Serialization
//===----------------------------------------------------------------------===//
@@ -2247,6 +2268,7 @@ void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
WritePreprocessor(PP);
WriteMethodPool(SemaRef);
+ WriteReferencedSelectorsPool(SemaRef);
WriteIdentifierTable(PP);
WriteTypeDeclOffsets();