[cfe-commits] r146763 - in /cfe/trunk/lib: AST/DeclObjC.cpp Serialization/ASTReader.cpp

Douglas Gregor dgregor at apple.com
Fri Dec 16 14:37:11 PST 2011


Author: dgregor
Date: Fri Dec 16 16:37:11 2011
New Revision: 146763

URL: http://llvm.org/viewvc/llvm-project?rev=146763&view=rev
Log:
Make sure we're always setting the previous declaration of an ObjCInterfaceDecl

Modified:
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=146763&r1=146762&r2=146763&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Dec 16 16:37:11 2011
@@ -683,28 +683,29 @@
                                              SourceLocation ClassLoc,
                                              bool isInternal){
   ObjCInterfaceDecl *Result = new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, 
-                                                        isInternal);
+                                                        PrevDecl, isInternal);
   C.getObjCInterfaceType(Result, PrevDecl);
-  
-  if (PrevDecl) {
-    Result->Data = PrevDecl->Data;
-    Result->setPreviousDeclaration(PrevDecl);
-  }
-
   return Result;
 }
 
 ObjCInterfaceDecl *ObjCInterfaceDecl::CreateEmpty(ASTContext &C) {
   return new (C) ObjCInterfaceDecl(0, SourceLocation(), 0, SourceLocation(),
-                                   false);
+                                   0, false);
 }
 
 ObjCInterfaceDecl::
 ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id,
-                  SourceLocation CLoc, bool isInternal)
+                  SourceLocation CLoc, ObjCInterfaceDecl *PrevDecl,
+                  bool isInternal)
   : ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, atLoc),
     TypeForDecl(0), Data()
 {
+  setPreviousDeclaration(PrevDecl);
+  
+  // Copy the 'data' pointer over.
+  if (PrevDecl)
+    Data = PrevDecl->Data;
+  
   setImplicit(isInternal);
 }
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=146763&r1=146762&r2=146763&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Dec 16 16:37:11 2011
@@ -4559,7 +4559,7 @@
     return 0;
   }
   
-if (!DeclsLoaded[Index]) {
+  if (!DeclsLoaded[Index]) {
     ReadDeclRecord(ID);
     if (DeserializationListener)
       DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);





More information about the cfe-commits mailing list