[PATCH] D121177: [modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions loaded from different modules.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 11 17:57:50 PST 2022
vsapsai marked 6 inline comments as done.
vsapsai added a comment.
In D121177#3371832 <https://reviews.llvm.org/D121177#3371832>, @ChuanqiXu wrote:
> I see it is guaranteed by `lookupInstanceVariable(Identifier)` now. I don't know much about ObjC. But I feel a little bit strange. Is it possible that two distinct variable with the same identifier in ObjC? If it is impossible, I think it might be OK.
Two distinct ivars with the same name in the same class are prohibited. But there are a bunch of situations when ivars don't end up in the same class. For example, the most common case (and a huge reason for non-fragile ABI) is you have `@interface MyView: NSView` that has ivar `color`. If NSView decides to add its own ivar `color` in `@implementation`, it won't break your MyView and your binary will work without recompilation. That is roughly achieved by treating those ivars as `MyView.color` and `NSView.color` (it is very hand-wavy over-simplified explanation). But within the same class ivar redeclarations are prohibited. Without splitting everything into modules, we don't allow redeclarations in
@interface TestSubject {
int a;
}
@end
@interface TestSubject() {
int a; // <- error as it is a redeclaration
int b;
int c;
}
@end
@interface TestSubject() {
int b; // <- error as it is a redeclaration
}
@end
@implementation TestSubject {
int c; // <- error as it is a redeclaration
}
@end
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121177/new/
https://reviews.llvm.org/D121177
More information about the cfe-commits
mailing list