[cfe-commits] r109256 - in /cfe/trunk: include/clang/Frontend/PCHBitCodes.h include/clang/Frontend/PCHReader.h include/clang/Frontend/PCHWriter.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp
Fariborz Jahanian
fjahanian at apple.com
Fri Jul 23 12:11:11 PDT 2010
Author: fjahanian
Date: Fri Jul 23 14:11:11 2010
New Revision: 109256
URL: http://llvm.org/viewvc/llvm-project?rev=109256&view=rev
Log:
PCH read/write for selector reference pool.
Finishes off radar 6507158.
Modified:
cfe/trunk/include/clang/Frontend/PCHBitCodes.h
cfe/trunk/include/clang/Frontend/PCHReader.h
cfe/trunk/include/clang/Frontend/PCHWriter.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/include/clang/Frontend/PCHBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHBitCodes.h?rev=109256&r1=109255&r2=109256&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Fri Jul 23 14:11:11 2010
@@ -236,8 +236,10 @@
/// \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.
Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=109256&r1=109255&r2=109256&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Fri Jul 23 14:11:11 2010
@@ -281,6 +281,10 @@
/// \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
Modified: cfe/trunk/include/clang/Frontend/PCHWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHWriter.h?rev=109256&r1=109255&r2=109256&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHWriter.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHWriter.h Fri Jul 23 14:11:11 2010
@@ -242,6 +242,7 @@
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);
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=109256&r1=109255&r2=109256&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Fri Jul 23 14:11:11 2010
@@ -1630,6 +1630,13 @@
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 @@
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) {
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=109256&r1=109255&r2=109256&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Fri Jul 23 14:11:11 2010
@@ -630,6 +630,7 @@
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 @@
}
}
+/// \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 @@
WritePreprocessor(PP);
WriteMethodPool(SemaRef);
+ WriteReferencedSelectorsPool(SemaRef);
WriteIdentifierTable(PP);
WriteTypeDeclOffsets();
More information about the cfe-commits
mailing list