[cfe-commits] r107664 - in /cfe/trunk: include/clang/Frontend/PCHBitCodes.h include/clang/Frontend/PCHReader.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Jul 6 08:37:05 PDT 2010
Author: akirtzidis
Date: Tue Jul 6 10:37:04 2010
New Revision: 107664
URL: http://llvm.org/viewvc/llvm-project?rev=107664&view=rev
Log:
Add to PCH missing Sema information about VTable uses and dynamic classes.
Modified:
cfe/trunk/include/clang/Frontend/PCHBitCodes.h
cfe/trunk/include/clang/Frontend/PCHReader.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=107664&r1=107663&r2=107664&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Tue Jul 6 10:37:04 2010
@@ -226,7 +226,14 @@
/// \brief Record code for the table of offsets to macro definition
/// entries in the preprocessing record.
- MACRO_DEFINITION_OFFSETS = 23
+ MACRO_DEFINITION_OFFSETS = 23,
+
+ /// \brief Record code for the array of VTable uses.
+ VTABLE_USES = 24,
+
+ /// \brief Record code for the array of dynamic classes.
+ DYNAMIC_CLASSES = 25
+
};
/// \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=107664&r1=107663&r2=107664&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Tue Jul 6 10:37:04 2010
@@ -333,6 +333,12 @@
/// PCH file.
llvm::SmallVector<uint64_t, 4> ExtVectorDecls;
+ /// \brief The set of VTable uses of CXXRecordDecls stored in the PCH file.
+ llvm::SmallVector<uint64_t, 64> VTableUses;
+
+ /// \brief The set of dynamic CXXRecord declarations stored in the PCH file.
+ llvm::SmallVector<uint64_t, 16> DynamicClasses;
+
/// \brief The set of Objective-C category definitions stored in the
/// the PCH file.
llvm::SmallVector<uint64_t, 4> ObjCCategoryImpls;
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=107664&r1=107663&r2=107664&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Tue Jul 6 10:37:04 2010
@@ -1505,6 +1505,22 @@
ExtVectorDecls.swap(Record);
break;
+ case pch::VTABLE_USES:
+ if (!VTableUses.empty()) {
+ Error("duplicate VTABLE_USES record in PCH file");
+ return Failure;
+ }
+ VTableUses.swap(Record);
+ break;
+
+ case pch::DYNAMIC_CLASSES:
+ if (!DynamicClasses.empty()) {
+ Error("duplicate DYNAMIC_CLASSES record in PCH file");
+ return Failure;
+ }
+ DynamicClasses.swap(Record);
+ break;
+
case pch::ORIGINAL_FILE_NAME:
ActualOriginalFileName.assign(BlobStart, BlobLen);
OriginalFileName = ActualOriginalFileName;
@@ -2801,6 +2817,26 @@
for (unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I)
SemaObj->ExtVectorDecls.push_back(
cast<TypedefDecl>(GetDecl(ExtVectorDecls[I])));
+
+ // FIXME: Do VTable uses and dynamic classes deserialize too much ?
+ // Can we cut them down before writing them ?
+
+ // If there were any VTable uses, deserialize the information and add it
+ // to Sema's vector and map of VTable uses.
+ unsigned Idx = 0;
+ for (unsigned I = 0, N = VTableUses[Idx++]; I != N; ++I) {
+ CXXRecordDecl *Class = cast<CXXRecordDecl>(GetDecl(VTableUses[Idx++]));
+ SourceLocation Loc = ReadSourceLocation(VTableUses, Idx);
+ bool DefinitionRequired = VTableUses[Idx++];
+ SemaObj->VTableUses.push_back(std::make_pair(Class, Loc));
+ SemaObj->VTablesUsed[Class] = DefinitionRequired;
+ }
+
+ // If there were any dynamic classes declarations, deserialize them
+ // and add them to Sema's vector of such declarations.
+ for (unsigned I = 0, N = DynamicClasses.size(); I != N; ++I)
+ SemaObj->DynamicClasses.push_back(
+ cast<CXXRecordDecl>(GetDecl(DynamicClasses[I])));
}
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=107664&r1=107663&r2=107664&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Tue Jul 6 10:37:04 2010
@@ -2132,6 +2132,20 @@
for (unsigned I = 0, N = SemaRef.ExtVectorDecls.size(); I != N; ++I)
AddDeclRef(SemaRef.ExtVectorDecls[I], ExtVectorDecls);
+ // Build a record containing all of the VTable uses information.
+ RecordData VTableUses;
+ VTableUses.push_back(SemaRef.VTableUses.size());
+ for (unsigned I = 0, N = SemaRef.VTableUses.size(); I != N; ++I) {
+ AddDeclRef(SemaRef.VTableUses[I].first, VTableUses);
+ AddSourceLocation(SemaRef.VTableUses[I].second, VTableUses);
+ VTableUses.push_back(SemaRef.VTablesUsed[SemaRef.VTableUses[I].first]);
+ }
+
+ // Build a record containing all of dynamic classes declarations.
+ RecordData DynamicClasses;
+ for (unsigned I = 0, N = SemaRef.DynamicClasses.size(); I != N; ++I)
+ AddDeclRef(SemaRef.DynamicClasses[I], DynamicClasses);
+
// Write the remaining PCH contents.
RecordData Record;
Stream.EnterSubblock(pch::PCH_BLOCK_ID, 5);
@@ -2227,6 +2241,14 @@
if (!ExtVectorDecls.empty())
Stream.EmitRecord(pch::EXT_VECTOR_DECLS, ExtVectorDecls);
+ // Write the record containing VTable uses information.
+ if (!VTableUses.empty())
+ Stream.EmitRecord(pch::VTABLE_USES, VTableUses);
+
+ // Write the record containing dynamic classes declarations.
+ if (!DynamicClasses.empty())
+ Stream.EmitRecord(pch::DYNAMIC_CLASSES, DynamicClasses);
+
// Some simple statistics
Record.clear();
Record.push_back(NumStatements);
More information about the cfe-commits
mailing list