]> granicus.if.org Git - clang/commitdiff
[PCH] Serialize info about redeclared objc methods.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 14 Oct 2011 17:41:52 +0000 (17:41 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 14 Oct 2011 17:41:52 +0000 (17:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141964 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp

index 05311ff0bf37bebf9acd5ed9b304e36d42397c6f..616045c7b4d11eda241f1cbcc10625d19fc5c3fe 100644 (file)
@@ -1592,7 +1592,8 @@ public:
 
   /// \brief Get the duplicate declaration of a ObjCMethod in the same
   /// interface, or null if non exists.
-  const ObjCMethodDecl *getObjCMethodRedeclaration(ObjCMethodDecl *MD) const {
+  const ObjCMethodDecl *getObjCMethodRedeclaration(
+                                               const ObjCMethodDecl *MD) const {
     llvm::DenseMap<const ObjCMethodDecl*, const ObjCMethodDecl*>::const_iterator
       I = ObjCMethodRedecls.find(MD);
     if (I == ObjCMethodRedecls.end())
index ea36914eb779311d04000a6501c9c2a9bc91a64d..425c89d290a6c02f22973c6cf76c2bc0f7470d5f 100644 (file)
@@ -128,9 +128,12 @@ private:
   // Method has a definition.
   unsigned IsDefined : 1;
 
-  // Method redeclaration in the same interface.
+  /// \brief Method redeclaration in the same interface.
   unsigned IsRedeclaration : 1;
 
+  /// \brief Is redeclared in the same interface.
+  mutable unsigned HasRedeclaration : 1;
+
   // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
   /// @required/@optional
   unsigned DeclImplementation : 2;
@@ -223,7 +226,7 @@ private:
     DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily),
     IsInstance(isInstance), IsVariadic(isVariadic),
     IsSynthesized(isSynthesized),
-    IsDefined(isDefined), IsRedeclaration(0),
+    IsDefined(isDefined), IsRedeclaration(0), HasRedeclaration(0),
     DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
     RelatedResultType(HasRelatedResultType),
     SelLocsKind(SelLoc_StandardNoSpace),
index 170cdf43fc425ae0395637e50388cac8974b248b..a589b7f9d3e95dc798064db8b2494a8f1768b826 100644 (file)
@@ -355,6 +355,7 @@ void ObjCMethodDecl::setAsRedeclaration(const ObjCMethodDecl *PrevMethod) {
   assert(PrevMethod);
   getASTContext().setObjCMethodRedeclaration(PrevMethod, this);
   IsRedeclaration = true;
+  PrevMethod->HasRedeclaration = true;
 }
 
 void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
@@ -398,8 +399,9 @@ void ObjCMethodDecl::setMethodParams(ASTContext &C,
 /// Otherwise it will return itself.
 ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() {
   ASTContext &Ctx = getASTContext();
-  ObjCMethodDecl *Redecl =
-      const_cast<ObjCMethodDecl*>(Ctx.getObjCMethodRedeclaration(this));
+  ObjCMethodDecl *Redecl = 0;
+  if (HasRedeclaration)
+    Redecl = const_cast<ObjCMethodDecl*>(Ctx.getObjCMethodRedeclaration(this));
   if (Redecl)
     return Redecl;
 
index 3e6188be4d2b7614183f8afc07e8506e3af9ef60..6cc3f0a70bc198e0789f134c3fef0f25e3088188 100644 (file)
@@ -482,6 +482,13 @@ void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
   MD->setVariadic(Record[Idx++]);
   MD->setSynthesized(Record[Idx++]);
   MD->setDefined(Record[Idx++]);
+
+  MD->IsRedeclaration = Record[Idx++];
+  MD->HasRedeclaration = Record[Idx++];
+  if (MD->HasRedeclaration)
+    Reader.getContext().setObjCMethodRedeclaration(MD,
+                                       ReadDeclAs<ObjCMethodDecl>(Record, Idx));
+
   MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]);
   MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
   MD->SetRelatedResultType(Record[Idx++]);
index 9b29fa60fec9ad20fd6435f5944796a13684adb3..a8243e502e30865b2f12d7bdd1282d0363b5d04a 100644 (file)
@@ -402,6 +402,14 @@ void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
   Record.push_back(D->isVariadic());
   Record.push_back(D->isSynthesized());
   Record.push_back(D->isDefined());
+
+  Record.push_back(D->IsRedeclaration);
+  Record.push_back(D->HasRedeclaration);
+  if (D->HasRedeclaration) {
+    assert(Context.getObjCMethodRedeclaration(D));
+    Writer.AddDeclRef(Context.getObjCMethodRedeclaration(D), Record);
+  }
+
   // FIXME: stable encoding for @required/@optional
   Record.push_back(D->getImplementationControl());
   // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway