]> granicus.if.org Git - clang/commitdiff
Sema/Obj-C: Simplify -- eliminate dead casts & provable asserts, and narrow type.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 2 Apr 2010 18:29:09 +0000 (18:29 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 2 Apr 2010 18:29:09 +0000 (18:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100197 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp

index f3d0dcff20c783b0e4ef767c1da262ee0430eb03..541c27169a7c052ea63501b4707387311556f902 100644 (file)
@@ -5740,17 +5740,15 @@ Sema::DeclPtrTy Sema::ActOnIvar(Scope *S,
     Visibility != tok::objc_not_keyword ? TranslateIvarVisibility(Visibility)
                                         : ObjCIvarDecl::None;
   // Must set ivar's DeclContext to its enclosing interface.
-  Decl *EnclosingDecl = IntfDecl.getAs<Decl>();
-  DeclContext *EnclosingContext;
+  ObjCContainerDecl *EnclosingDecl = IntfDecl.getAs<ObjCContainerDecl>();
+  ObjCContainerDecl *EnclosingContext;
   if (ObjCImplementationDecl *IMPDecl =
       dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
     // Case of ivar declared in an implementation. Context is that of its class.
-    ObjCInterfaceDecl* IDecl = IMPDecl->getClassInterface();
-    assert(IDecl && "No class- ActOnIvar");
-    EnclosingContext = cast_or_null<DeclContext>(IDecl);
+    EnclosingContext = IMPDecl->getClassInterface();
+    assert(EnclosingContext && "Implementation has no class interface!");
   } else
-    EnclosingContext = dyn_cast<DeclContext>(EnclosingDecl);
-  assert(EnclosingContext && "null DeclContext for ivar - ActOnIvar");
+    EnclosingContext = EnclosingDecl;
 
   // Construct the decl.
   ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context,