Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for marking redeclared methods as overrides #1

Open
kylesluder opened this issue Dec 3, 2013 · 0 comments
Open

Add support for marking redeclared methods as overrides #1

kylesluder opened this issue Dec 3, 2013 · 0 comments
Labels

Comments

@kylesluder
Copy link
Owner

Under the current scheme (f6a99a4), redeclaring a method in an @interface block that belongs to a different namespace produces a declaration of a method in that namespace. The only way to tell the compiler "no, I really just want to advertise to clients that I implement this method" is to move the redeclaration into a category that belongs to the namespace of the declaration. Without that, the compiler would complain that the @implementation block is lacking a definition of a method with the same name as the redeclared method, but in a different namespace:

@namespace MyNS
@interface MyObject : NSObject
- (instancetype)init;

@implementation MyObject
@end
// ^ error: definition of -[MyNS init] in namespace 'MyNS' not found

@end

This is actually kind of fragile, since it requires updating the subclasses whenever the namespaces of their superclasses change. (This might actually be an instance of a larger issue.)

It might be preferable to take the heuristic described for @implementation blocks and make it opt-in within the @interface as well. This could be done with an override keyword:

@namespace MyNS
@interface MyObject : NSObject
- override (instancetype) init; // resolves to @selector(default, init)
@end

If the override is omitted, the compiler should probably warn about the ambiguity:

@interface MyNS
@interface MyObject: NSObject
- (instancetype) init;
// ^ warning: instance method -init declared in namespace 'default' by superclass 'NSObject'
@end

The intent to declare a method of the same name in a different namespace can be made explicit via another keyword. I can't think of a good one right now, but perhaps alongside would work (since the new method lives "alongside" the one in the other namespace):

@interface MyNS
@interface MyObject : NSObject
- alongside (instancetype) init;
@end
kylesluder pushed a commit that referenced this issue Feb 18, 2014
1) Fix a specific bug when certain conversion functions are called in a program compiled as mips16 with hard float and
the program is linked as c++. There are two libraries that are reversed in the link order with gcc/g++ and clang/clang++ for
mips16 in this case and the proper stubs will then not be called. These stubs are normally handled in the Mips16HardFloat pass
but in this case we don't know at that time that we need to generate the stubs. This must all be handled later in code generation
and we have moved this functionality to MipsAsmPrinter. When linked as C (gcc or clang) the proper stubs are linked in from libc.

2) Set up the infrastructure to handle 90% of what is in the Mips16HardFloat pass in this new area of MipsAsmPrinter. This is a more
logical place to handle this and we have known for some time that we needed to move the code later and not implement it using
inline asm as we do now but it was not clear exactly where to do this and what mechanism should be used. Now it's clear to us
how to do this and this patch contains the infrastructure to move most of this to MipsAsmPrinter but the actual moving will be done
in a follow on patch. The same infrastructure is used to fix this current bug as described in #1. This change was requested by the list
during the original putback of the Mips16HardFloat pass but was not practical for us do at that time.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201426 91177308-0d34-0410-b5e6-96231b3b80d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant