[PATCH] D124285: [clang][NFC] In parts of Objective-C Sema use Obj-C-specific types instead of `Decl`.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 28 13:10:09 PDT 2022


vsapsai added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:17067
+void Sema::ActOnObjCTemporaryExitContainerContext(ObjCContainerDecl *ObjCCtx) {
+  auto DC = cast<DeclContext>(ObjCCtx);
   assert(DC == CurContext && "Mismatch of container contexts");
----------------
jansvoboda11 wrote:
> vsapsai wrote:
> > jansvoboda11 wrote:
> > > Why the cast? We should be able to compare/assign `ObjCContainerDecl *` to `DeclContext *`.
> > I believe you are right and the cast is not required. Though we cannot compare `ObjCCtx` and `CurContext`, we need to compare `DeclContext *DC`.
> > 
> > Also dropped a similar cast in `ActOnObjCContainerStartDefinition`.
> Interesting, I would expect that `ObjCCtx == CurContext` would have implicit upcast of `ObjCCtx` to `DeclContext *`. Same for the assignment.
D'oh, relying on values in debugger isn't always correct. You are right, according to [expr.eq]p2 both operands are brought to their composite pointer type and [conv.ptr]p3 allows upcasting, so we don't need to have variables of the same time for comparison.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124285/new/

https://reviews.llvm.org/D124285



More information about the cfe-commits mailing list