And include some supplementary mangling changes:
- Give the first generic param (depth=0, index=0) a single character mangling. Even after removing the self type from method declaration types, 'Self' still shows up very frequently in protocol requirement signatures.
- Fix the mangling of generic parameter counts to elide the count when there's only one parameter at the starting depth of the mangling.
Together these carve another 154KB out of a debug standard library. There's some awkwardness in demangled strings that I'll clean up in subsequent commits; since decl types now only mangle the number of generic params at their own depth, it's context-dependent what depths those represent, which we get wrong now. Currying markers are also wrong, but since free function currying is going away, we can mangle the partial application thunks in different ways.
Swift SVN r32896
Bring this build setting in line with swift-compiler-version:
- Use "clang-compiler-version" instead of "repository_string"
- Don't append the clang compiler version to the swift one.
- Clean up uses in build-script-impl and build-presets.ini.
- Clean up uses in CMake
Swift SVN r32794
Canonical dependent member types are always based from a generic parameter, so we can use a more optimal mangling that assumes this. We can also introduce substitutions for AssociatedTypeDecls, and when a generic parameter in a signature is constrained by a single protocol, we can leave that protocol qualification out of the unsubstituted associated type mangling. These optimizations together shrink the standard library by 117KB, and bring the length of the longest Swift symbol in the stdlib down from 578 to 334 characters, shorter than the longest C++ symbol in the stdlib.
Swift SVN r32786
A microoptimization; since the module is likely to come up often in the subsequent mangling, we want to make it more likely to get the coveted S_ substitution.
Swift SVN r32784
This is a WIP to make CompilerVersion more general.
- Rename CompilerVersion to just "Version"
- Make version comparison general and put _compiler_version special logic
with its second version component in a specialized parsing function
- Add a generic version parsing function
Swift SVN r32726
Internal compiler versions must be able to be packed into a 64-bit
value, and there is a limit on how many components we can use and which
values they can take on.
Versions must have no more than five components, assuming a version
X.Y.Z.a.b, where X, Y, Z, a, and b are integers with the following
inclusive ranges:
X: [0 - 214747]
Y: [0 - 999]
Z: [0 - 999]
a: [0 - 999]
b: [0 - 999]
Swift SVN r32724
Cocoa's naming guidelines use lowercase initial words for selector
pieces and property names except when the first word is an
acronym. Force the first word of all imported APIs to be lowercase,
including acronyms.
Swift SVN r32719
To better indicate that the second _compiler_version component isn't
used in the ordering, warn and provide a fix-it replacement if it's
not a '*' in source code.
To make the diagnostics a little easier to emit, I cleaned up the
parsing code to use StringRef::split instead of a hand-written
tokenizer.
rdar://problem/23080845
Swift SVN r32673
The use of it already uses a TOSTR macro to wrap a bare substitution in a
string, to match the previous definition of the macro without quotes
(removed in r32625). Thanks, David!
Swift SVN r32656
When users try to print the interface of a specific type (most often through cursor
infor query of SourceKit), we should simplify the original decls by replacing
archetypes with instantiated types, hiding extension details, and omitting
unfulfilled extension requirements. So the users can get the straight-to-the-point
"type interface". This commit builds the testing infrastructure for this feature,
and implements the first trick that wraps extension contents into the interface body.
This commit also moves some generic testing support from SourceKit to Swift.
Swift SVN r32630
Modeled after the same feature in Clang. Example (from swift -version):
Swift version 2.1 (LLVM bf75799360, Clang 340dfbb3d5, Swift 32557)
rdar://problem/22959963
Swift SVN r32625
"with"
Treat these prepositions as vacuous names, so we never reduce any
parameter name down to one of them. If that would happen, leave the
entire parameter name alone. This makes our transformation a bit more conservative.
Swift SVN r32460
Prepend "is" to Boolean property names (e.g., "empty" becomes
"isEmpty") unless the property name strongly indicates its Boolean
nature or we're likely to ruin the name. Therefore, the presence of
one of the following in the property name will suppress this
transformation:
* An auxiliary verb, such as "is", "has", "may", "should", or "will".
* A word ending in "s", indicating either a plural (for which
prepending "is" would be incorrect) or a verb in the continuous
tense (which indicates its Boolean nature, e.g., "translates" in
"translatesCoordinates").
Swift SVN r32458
a ternary tree with a fixed-length per-node inline key buffer.
I plan to use this for metadata path caches, where it's useful to
be able to quickly find the most-derived point along a path that
you've already cached, but it should be useful for other things
in the compiler as well, like function-with-argument-label
lookups and possibly code completion.
This is quite a bit more space-efficient (and somewhat faster)
than doing scans after a lower_bound on a std::map<std::string, T>.
I haven't implemented balancing yet, and I don't need delete at
all for metadata paths, so I don't plan to work on that.
Swift SVN r32453
Together, UnsafePointer, UnsafeMutablePointer, UnsafeBufferPointer, and UnsafeMutableBufferPointer appear in standard library manglings over 1000 times, and they're fairly long names. Giving them standard substitutions shrinks the stdlib by 44KB.
Swift SVN r32410
'Ss' appears in manglings tens of thousands of times in the standard library and is also incredibly frequent in other modules. This alone is enough to shrink the standard library by 59KB.
Swift SVN r32409
When the first parameter of a function has Boolean type, try to create
an argument label for it. We start with the (normally non-API)
parameter name as the argument label, then try to match that against
the end of the base name of the method to eliminate redundancy. Add a
little magic, and here are some diffs:
- func openUntitledDocumentAndDisplay(_: Bool) throws -> NSDocument
+ func openUntitledDocument(display _: Bool) throws -> NSDocument
- func fontMenu(_: Bool) -> NSMenu?
- func fontPanel(_: Bool) -> NSFontPanel?
+ func fontMenu(create _: Bool) -> NSMenu?
+ func fontPanel(create _: Bool) -> NSFontPanel?
- func lockFocusFlipped(_: Bool)
+ func lockFocus(flipped _: Bool)
- func rectForSearchTextWhenCentered(_: Bool) -> NSRect
+ func rectForSearchText(whenCentered _: Bool) -> NSRect
- func dismissPreviewAnimated(_: Bool)
- func dismissMenuAnimated(_: Bool)
+ func dismissPreview(animated _: Bool)
+ func dismissMenu(animated _: Bool)
Swift SVN r32392
'arch' and 'os' build configurations with valid identifiers as
arguments, but which are unknown to the compiler, will cause the
compiler to silently skip over that code as it has an inactive clause.
Emit a diagnostic, but not an error so as not to inadvertantly break
code that may be in a compiler without knowledge of a particular
operating system or architecture.
rdar://problem/22052176
Swift SVN r32219
A couple of small tweaks to _compiler_version based on review comments:
- Fix &&/|| rejection to work with _compiler_version on either side of the
expression. Also add some test cases around this.
- Use clang/LLVM facilities for isdigit and atoi.
- Assert if parsing an invalid version string and there is no diagnostic
engine.
- Clean up some crumbs in the CMake configs.
rdar://problem/22730282
Swift SVN r32212
This configuration clause will suppress lex diagnostics and skip parsing
altogether if the code under the clause isn't active - the compiler must
have a repository version greater than or equal to the version given to
_compiler_version.
This option is only meant to be used sparingly and not to track the
Swift *language* version.
Example, if using a compiler versioned 700.0.28:
#if _compiler_version("700.0.23")
print("This code will compile for versions 700.0.23 and later.")
#else
This + code + will + not + be + parsed
#endif
Included are new diagnostics for checking that the version is formatted
correctly and isn't empty.
New tests:
- Compiler version comparison unit tests
- Build configuration diagnostics
- Skipping parsing of code under inactive clauses
rdar://problem/22730282
Swift SVN r32195
The special rule of introducing "body" isn't helping readability. We
might want to have a special rule around closure (or, especially,
trailing closure) parameters, but this is not it.
Swift SVN r32166
"Type" shows up in type names from time to time, but tends to be
omitted from selector pieces in such cases. This lets us skip that
suffix, fixing, e.g.,
- func changeCountTokenForSaveOperation(_: NSSaveOperationType) -> AnyObject
+ func changeCountTokenFor(_: NSSaveOperationType) -> AnyObject
Swift SVN r32165
Beyond the first parameter, the "with" or "using" at the beginning of
an argument label is needless, because one does not read the base name
of the method as if it distributed to the parameters. Some examples:
- func setProperty(_: String, withValue: AnyObject? = nil)
+ func setProperty(_: String, value: AnyObject? = nil)
- func hitTest(_: NSRect, withImageDestinationRect: NSRect, context:
NSGraphicsContext? = nil, hints: [String : AnyObject]? = nil,
flipped: Bool) -> Bool
+ func hitTest(_: NSRect, imageDestinationRect: NSRect, context:
NSGraphicsContext? = nil, hints: [String : AnyObject]? = nil,
flipped: Bool) -> Bool
- func track(_: NSRulerMarker, withMouseEvent: NSEvent) -> Bool
+ func track(_: NSRulerMarker, mouseEvent: NSEvent) -> Bool
Swift SVN r32141
Instead, when mapping a Clang type to its name for omission purposes,
map CF types to their appropriate names. This more directly mirrors
what will happen on the Swift side, but is otherwise NFC.
Swift SVN r32140
It's a cleaner rule to specify that we omit needless words from the
base name of a method and *then* split it for default arguments. This
tweak actually caught a small number of cases where we weren't
splitting properly, but should have.
Swift SVN r32133
When the context type of a declaraton matches the result type,
strip off redundant type information at the beginning of the
declaration name if it is followed by a preposition. This covers the
class of transformations on performs on a class that produce a value
of the same type as that class, e.g., NSURL's "URLWithHTTPS" or
NSString's "stringByAppendingString".
When that preposition is the magical "By" and is followed by a gerund,
strip the "By" as well. Note that this is slightly more conservative
now for methods, which previously stripped based on the result type
(always). For example, in NSCalendar:
- func adding(_: NSDateComponents, to: NSDate, options:
NSCalendarOptions = [])
-> NSDate?
+ func dateByAdding(_: NSDateComponents, to: NSDate, options:
NSCalendarOptions
= []) -> NSDate?
but it's more general for properties, e.g.,
- @NSCopying var bezierPathByFlattening: NSBezierPath { get }
- @NSCopying var bezierPathByReversing: NSBezierPath { get }
+ @NSCopying var byFlattening: NSBezierPath { get }
+ @NSCopying var reversing: NSBezierPath { get }
The important part is that the rules are more uniform and the code is
more regularly structured: we strip this leading type information when
it's redundant with the context and result type, regardless of whether
we have a property or a method, and the "By" rule is no longer special
in that regard.
Swift SVN r32129
This takes an highly-redundant API name like NSBezierPath's
func bezierPathByReversingPath() -> NSBezierPath
and turns it into
func reversing() -> NSBezierPath
Also, handle 'instancetype' properly when omitting words matching the
result type from the front of the base name.
Swift SVN r32119