[LLVMbugs] [Bug 13222] New: Add attribute allowing return type to be the same as type of an argument
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Jun 27 09:32:16 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13222
Bug #: 13222
Summary: Add attribute allowing return type to be the same as
type of an argument
Product: clang
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: tjw at me.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
The method -[NSUndoManager prepareWithInvocationTarget:] takes an argument and
returns a proxy that logs undo operations based on messages sent to the proxy.
But, since -prepareWithInvocationTarget: returns type 'id', you can end up
having to cast the result to the type of the argument if there are multiple
implementations of the method to be sent with differing type signatures.
For example, if you have a custom class with a priority property (see the
attached sample), you'll possibly get a conflict with -[NSLayoutConstraint
setPriority:] from this line:
[[undoManager prepareWithInvocationTarget:custom] setPriority:priority];
Instead clang should have support for an attribute and NSUndoManager should use
it to declare that the return type of the method is the same as the argument.
On possible (likely terrible) form could be:
- (__attribute__((return_argument_type,
2))prepareWithInvocationTarget:(id)object;
This would make each call to -prepareWithInvocationTarget: act as if would
return the actual type passed in for the third argument (object) at that call
site.
There are other cases where this sort of behavior is wanted, including the
"first" argument (self). For example, -[NSObject autoContentAccessingProxy]
could be declared as:
- (__attribute__((return_argument_type, 0))autoContentAccessingProxy;
While clang could special case these methods, that would be a bad approach
since it would hide these details from people inspecting the header file and it
wouldn't be extensible.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list