]> granicus.if.org Git - clang/commitdiff
CG/NeXT: Assert some invariants on an ivar's containing decl context that I am about...
authorDaniel Dunbar <daniel@zuster.org>
Fri, 2 Apr 2010 15:43:29 +0000 (15:43 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 2 Apr 2010 15:43:29 +0000 (15:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100188 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp

index 883ed98511e7242ff2671ffc223af2177598c8c4..d799162fa43f652aea15c3fac44e2a5d554643d0 100644 (file)
@@ -78,6 +78,19 @@ static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM,
     FindIvarInterface(CGM.getContext(), OID, Ivar, Index);
   assert(Container && "Unable to find ivar container");
 
+  // Check that the Obj-C decl contexts match what we expect.
+  const ObjCContainerDecl *DC = cast<ObjCContainerDecl>(Ivar->getDeclContext());
+  assert(isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplDecl>(DC) ||
+         isa<ObjCCategoryDecl>(DC));
+  if (isa<ObjCImplDecl>(DC)) {
+    assert(DC == ID);
+    assert(Container == cast<ObjCImplDecl>(DC)->getClassInterface());
+  } else if (isa<ObjCCategoryDecl>(DC)) {
+    assert(Container == cast<ObjCCategoryDecl>(DC)->getClassInterface());
+  }  else {
+    assert(Container == DC);
+  }
+
   // If we know have an implementation (and the ivar is in it) then
   // look up in the implementation layout.
   const ASTRecordLayout *RL;