/// \brief Record code for the chained PCH metadata, including the
/// PCH version and the name of the PCH this is chained to.
- CHAINED_METADATA = 26
-
+ CHAINED_METADATA = 26,
+
+ /// \brief Record code for referenced selector pool.
+ REFERENCED_SELECTOR_POOL = 27
};
/// \brief Record types used within a source manager block.
/// \brief The number of preallocated preprocessing entities in the
/// preprocessing record.
unsigned NumPreallocatedPreprocessingEntities;
+
+ /// \brief Method selectors used in a @selector expression. Used for
+ /// implementation of -Wselector.
+ llvm::SmallVector<long long unsigned int,64u> ReferencedSelectorsData;
};
/// \brief The chain of PCH files. The first entry is the one named by the
uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
void WriteTypeDeclOffsets();
void WriteMethodPool(Sema &SemaRef);
+ void WriteReferencedSelectorsPool(Sema &SemaRef);
void WriteIdentifierTable(Preprocessor &PP);
void WriteAttributeRecord(const Attr *Attr);
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]);
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) {
RECORD(UNUSED_STATIC_FUNCS);
RECORD(MACRO_DEFINITION_OFFSETS);
RECORD(CHAINED_METADATA);
+ RECORD(REFERENCED_SELECTOR_POOL);
// SourceManager Block.
BLOCK(SOURCE_MANAGER_BLOCK);
}
}
+/// \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
//===----------------------------------------------------------------------===//
WritePreprocessor(PP);
WriteMethodPool(SemaRef);
+ WriteReferencedSelectorsPool(SemaRef);
WriteIdentifierTable(PP);
WriteTypeDeclOffsets();