[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
Tue Apr 26 16:24:02 PDT 2022
vsapsai marked an inline comment as done.
vsapsai added inline comments.
================
Comment at: clang/include/clang/Sema/Sema.h:3300
- Decl *ActOnObjCContainerStartDefinition(Decl *IDecl);
+ void ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl);
----------------
jansvoboda11 wrote:
> Why the change in return type?
Initially I've changed the type to catch various `return ActOnObjCContainerStartDefinition..` Now it's not really required.
What type do you think it should be? We can do both `Decl *` and `ObjCContainerDecl *` though none of those is particularly useful. I've decided to keep `void` because we don't use the returned value anyway.
I was also considering
```lang=c++
template <typename ObjCDeclTy>
ObjCDeclTy *ActOnObjCContainerStartDefinition(ObjCDeclTy *IDecl);
```
but I feel like the introduced complexity isn't worth it.
================
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:
> 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`.
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