]> granicus.if.org Git - clang/commitdiff
Store in PCH the key function of C++ class to avoid deserializing the complete declar...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 14 Oct 2010 20:14:38 +0000 (20:14 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 14 Oct 2010 20:14:38 +0000 (20:14 +0000)
Progress for rdar://7260160.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116508 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
lib/AST/RecordLayoutBuilder.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/PCH/check-deserializations.cpp

index 40a36475e006b9f762a71977f06babc0ea6f1a2e..0a960ab34c07023e5dc5b515d4579b378bfaa2e1 100644 (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;
index c5465a5dca9882861f22f1a6646e28c2a451a202..9444be301b3d6ee4260e620c66f4a4952b5fd011 100644 (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;
 }
index 97adbf73cca3ed137958c9b6357125fe7ee963f6..e8fe264651b43c31077fe40482612665672b0797 100644 (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) {
index 3e1ba89a668bc022603857053697db31e94801f2..9aaaa485b67e36745d80bc286f8ef1eb600ec767 100644 (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;
 }
 
index ea0398470dfc8b3732e22ec2e06ced9ce4398e34..9f73c95c541e931403d80c0906e7d4a5ce247d6d 100644 (file)
@@ -7,6 +7,7 @@
 
 struct S1 {
   void S1_method(); // This should not be deserialized.
+  virtual void S1_keyfunc();
 };