Skip to content

Commit 77a0366

Browse files
committed
---
yaml --- r: 343787 b: refs/heads/master-rebranch c: c109f90 h: refs/heads/master i: 343785: a083d35 343783: 1dfc424
1 parent 7c9c94a commit 77a0366

File tree

92 files changed

+756
-846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+756
-846
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 0291bbfed63409fe258a4b55641f1e40d9c7f918
1458+
refs/heads/master-rebranch: c109f9058f573f81047f7736fd9b081e8700a5d9
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/docs/CToSwiftNameTranslation.md

Lines changed: 10 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22

33
This document gives a high-level description of how C and Objective-C declarations are translated to Swift, with particular focus on how names are adjusted. It is not attempting to be a *complete* description of everything the compiler does except with regards to how *names* are transformed; even there, some special cases that only apply to Apple's SDKs have been omitted.
44

5-
## Word boundaries
6-
7-
Several forms of name translation are defined in terms of word boundaries. The word-splitting algorithm used by the Swift compiler is as follows: there is a boundary after
8-
9-
1. An underscore ("\_").
10-
2. A series of two or more uppercase ASCII characters and the suffix "s", "es", or "ies" (e.g. "URLs", "VAXes")...unless the last uppercase letter is "I" and the suffix is "s", in which case it's just as likely to be an acronym followed by "Is" (i.e. "URLIs" is treated as "URL Is").
11-
2. A series of two or more uppercase ASCII characters followed by an uppercase ASCII character and then a lowercase ASCII character ("XMLReader" becomes "XML Reader").
12-
3. A series of two or more uppercase ASCII characters followed by a non-ASCII-alphabetic character. ("UTF8" becomes "UTF 8")
13-
4. A series of two or more uppercase ASCII characters at the end of the string.
14-
5. An uppercase ASCII character and any number of non-ASCII-uppercase, non-underscore characters ("ContrivedExample" becomes "Contrived Example").
15-
6. Any number of non-ASCII-uppercase, non-underscore characters ("lowercase\_example" becomes "lowercase \_ example").
16-
17-
185
## Enums
196

207
1. Anonymous? Import elements as constants of the underlying type, *except* that Int is used for an inferred underlying type if all the cases fit in an Int32, since integer conversions are explicit in Swift.
@@ -127,7 +114,15 @@ In C, enumerators (enum cases) aren't namespaced under their enum type, so their
127114

128115
1. Collect all *available, non-deprecated* enum cases *without custom names.* If there are no such cases, collect all cases without custom names, whether available or not.
129116

130-
2. Find the common word-boundary prefix __CP__ of these cases.
117+
2. Find the common word-boundary prefix __CP__ of these cases. There is a word boundary after
118+
119+
1. An underscore ("\_").
120+
2. A series of two or more uppercase ASCII characters and the suffix "s", "es", or "ies" (e.g. "URLs", "VAXes")...unless the last uppercase letter is "I" and the suffix is "s", in which case it's just as likely to be an acronym followed by "Is" (i.e. "URLIs" is treated as "URL Is").
121+
2. A series of two or more uppercase ASCII characters followed by an uppercase ASCII character and then a lowercase ASCII character ("XMLReader" becomes "XML Reader").
122+
3. A series of two or more uppercase ASCII characters followed by a non-ASCII-alphabetic character. ("UTF8" becomes "UTF 8")
123+
4. A series of two or more uppercase ASCII characters at the end of the string.
124+
5. An uppercase ASCII character and any number of non-ASCII-uppercase, non-underscore characters ("ContrivedExample" becomes "Contrived Example").
125+
6. Any number of non-ASCII-uppercase, non-underscore characters ("lowercase\_example" becomes "lowercase \_ example").
131126

132127
3. If __CP__ starts with "k" followed by an uppercase letter, or if it's *just* "k" and none of the cases have a non-identifier-start character immediately after the 'k', treat that as meaning "constant" and ignore it for the next step.
133128

@@ -149,7 +144,7 @@ In C, enumerators (enum cases) aren't namespaced under their enum type, so their
149144

150145
9. ASCII-lowercase the first word of the remaining name if it starts with an uppercase ASCII character.
151146

152-
_There's a bug in this step where the special case for "Is" is missing, so "URLIs" will be lowercased to "urlis"._
147+
_There's a bug here where the special case for "Is" is missing, so "URLIs" will be lowercased to "urlis"._
153148

154149
## `swift_wrapper` typedefs
155150

@@ -195,48 +190,4 @@ extension SecretResourceID {
195190

196191
On Apple platforms, whenever Foundation is imported, constants with the type "NSNotificationName" additionally have the suffix "Notification" stripped before performing the above rules unless they have a custom name. Global NSString constants whose name ends in "Notification" will also automatically be treated as if they were declared with the type NSNotificationName unless they have a custom name.
197192

198-
199-
## Objective-C Protocols
200-
201-
Protocols in Objective-C are normally in a separate namespace from the "ordinary" identifier namespace used by typedefs and classes. Swift does not have separate namespaces, so if the protocol has the same name as another declaration in the same module, the suffix "Protocol" is appended. (Example: NSObjectProtocol in the ObjectiveC module.)
202-
203-
204-
## CF Types
205-
206-
"Core Foundation" is a C-based object-oriented system with strong conventions built around pointers to opaque structs. Creating new Core Foundation types is not generally supported, but Swift will recognize those in Apple's SDKs. If a struct has the `objc_bridge`, `objc_mutable_bridge`, or `objc_bridge_related` Clang attributes, it will be treated as a CF type and a typedef of a pointer to that struct will be imported as a class in Swift. The suffix "Ref" will be dropped from the class's name if present unless doing so would conflict with another declaration in the same module as the typedef.
207-
208-
If the class name contains the word "Mutable" exactly once per the usual word-boundary rules, a corresponding class name without the word "Mutable" will be used as the superclass if present. Otherwise, the CF type is taken to be a root object.
209-
210-
Additionally, typedefs for `void *` or `const void *` that are themselves annotated with `objc_bridge` will be treated as CFTypeRef-like and imported as `Any` rather than `Unsafe[Mutable]RawPointer`.
211-
212-
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.
213-
214-
215-
## `swift_private`
216-
217-
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.
218-
219-
```objc
220-
@interface Example : NSObject
221-
- (instancetype)initWithValue:(int)value __attribute__((swift_private));
222-
@property(readonly) int value __attribute__((swift_private));
223-
@end
224-
225-
// Usually seen as NS_REFINED_FOR_SWIFT
226-
```
227-
228-
```swift
229-
class Example: NSObject {
230-
init(__value: Int32)
231-
var __value: Int32 { get }
232-
}
233-
```
234-
235-
The purpose of this annotation is to allow a more idiomatic implementation to be provided in Swift. The effect of `swift_private` is inherited from an enum onto its elements if the enum is not imported as an error code enum, an `@objc` enum, or an option set.
236-
237-
_The original intent of the `swift_private` attribute was additionally to limit access to a Swift module with the same name as the owning Clang module, e.g. the Swift half of a mixed-source framework. However, this restriction has not been implemented as of Swift 5.1._
238-
239-
_For "historical reasons", the `swift_private` attribute is ignored on factory methods with no arguments imported as initializers. This is essentially matching the behavior of older Swift compilers for source compatibility in case someone has marked such a factory method as `swift_private`._
240-
241-
242193
## More to come...

branches/master-rebranch/include/swift/AST/ASTNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ namespace swift {
3636
enum class DeclKind : uint8_t;
3737
enum class StmtKind;
3838

39-
struct ASTNode : public llvm::PointerUnion<Expr*, Stmt*, Decl*> {
39+
struct ASTNode : public llvm::PointerUnion3<Expr*, Stmt*, Decl*> {
4040
// Inherit the constructors from PointerUnion.
41-
using PointerUnion::PointerUnion;
42-
41+
using PointerUnion3::PointerUnion3;
42+
4343
SourceRange getSourceRange() const;
4444

4545
/// Return the location of the start of the statement.

branches/master-rebranch/include/swift/AST/Attr.def

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ DECL_ATTR(available, Available,
121121
1)
122122
CONTEXTUAL_SIMPLE_DECL_ATTR(final, Final,
123123
OnClass | OnFunc | OnAccessor | OnVar | OnSubscript |
124-
DeclModifier | ABIBreakingToAdd | ABIBreakingToRemove |
125-
APIBreakingToAdd,
124+
DeclModifier,
126125
2)
127126
DECL_ATTR(objc, ObjC,
128127
OnAbstractFunction | OnClass | OnProtocol | OnExtension | OnVar |
129-
OnSubscript | OnEnum | OnEnumElement | ABIBreakingToAdd | ABIBreakingToRemove,
128+
OnSubscript | OnEnum | OnEnumElement,
130129
3)
131130
CONTEXTUAL_SIMPLE_DECL_ATTR(required, Required,
132131
OnConstructor |
@@ -188,7 +187,7 @@ DECL_ATTR(_semantics, Semantics,
188187
21)
189188
CONTEXTUAL_SIMPLE_DECL_ATTR(dynamic, Dynamic,
190189
OnFunc | OnAccessor | OnVar | OnSubscript | OnConstructor |
191-
DeclModifier | ABIBreakingToAdd | ABIBreakingToRemove,
190+
DeclModifier,
192191
22)
193192
CONTEXTUAL_SIMPLE_DECL_ATTR(infix, Infix,
194193
OnFunc | OnOperator |
@@ -213,7 +212,7 @@ SIMPLE_DECL_ATTR(nonobjc, NonObjC,
213212
30)
214213
SIMPLE_DECL_ATTR(_fixed_layout, FixedLayout,
215214
OnVar | OnClass | OnStruct |
216-
UserInaccessible | ABIBreakingToAdd | ABIBreakingToRemove,
215+
UserInaccessible,
217216
31)
218217
SIMPLE_DECL_ATTR(inlinable, Inlinable,
219218
OnVar | OnSubscript | OnAbstractFunction,
@@ -363,7 +362,7 @@ SIMPLE_DECL_ATTR(_weakLinked, WeakLinked,
363362
OnSubscript | OnConstructor | OnEnumElement | OnExtension | UserInaccessible,
364363
75)
365364
SIMPLE_DECL_ATTR(frozen, Frozen,
366-
OnEnum | OnStruct | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToRemove,
365+
OnEnum | OnStruct,
367366
76)
368367
DECL_ATTR_ALIAS(_frozen, Frozen)
369368
SIMPLE_DECL_ATTR(_forbidSerializingReference, ForbidSerializingReference,

branches/master-rebranch/include/swift/AST/Attr.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,6 @@ class DeclAttribute : public AttributeBase {
353353

354354
/// Whether client code cannot use the attribute.
355355
UserInaccessible = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 7),
356-
357-
/// Whether adding this attribute can break API
358-
APIBreakingToAdd = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 8),
359-
360-
/// Whether removing this attribute can break API
361-
APIBreakingToRemove = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 9),
362-
363-
/// Whether adding this attribute can break ABI
364-
ABIBreakingToAdd = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 10),
365-
366-
/// Whether removing this attribute can break ABI
367-
ABIBreakingToRemove = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 11),
368356
};
369357

370358
LLVM_READNONE
@@ -447,21 +435,6 @@ class DeclAttribute : public AttributeBase {
447435
return getOptions(DK) & UserInaccessible;
448436
}
449437

450-
static bool isAddingBreakingABI(DeclAttrKind DK) {
451-
return getOptions(DK) & ABIBreakingToAdd;
452-
}
453-
454-
static bool isAddingBreakingAPI(DeclAttrKind DK) {
455-
return getOptions(DK) & APIBreakingToAdd;
456-
}
457-
458-
static bool isRemovingBreakingABI(DeclAttrKind DK) {
459-
return getOptions(DK) & ABIBreakingToRemove;
460-
}
461-
static bool isRemovingBreakingAPI(DeclAttrKind DK) {
462-
return getOptions(DK) & APIBreakingToRemove;
463-
}
464-
465438
bool isDeclModifier() const {
466439
return isDeclModifier(getKind());
467440
}

branches/master-rebranch/include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4788,7 +4788,7 @@ class VarDecl : public AbstractStorageDecl {
47884788
};
47894789

47904790
protected:
4791-
PointerUnion<PatternBindingDecl *, Stmt *, VarDecl *> Parent;
4791+
PointerUnion3<PatternBindingDecl *, Stmt *, VarDecl *> Parent;
47924792

47934793
VarDecl(DeclKind kind, bool isStatic, Introducer introducer,
47944794
bool issCaptureList, SourceLoc nameLoc, Identifier name,

branches/master-rebranch/include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ WARNING(implicit_bridging_header_imported_from_module,none,
9191
"is deprecated and will be removed in a later version of Swift",
9292
(StringRef, Identifier))
9393

94+
WARNING(clang_vfs_overlay_is_ignored,none,
95+
"ignoring '-ivfsoverlay' options provided to '-Xcc' in favor of "
96+
"'-vfsoverlay'", ())
97+
9498
#ifndef DIAG_NO_UNDEF
9599
# if defined(DIAG)
96100
# undef DIAG

branches/master-rebranch/include/swift/AST/GenericSignatureBuilder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ class GenericSignatureBuilder {
9292
class ResolvedType;
9393

9494
using UnresolvedRequirementRHS =
95-
llvm::PointerUnion<Type, PotentialArchetype *, LayoutConstraint>;
95+
llvm::PointerUnion3<Type, PotentialArchetype *, LayoutConstraint>;
9696

9797
using RequirementRHS =
98-
llvm::PointerUnion<Type, PotentialArchetype *, LayoutConstraint>;
98+
llvm::PointerUnion3<Type, PotentialArchetype *, LayoutConstraint>;
9999

100100
/// The location of a requirement as written somewhere in the source.
101101
typedef llvm::PointerUnion<const TypeRepr *, const RequirementRepr *>
@@ -1373,8 +1373,8 @@ class GenericSignatureBuilder::FloatingRequirementSource {
13731373
} kind;
13741374

13751375
using Storage =
1376-
llvm::PointerUnion<const RequirementSource *, const TypeRepr *,
1377-
const RequirementRepr *>;
1376+
llvm::PointerUnion3<const RequirementSource *, const TypeRepr *,
1377+
const RequirementRepr *>;
13781378

13791379
Storage storage;
13801380

branches/master-rebranch/include/swift/AST/ModuleLoader.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#include "llvm/ADT/SmallSet.h"
2525
#include "llvm/ADT/TinyPtrVector.h"
2626

27-
namespace llvm {
28-
class FileCollector;
29-
}
30-
3127
namespace clang {
3228
class DependencyCollector;
3329
}
@@ -58,9 +54,8 @@ enum class Bridgeability : unsigned {
5854
class DependencyTracker {
5955
std::shared_ptr<clang::DependencyCollector> clangCollector;
6056
public:
61-
explicit DependencyTracker(
62-
bool TrackSystemDeps,
63-
std::shared_ptr<llvm::FileCollector> FileCollector = {});
57+
58+
explicit DependencyTracker(bool TrackSystemDeps);
6459

6560
/// Adds a file as a dependency.
6661
///

branches/master-rebranch/include/swift/AST/TypeCheckRequests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ struct WhereClauseOwner {
365365

366366
/// The source of the where clause, which can be a generic parameter list
367367
/// or a declaration that can have a where clause.
368-
llvm::PointerUnion<GenericParamList *, Decl *, SpecializeAttr *> source;
368+
llvm::PointerUnion3<GenericParamList *, Decl *, SpecializeAttr *> source;
369369

370370
WhereClauseOwner(Decl *decl);
371371

branches/master-rebranch/include/swift/Basic/LLVM.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ namespace llvm {
4242
template<typename T> class MutableArrayRef;
4343
template<typename T> class TinyPtrVector;
4444
template<typename T> class Optional;
45-
template <typename ...PTs> class PointerUnion;
45+
template <typename PT1, typename PT2> class PointerUnion;
46+
template <typename PT1, typename PT2, typename PT3> class PointerUnion3;
4647
class SmallBitVector;
4748

4849
// Other common classes.
@@ -67,6 +68,7 @@ namespace swift {
6768
using llvm::None;
6869
using llvm::Optional;
6970
using llvm::PointerUnion;
71+
using llvm::PointerUnion3;
7072
using llvm::SmallBitVector;
7173
using llvm::SmallPtrSet;
7274
using llvm::SmallPtrSetImpl;

branches/master-rebranch/include/swift/ClangImporter/ClangImporter.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
namespace llvm {
2525
class Triple;
26-
class FileCollector;
2726
template<typename Fn> class function_ref;
2827
}
2928

@@ -150,8 +149,7 @@ class ClangImporter final : public ClangModuleLoader {
150149
/// Create a new clang::DependencyCollector customized to
151150
/// ClangImporter's specific uses.
152151
static std::shared_ptr<clang::DependencyCollector>
153-
createDependencyCollector(bool TrackSystemDeps,
154-
std::shared_ptr<llvm::FileCollector> FileCollector);
152+
createDependencyCollector(bool TrackSystemDeps);
155153

156154
/// Append visible module names to \p names. Note that names are possibly
157155
/// duplicated, and not guaranteed to be ordered in any way.

branches/master-rebranch/include/swift/ClangImporter/ClangImporterOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ class ClangImporterOptions {
9696
/// When set, don't enforce warnings with -Werror.
9797
bool DebuggerSupport = false;
9898

99+
/// When set, clobber the Clang instance's virtual file system with the Swift
100+
/// virtual file system.
101+
bool ForceUseSwiftVirtualFileSystem = false;
102+
99103
/// Return a hash code of any components from these options that should
100104
/// contribute to a Swift Bridging PCH hash.
101105
llvm::hash_code getPCHHashComponents() const {

branches/master-rebranch/include/swift/LLVMPasses/Passes.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,8 @@ namespace swift {
3030
const llvm::PreservedAnalyses &) { return false; }
3131

3232
using AAResultBase::getModRefInfo;
33-
llvm::ModRefInfo getModRefInfo(const llvm::CallBase *Call,
34-
const llvm::MemoryLocation &Loc) {
35-
llvm::AAQueryInfo AAQI;
36-
return getModRefInfo(Call, Loc, AAQI);
37-
}
38-
llvm::ModRefInfo getModRefInfo(const llvm::CallBase *Call,
39-
const llvm::MemoryLocation &Loc,
40-
llvm::AAQueryInfo &AAQI);
33+
llvm::ModRefInfo getModRefInfo(llvm::ImmutableCallSite CS,
34+
const llvm::MemoryLocation &Loc);
4135
};
4236

4337
class SwiftAAWrapperPass : public llvm::ImmutablePass {

branches/master-rebranch/include/swift/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "llvm/ADT/SetVector.h"
4141

4242
namespace llvm {
43-
template <typename... PTs> class PointerUnion;
43+
template <typename PT1, typename PT2, typename PT3> class PointerUnion3;
4444
}
4545

4646
namespace swift {

branches/master-rebranch/include/swift/SILOptimizer/Analysis/LoopRegionAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class LoopRegion {
384384
private:
385385
/// A pointer to one of a Loop, Basic Block, or Function represented by this
386386
/// region.
387-
llvm::PointerUnion<FunctionTy *, LoopTy *, BlockTy *> Ptr;
387+
llvm::PointerUnion3<FunctionTy *, LoopTy *, BlockTy *> Ptr;
388388

389389
/// The ID of this region.
390390
unsigned ID;

branches/master-rebranch/include/swift/SILOptimizer/Utils/StackNesting.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,10 @@ class StackNesting {
155155
return bitNumberForAlloc(AllocInst);
156156
}
157157

158-
/// Insert deallocations at block boundaries.
159-
Changes insertDeallocsAtBlockBoundaries();
160-
161158
/// Modifies the SIL to end up with a correct stack nesting.
162159
///
163160
/// Returns the status of what changes were made.
164-
bool adaptDeallocs();
161+
Changes adaptDeallocs();
165162
};
166163

167164
} // end namespace swift

branches/master-rebranch/lib/AST/Builtins.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,6 @@ Type IntrinsicTypeDecoder::decodeImmediate() {
13611361
case IITDescriptor::HalfVecArgument:
13621362
case IITDescriptor::VarArg:
13631363
case IITDescriptor::Token:
1364-
case IITDescriptor::VecElementArgument:
13651364
case IITDescriptor::VecOfAnyPtrsToElt:
13661365
// These types cannot be expressed in swift yet.
13671366
return Type();

0 commit comments

Comments
 (0)