After rebasing on master and incorporating more 32-bit support,
perform a bunch of cleanup, documentation updates, comments, move code
back to String declaration, etc.
C requires that there is at least one declaration in a translation unit.
Because this file is ObjC and not ObjC++, this restriction applies. Add
a declaration to silence the warning in the case that ObjC interop is
disabled.
This is only necessary on x86-64. On arm/arm64 we are already ok since the
assembly marker that we use there does not suffer from this issue.
For x86-64 we need to solve the problem upstream by not tailing calling
objc_retainAutoreleasedReturnValue.
rdar://38675842
String's hashValue function is implemented in terms of Foundation's hash
function in a runtime function on darwin platforms. For non-ASCII strings we
will call str.decomposedStringWithCanonicalMapping inside this runtime function
which will allocate a new NSString and return the result in the current
autorelease pool. We implemented this function in a file compiled without ARC.
This meant that we would leak said NSString into the current active autorelease
pool.
This patch moves the implementation to a file compiled with ARC. ARC will insert
objc_retainAutoreleasedReturnValue call and on platforms that require it an
marker for the hand-off of the autoreleased return value optimization.
SR-4889
rdar://32199117