forked from OSchip/llvm-project
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:
parent
0e88a565c0
commit
6843141d39
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
struct S1 {
|
||||
void S1_method(); // This should not be deserialized.
|
||||
virtual void S1_keyfunc();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue