Store in PCH the key function of C++ class to avoid deserializing the complete declaration context in order to compute it.

Progress for rdar://7260160.

llvm-svn: 116508
This commit is contained in:
Argyrios Kyrtzidis 2010-10-14 20:14:38 +00:00
parent 0e88a565c0
commit 6843141d39
5 changed files with 18 additions and 4 deletions

View File

@ -287,7 +287,9 @@ class ASTContext {
/// \brief The current C++ ABI.
llvm::OwningPtr<CXXABI> ABI;
CXXABI *createCXXABI(const TargetInfo &T);
friend class ASTDeclReader;
public:
const TargetInfo &Target;
IdentifierTable &Idents;

View File

@ -1712,9 +1712,6 @@ const CXXMethodDecl *ASTContext::getKeyFunction(const CXXRecordDecl *RD) {
const CXXMethodDecl *&Entry = KeyFunctions[RD];
if (!Entry)
Entry = RecordLayoutBuilder::ComputeKeyFunction(RD);
else
assert(Entry == RecordLayoutBuilder::ComputeKeyFunction(RD) &&
"Key function changed!");
return Entry;
}

View File

@ -833,6 +833,15 @@ void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
break;
}
}
// Load the key function to avoid deserializing every method so we can
// compute it.
if (D->IsDefinition) {
CXXMethodDecl *Key
= cast_or_null<CXXMethodDecl>(Reader.GetDecl(Record[Idx++]));
if (Key)
C.KeyFunctions[D] = Key;
}
}
void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {

View File

@ -770,6 +770,11 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
Record.push_back(CXXRecNotTemplate);
}
// Store the key function to avoid deserializing every method so we can
// compute it.
if (D->IsDefinition)
Writer.AddDeclRef(Context.getKeyFunction(D), Record);
Code = serialization::DECL_CXX_RECORD;
}

View File

@ -7,6 +7,7 @@
struct S1 {
void S1_method(); // This should not be deserialized.
virtual void S1_keyfunc();
};