Skip to content

Commit 47a040f

Browse files
committed
---
yaml --- r: 348742 b: refs/heads/master c: c108dae h: refs/heads/master
1 parent 0e9c00a commit 47a040f

23 files changed

+131
-361
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3ec5e76ee30b2b50d26c455736ff108515b9ada8
2+
refs/heads/master: c108dae5d99698db1811347fa6827babd595d974
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/docs/CToSwiftNameTranslation.md

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -212,29 +212,6 @@ Additionally, typedefs for `void *` or `const void *` that are themselves annota
212212
If a typedef's underlying type is itself a "CF pointer" typedef, the "alias" typedef will be imported as a regular typealias, with the suffix "Ref" still dropped from its name (if present) unless doing so would conflict with another declaration in the same module as the typedef.
213213

214214

215-
## Objective-C Properties
216-
217-
By default, most property names are not transformed at all. However, if the getter of a property overrides a superclass or adopted protocol method that is also a property accessor, the Swift name of the overridden accessor's property will be used for consistency. If there's more than one such name, one is chosen arbitrarily.
218-
219-
Properties with the type `BOOL` or `Boolean` use the name of the getter as the name of the Swift property by default, rather than the name of the property in Objective-C. This accounts for a difference in Swift and Objective-C naming conventions for boolean properties that use "is".
220-
221-
```objc
222-
@property(getter=isContrivedExample) BOOL contrivedExample;
223-
@property BOOL hasAnotherForm;
224-
```
225-
226-
```swift
227-
var isContrivedExample: Bool { get set }
228-
var hasAnotherForm: Bool { get set }
229-
```
230-
231-
_This rule should probably have applied to C's native `bool` as well._
232-
233-
A property declaration with the `SwiftImportPropertyAsAccessors` API note will not be imported at all, and its accessors will be imported as methods. Additionally, properties whose names start with "accessibility" in the NSAccessibility protocol are always imported as methods, as are properties whose names start with "accessibility" in an `@interface` declaration (class or category) that provides the adoption of NSAccessibility.
234-
235-
_Objective-C code has historically not been consistent about whether the NSAccessibility declarations should be considered properties and therefore the Swift compiler chooses to import them as methods, as a sort of lowest common denominator._
236-
237-
238215
## `swift_private`
239216

240217
The `swift_private` Clang attribute prepends `__` onto the base name of any declaration being imported except initializers. For initializers with no arguments, a dummy `Void` argument with the name `__` is inserted; otherwise, the label for the first argument has `__` prepended. This transformation takes place after any other name manipulation, unless the declaration has a custom name. It will not occur if the declaration is an override; in that case the name needs to match the overridden declaration.
@@ -275,8 +252,6 @@ __attribute__((swift_name("SpacecraftCoordinates")))
275252
struct SPKSpacecraftCoordinates {
276253
double x, y, z, t; // space and time, of course
277254
};
278-
279-
// Usually seen as NS_SWIFT_NAME.
280255
```
281256
282257
```swift
@@ -312,10 +287,12 @@ The `swift_name` attribute can be used to give a C function a custom name. The v
312287
```objc
313288
__attribute__((swift_name("doSomething(to:bar:)")))
314289
void doSomethingToFoo(Foo *foo, int bar);
290+
291+
// Usually seen as NS_SWIFT_NAME.
315292
```
316293
317294
```swift
318-
func doSomething(to foo: UnsafeMutablePointer<Foo>, bar: Int32)
295+
func doSomething(foo: UnsafeMutablePointer<Foo>, bar: Int32)
319296
```
320297

321298
An underscore can be used in place of an empty parameter label, as in Swift.
@@ -453,86 +430,4 @@ Although enumerators always have global scope in C, they are often imported as m
453430

454431
_Currently, `swift_name` does not even allow importing an enum case as a member of the enum type itself, even if the enum is not recognized as an `@objc` enum, error code enum, or option set (i.e. the situation where a case is imported as a global constant)._
455432

456-
457-
### Fields of structs and unions; Objective-C properties
458-
459-
The `swift_name` attribute can be applied to rename a struct or union field or an Objective-C property (whether on a class or a protocol). The value of the attribute must be a valid Swift identifier.
460-
461-
```objc
462-
struct SPKSpaceflightBooking {
463-
const SPKLocation * _Nullable destination;
464-
bool roundTrip __attribute__((swift_name("isRoundTrip")));
465-
};
466-
```
467-
468-
```swift
469-
struct SPKSpaceflightBooking {
470-
var destination: UnsafePointer<SPKLocation>?
471-
var isRoundTrip: Bool
472-
}
473-
```
474-
475-
476-
### Objective-C methods
477-
478-
The `swift_name` attribute can be used to give an Objective-C method a custom name. The value of the attribute must be a full Swift function name, including parameter labels.
479-
480-
```objc
481-
- (void)doSomethingToFoo:(Foo *)foo bar:(int)bar
482-
__attribute__((swift_name("doSomethingImportant(to:bar:)")));
483-
```
484-
485-
```swift
486-
func doSomethingImportant(to foo: UnsafeMutablePointer<Foo>, bar: Int32)
487-
```
488-
489-
As with functions, an underscore can be used to represent an empty parameter label.
490-
491-
Methods that follow the NSError out-parameter convention may provide one fewer parameter label than the number of parameters in the original method to indicate that a parameter should be dropped, but they do not have to. The `swift_error` attribute is still respected even when using a custom name for purposes of transforming an NSError out-parameter and the method return type.
492-
493-
```objc
494-
- (BOOL)doSomethingRiskyAndReturnError:(NSError **)error
495-
__attribute__((swift_name("doSomethingRisky()")));
496-
- (BOOL)doSomethingContrived:(NSString *)action error:(NSError **)outError
497-
__attribute__((swift_name("doSomethingContrived(_:error:)")));
498-
```
499-
500-
```swift
501-
func doSomethingRisky() throws
502-
func doSomethingContrived(_ action: String, error: ()) throws
503-
```
504-
505-
A base name of "init" can be used on a *class* method that returns `instancetype` or the containing static type in order to import that method as an initializer. Any other custom name *prevents* a class method from being imported as an initializer even if it would normally be inferred as one.
506-
507-
```objc
508-
+ (Action *)makeActionWithHandler:(void(^)(void))handler
509-
__attribute__((swift_name("init(handler:)")));
510-
+ (instancetype)makeActionWithName:(NSString *)name
511-
__attribute__((swift_name("init(name:)")));
512-
```
513-
514-
```swift
515-
/* non-inherited */ init(handler: () -> Void)
516-
init(name: String)
517-
```
518-
519-
A no-argument method imported as an initializer can be given a dummy argument label to disambiguate it from the no-argument `init()`, whether the method is an init-family instance method or a factory class method in Objective-C.
520-
521-
```objc
522-
- (instancetype)initSafely
523-
__attribute__((swift_name("init(safe:)")));
524-
+ (instancetype)makeDefaultAction
525-
__attribute__((swift_name("init(default:)")));
526-
```
527-
528-
```swift
529-
init(safe: ())
530-
init(default: ())
531-
```
532-
533-
A custom name on an instance method with one of Objective-C's subscript selectors (`objectAtIndexedSubscript:`, `objectForKeyedSubscript:`, `setObject:atIndexedSubscript:`, or `setObject:forKeyedSubscript:`) prevents that method from being imported as a subscript or used as the accessor for another subscript.
534-
535-
_Currently, this only works if *both* methods in a read/write subscript are given custom names; if just one is, a read/write subscript will still be formed. A read-only subscript only has one method to rename._
536-
537-
538433
## More to come...

trunk/include/swift/AST/Identifier.h

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,8 @@ class Identifier {
5656

5757
const char *Pointer;
5858

59-
public:
60-
enum : size_t {
61-
NumLowBitsAvailable = 2,
62-
RequiredAlignment = 1 << NumLowBitsAvailable,
63-
SpareBitMask = ((intptr_t)1 << NumLowBitsAvailable) - 1
64-
};
65-
66-
private:
6759
/// Constructor, only accessible by ASTContext, which handles the uniquing.
68-
explicit Identifier(const char *Ptr) : Pointer(Ptr) {
69-
assert(((uintptr_t)Ptr & SpareBitMask) == 0
70-
&& "Identifier pointer does not use any spare bits");
71-
}
72-
73-
/// A type with the alignment expected of a valid \c Identifier::Pointer .
74-
struct alignas(uint32_t) Aligner {};
75-
76-
static_assert(alignof(Aligner) >= RequiredAlignment,
77-
"Identifier table will provide enough spare bits");
78-
60+
explicit Identifier(const char *Ptr) : Pointer(Ptr) {}
7961
public:
8062
explicit Identifier() : Pointer(nullptr) {}
8163

@@ -171,15 +153,12 @@ class Identifier {
171153
bool operator<(Identifier RHS) const { return Pointer < RHS.Pointer; }
172154

173155
static Identifier getEmptyKey() {
174-
uintptr_t Val = static_cast<uintptr_t>(-1);
175-
Val <<= NumLowBitsAvailable;
176-
return Identifier((const char*)Val);
156+
return Identifier((const char*)
157+
llvm::DenseMapInfo<const void*>::getEmptyKey());
177158
}
178-
179159
static Identifier getTombstoneKey() {
180-
uintptr_t Val = static_cast<uintptr_t>(-2);
181-
Val <<= NumLowBitsAvailable;
182-
return Identifier((const char*)Val);
160+
return Identifier((const char*)
161+
llvm::DenseMapInfo<const void*>::getTombstoneKey());
183162
}
184163

185164
private:
@@ -223,7 +202,7 @@ namespace llvm {
223202
static inline swift::Identifier getFromVoidPointer(void *P) {
224203
return swift::Identifier::getFromOpaquePointer(P);
225204
}
226-
enum { NumLowBitsAvailable = swift::Identifier::NumLowBitsAvailable };
205+
enum { NumLowBitsAvailable = 2 };
227206
};
228207

229208
} // end namespace llvm
@@ -242,15 +221,15 @@ class DeclBaseName {
242221
};
243222

244223
private:
245-
/// In a special DeclName representing a subscript, this opaque pointer
224+
/// In a special DeclName represenenting a subscript, this opaque pointer
246225
/// is used as the data of the base name identifier.
247226
/// This is an implementation detail that should never leak outside of
248227
/// DeclName.
249-
static const Identifier::Aligner SubscriptIdentifierData;
228+
static void *SubscriptIdentifierData;
250229
/// As above, for special constructor DeclNames.
251-
static const Identifier::Aligner ConstructorIdentifierData;
230+
static void *ConstructorIdentifierData;
252231
/// As above, for special destructor DeclNames.
253-
static const Identifier::Aligner DestructorIdentifierData;
232+
static void *DestructorIdentifierData;
254233

255234
Identifier Ident;
256235

@@ -260,23 +239,23 @@ class DeclBaseName {
260239
DeclBaseName(Identifier I) : Ident(I) {}
261240

262241
static DeclBaseName createSubscript() {
263-
return DeclBaseName(Identifier((const char *)&SubscriptIdentifierData));
242+
return DeclBaseName(Identifier((const char *)SubscriptIdentifierData));
264243
}
265244

266245
static DeclBaseName createConstructor() {
267-
return DeclBaseName(Identifier((const char *)&ConstructorIdentifierData));
246+
return DeclBaseName(Identifier((const char *)ConstructorIdentifierData));
268247
}
269248

270249
static DeclBaseName createDestructor() {
271-
return DeclBaseName(Identifier((const char *)&DestructorIdentifierData));
250+
return DeclBaseName(Identifier((const char *)DestructorIdentifierData));
272251
}
273252

274253
Kind getKind() const {
275-
if (Ident.get() == (const char *)&SubscriptIdentifierData) {
254+
if (Ident.get() == SubscriptIdentifierData) {
276255
return Kind::Subscript;
277-
} else if (Ident.get() == (const char *)&ConstructorIdentifierData) {
256+
} else if (Ident.get() == ConstructorIdentifierData) {
278257
return Kind::Constructor;
279-
} else if (Ident.get() == (const char *)&DestructorIdentifierData) {
258+
} else if (Ident.get() == DestructorIdentifierData) {
280259
return Kind::Destructor;
281260
} else {
282261
return Kind::Normal;
@@ -741,7 +720,7 @@ namespace llvm {
741720
static inline swift::DeclName getFromVoidPointer(void *ptr) {
742721
return swift::DeclName::getFromOpaqueValue(ptr);
743722
}
744-
enum { NumLowBitsAvailable = PointerLikeTypeTraits<swift::DeclBaseName>::NumLowBitsAvailable - 2 };
723+
enum { NumLowBitsAvailable = 0 };
745724
};
746725

747726
// DeclNames hash just like pointers.

trunk/include/swift/ClangImporter/ClangImporterOptions.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ class ClangImporterOptions {
103103
using llvm::hash_combine;
104104

105105
auto Code = hash_value(ModuleCachePath);
106-
Code = hash_combine(Code, llvm::hash_combine_range(ExtraArgs.begin(),
107-
ExtraArgs.end()));
106+
// ExtraArgs ignored - already considered in Clang's module hashing.
108107
Code = hash_combine(Code, OverrideResourceDir);
109108
Code = hash_combine(Code, TargetCPU);
110109
Code = hash_combine(Code, BridgingHeader);

trunk/lib/AST/ASTContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ struct ASTContext::Implementation {
165165

166166
// FIXME: This is a StringMap rather than a StringSet because StringSet
167167
// doesn't allow passing in a pre-existing allocator.
168-
llvm::StringMap<Identifier::Aligner, llvm::BumpPtrAllocator&>
169-
IdentifierTable;
168+
llvm::StringMap<char, llvm::BumpPtrAllocator&> IdentifierTable;
170169

171170
/// The declaration of Swift.AssignmentPrecedence.
172171
PrecedenceGroupDecl *AssignmentPrecedence = nullptr;
@@ -643,8 +642,7 @@ Identifier ASTContext::getIdentifier(StringRef Str) const {
643642
if (Str.data() == nullptr)
644643
return Identifier(nullptr);
645644

646-
auto pair = std::make_pair(Str, Identifier::Aligner());
647-
auto I = getImpl().IdentifierTable.insert(pair).first;
645+
auto I = getImpl().IdentifierTable.insert(std::make_pair(Str, char())).first;
648646
return Identifier(I->getKeyData());
649647
}
650648

trunk/lib/AST/ASTMangler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,10 +1491,6 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn) {
14911491
Optional<ASTMangler::SpecialContext>
14921492
ASTMangler::getSpecialManglingContext(const ValueDecl *decl,
14931493
bool useObjCProtocolNames) {
1494-
#if SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
1495-
return None; // not needed for the parser library.
1496-
#endif
1497-
14981494
// Declarations provided by a C module have a special context mangling.
14991495
// known-context ::= 'So'
15001496
//

trunk/lib/AST/Identifier.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
#include "clang/Basic/CharInfo.h"
2222
using namespace swift;
2323

24-
constexpr const Identifier::Aligner DeclBaseName::SubscriptIdentifierData{};
25-
constexpr const Identifier::Aligner DeclBaseName::ConstructorIdentifierData{};
26-
constexpr const Identifier::Aligner DeclBaseName::DestructorIdentifierData{};
24+
void *DeclBaseName::SubscriptIdentifierData =
25+
&DeclBaseName::SubscriptIdentifierData;
26+
void *DeclBaseName::ConstructorIdentifierData =
27+
&DeclBaseName::ConstructorIdentifierData;
28+
void *DeclBaseName::DestructorIdentifierData =
29+
&DeclBaseName::DestructorIdentifierData;
2730

2831
raw_ostream &llvm::operator<<(raw_ostream &OS, Identifier I) {
2932
if (I.get() == nullptr)

trunk/lib/IRGen/IRGenSIL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,9 @@ void IRGenSILFunction::emitSILFunction() {
16391639

16401640
assert(!CurSILFn->empty() && "function has no basic blocks?!");
16411641

1642+
if (CurSILFn->isThunk())
1643+
IGM.setHasFramePointer(CurFn, false);
1644+
16421645
if (CurSILFn->getDynamicallyReplacedFunction())
16431646
IGM.IRGen.addDynamicReplacement(CurSILFn);
16441647

trunk/lib/SILOptimizer/Transforms/OwnershipModelEliminator.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -383,25 +383,7 @@ struct OwnershipModelEliminator : SILModuleTransform {
383383
continue;
384384

385385
// Verify here to make sure ownership is correct before we strip.
386-
{
387-
// Add a pretty stack trace entry to tell users who see a verification
388-
// failure triggered by this verification check that they need to re-run
389-
// with -sil-verify-all to actually find the pass that introduced the
390-
// verification error.
391-
//
392-
// DISCUSSION: This occurs due to the crash from the verification
393-
// failure happening in the pass itself. This causes us to dump the
394-
// SILFunction and emit a msg that this pass (OME) is the culprit. This
395-
// is generally correct for most passes, but not for OME since we are
396-
// verifying before we have even modified the function to ensure that
397-
// all ownership invariants have been respected before we lower
398-
// ownership from the function.
399-
llvm::PrettyStackTraceString silVerifyAllMsgOnFailure(
400-
"Found verification error when verifying before lowering "
401-
"ownership. Please re-run with -sil-verify-all to identify the "
402-
"actual pass that introduced the verification error.");
403-
F.verify();
404-
}
386+
F.verify();
405387

406388
if (stripOwnership(F)) {
407389
auto InvalidKind =

0 commit comments

Comments
 (0)