]> granicus.if.org Git - clang/commitdiff
Make sure we're always setting the previous declaration of an ObjCInterfaceDecl
authorDouglas Gregor <dgregor@apple.com>
Fri, 16 Dec 2011 22:37:11 +0000 (22:37 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 16 Dec 2011 22:37:11 +0000 (22:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146763 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclObjC.cpp
lib/Serialization/ASTReader.cpp

index 02cc988d82d850e2afb3852040ee07d318d64b21..18be26def90560fef5bc6baefa46edd71dfd0e4b 100644 (file)
@@ -683,28 +683,29 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,
                                              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);
 }
 
index 44ffc29bad254781578eadcd2a3e30918bbc4a0f..81f08e375bd74e672bcf5f473c46c4a7bb21d0fb 100644 (file)
@@ -4559,7 +4559,7 @@ Decl *ASTReader::GetDecl(DeclID ID) {
     return 0;
   }
   
-if (!DeclsLoaded[Index]) {
+  if (!DeclsLoaded[Index]) {
     ReadDeclRecord(ID);
     if (DeserializationListener)
       DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);