Skip to content

Commit 53f0422

Browse files
author
Harlan Haskins
committed
---
yaml --- r: 348909 b: refs/heads/master c: 60523e3 h: refs/heads/master i: 348907: c779df1
1 parent f608eef commit 53f0422

File tree

138 files changed

+1496
-1873
lines changed

Some content is hidden

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

138 files changed

+1496
-1873
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: f5dd971ae37e4f65e45aa9cc2138b498d5ee08be
2+
refs/heads/master: 60523e38b41c0221052f0aabb4d4f3650616b9d2
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/cmake/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ set(SWIFT_LIBRARY_DIRS ${SWIFT_LIBRARY_OUTPUT_INTDIR})
1616
configure_file(
1717
SwiftConfig.cmake.in
1818
${swift_cmake_builddir}/SwiftConfig.cmake
19-
@ONLY)
19+
@ONLY)

trunk/cmake/modules/SwiftConfig.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ set(SWIFT_VERSION @SWIFT_VERSION@)
66
set(SWIFT_MAIN_SRC_DIR @SWIFT_SOURCE_DIR@)
77

88
set(SWIFT_INCLUDE_DIRS "@SWIFT_INCLUDE_DIRS@")
9-
set(SWIFT_LIBRARY_DIRS "@SWIFT_LIBRARY_DIRS@")
9+
set(SWIFT_LIBRARY_DIRS "@SWIFT_CONFIG_LIBRARY_DIRS@")
1010

1111
# These variables are duplicated, but they must match the LLVM variables of the
1212
# same name. The variables ending in "S" could some day become lists, and are
1313
# preserved for convention and compatibility.
1414
set(SWIFT_INCLUDE_DIR "@SWIFT_INCLUDE_DIRS@")
15-
set(SWIFT_LIBRARY_DIR "@SWIFT_LIBRARY_DIRS@")
15+
set(SWIFT_LIBRARY_DIR "@SWIFT_CONFIG_LIBRARY_DIRS@")
1616

1717
set(SWIFT_CMAKE_DIR "@SWIFT_CMAKE_DIR@")
1818
set(SWIFT_BINARY_DIR "@SWIFT_BINARY_DIR@")

trunk/include/swift/AST/ASTDemangler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class ASTBuilder {
5858
using BuiltTypeDecl = swift::GenericTypeDecl *; // nominal or type alias
5959
using BuiltProtocolDecl = swift::ProtocolDecl *;
6060
explicit ASTBuilder(ASTContext &ctx) : Ctx(ctx) {}
61+
62+
/// The resolver to use for type checking, if necessary.
63+
LazyResolver *Resolver = nullptr;
6164

6265
ASTContext &getASTContext() { return Ctx; }
6366
DeclContext *getNotionalDC();

trunk/include/swift/AST/ASTTypeIDZone.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ SWIFT_TYPEID_NAMED(InfixOperatorDecl *, InfixOperatorDecl)
3333
SWIFT_TYPEID_NAMED(IterableDeclContext *, IterableDeclContext)
3434
SWIFT_TYPEID_NAMED(ModuleDecl *, ModuleDecl)
3535
SWIFT_TYPEID_NAMED(NominalTypeDecl *, NominalTypeDecl)
36-
SWIFT_TYPEID_NAMED(OpaqueTypeDecl *, OpaqueTypeDecl)
3736
SWIFT_TYPEID_NAMED(OperatorDecl *, OperatorDecl)
3837
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>,
3938
PropertyWrapperMutability)

trunk/include/swift/AST/ASTTypeIDs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class IterableDeclContext;
3434
class ModuleDecl;
3535
class NominalTypeDecl;
3636
class OperatorDecl;
37-
class OpaqueTypeDecl;
3837
class PrecedenceGroupDecl;
3938
struct PropertyWrapperBackingPropertyInfo;
4039
struct PropertyWrapperTypeInfo;

trunk/include/swift/AST/Decl.h

Lines changed: 72 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class alignas(1 << DeclAlignInBits) Decl {
388388
SWIFT_INLINE_BITFIELD(SubscriptDecl, VarDecl, 2,
389389
StaticSpelling : 2
390390
);
391-
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1,
391+
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1+1+1,
392392
/// \see AbstractFunctionDecl::BodyKind
393393
BodyKind : 3,
394394

@@ -404,6 +404,12 @@ class alignas(1 << DeclAlignInBits) Decl {
404404
/// Whether the function body throws.
405405
Throws : 1,
406406

407+
/// Whether this function requires a new vtable entry.
408+
NeedsNewVTableEntry : 1,
409+
410+
/// Whether NeedsNewVTableEntry is valid.
411+
HasComputedNeedsNewVTableEntry : 1,
412+
407413
/// Whether this member was synthesized as part of a derived
408414
/// protocol conformance.
409415
Synthesized : 1,
@@ -412,10 +418,7 @@ class alignas(1 << DeclAlignInBits) Decl {
412418
HasSingleExpressionBody : 1
413419
);
414420

415-
SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+1+2+1+1+2,
416-
/// Whether we've computed the 'static' flag yet.
417-
IsStaticComputed : 1,
418-
421+
SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+2+1+1+2,
419422
/// Whether this function is a 'static' method.
420423
IsStatic : 1,
421424

@@ -851,6 +854,17 @@ class alignas(1 << DeclAlignInBits) Decl {
851854
return getValidationState() > ValidationState::Unchecked;
852855
}
853856

857+
/// Manually indicate that validation is complete for the declaration. For
858+
/// example: during importing, code synthesis, or derived conformances.
859+
///
860+
/// For normal code validation, please use DeclValidationRAII instead.
861+
///
862+
/// FIXME -- Everything should use DeclValidationRAII instead of this.
863+
void setValidationToChecked() {
864+
if (!isBeingValidated())
865+
Bits.Decl.ValidationState = unsigned(ValidationState::Checked);
866+
}
867+
854868
bool escapedFromIfConfig() const {
855869
return Bits.Decl.EscapedFromIfConfig;
856870
}
@@ -2591,9 +2605,6 @@ class ValueDecl : public Decl {
25912605
/// if the base declaration is \c open, the override might have to be too.
25922606
bool hasOpenAccess(const DeclContext *useDC) const;
25932607

2594-
/// FIXME: This is deprecated.
2595-
bool isRecursiveValidation() const;
2596-
25972608
/// Retrieve the "interface" type of this value, which uses
25982609
/// GenericTypeParamType if the declaration is generic. For a generic
25992610
/// function, this will have a GenericFunctionType with a
@@ -2753,6 +2764,12 @@ class ValueDecl : public Decl {
27532764
/// Get the representative for this value's opaque result type, if it has one.
27542765
OpaqueReturnTypeRepr *getOpaqueResultTypeRepr() const;
27552766

2767+
/// Set the opaque return type decl for this decl.
2768+
///
2769+
/// `this` must be of a decl type that supports opaque return types, and
2770+
/// must not have previously had an opaque result type set.
2771+
void setOpaqueResultTypeDecl(OpaqueTypeDecl *D);
2772+
27562773
/// Retrieve the attribute associating this declaration with a
27572774
/// function builder, if there is one.
27582775
CustomAttr *getAttachedFunctionBuilder() const;
@@ -3541,6 +3558,8 @@ class EnumDecl final : public NominalTypeDecl {
35413558
return SourceRange(EnumLoc, getBraces().End);
35423559
}
35433560

3561+
EnumElementDecl *getElement(Identifier Name) const;
3562+
35443563
public:
35453564
/// A range for iterating the elements of an enum.
35463565
using ElementRange = DowncastFilterRange<EnumElementDecl, DeclRange>;
@@ -4511,6 +4530,8 @@ class AbstractStorageDecl : public ValueDecl {
45114530
Bits.AbstractStorageDecl.IsStatic = IsStatic;
45124531
}
45134532

4533+
OpaqueTypeDecl *OpaqueReturn = nullptr;
4534+
45144535
public:
45154536

45164537
/// Should this declaration be treated as if annotated with transparent
@@ -4768,6 +4789,14 @@ class AbstractStorageDecl : public ValueDecl {
47684789

47694790
bool hasAnyDynamicReplacementAccessors() const;
47704791

4792+
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
4793+
return OpaqueReturn;
4794+
}
4795+
void setOpaqueResultTypeDecl(OpaqueTypeDecl *decl) {
4796+
assert(!OpaqueReturn && "already has opaque type decl");
4797+
OpaqueReturn = decl;
4798+
}
4799+
47714800
// Implement isa/cast/dyncast/etc.
47724801
static bool classof(const Decl *D) {
47734802
return D->getKind() >= DeclKind::First_AbstractStorageDecl &&
@@ -5545,8 +5574,6 @@ class ImportAsMemberStatus {
55455574

55465575
/// Base class for function-like declarations.
55475576
class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5548-
friend class NeedsNewVTableEntryRequest;
5549-
55505577
public:
55515578
enum class BodyKind {
55525579
/// The function did not have a body in the source code file.
@@ -5616,11 +5643,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
56165643
/// Location of the 'throws' token.
56175644
SourceLoc ThrowsLoc;
56185645

5619-
struct {
5620-
unsigned NeedsNewVTableEntryComputed : 1;
5621-
unsigned NeedsNewVTableEntry : 1;
5622-
} LazySemanticInfo = { };
5623-
56245646
AbstractFunctionDecl(DeclKind Kind, DeclContext *Parent, DeclName Name,
56255647
SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc,
56265648
bool HasImplicitSelfDecl,
@@ -5632,6 +5654,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
56325654
Bits.AbstractFunctionDecl.HasImplicitSelfDecl = HasImplicitSelfDecl;
56335655
Bits.AbstractFunctionDecl.Overridden = false;
56345656
Bits.AbstractFunctionDecl.Throws = Throws;
5657+
Bits.AbstractFunctionDecl.NeedsNewVTableEntry = false;
5658+
Bits.AbstractFunctionDecl.HasComputedNeedsNewVTableEntry = false;
56355659
Bits.AbstractFunctionDecl.Synthesized = false;
56365660
Bits.AbstractFunctionDecl.HasSingleExpressionBody = false;
56375661
}
@@ -5801,9 +5825,16 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
58015825
return getBodyKind() == BodyKind::MemberwiseInitializer;
58025826
}
58035827

5804-
/// For a method of a class, checks whether it will require a new entry in the
5805-
/// vtable.
5806-
bool needsNewVTableEntry() const;
5828+
void setNeedsNewVTableEntry(bool value) {
5829+
Bits.AbstractFunctionDecl.HasComputedNeedsNewVTableEntry = true;
5830+
Bits.AbstractFunctionDecl.NeedsNewVTableEntry = value;
5831+
}
5832+
5833+
bool needsNewVTableEntry() const {
5834+
if (!Bits.AbstractFunctionDecl.HasComputedNeedsNewVTableEntry)
5835+
const_cast<AbstractFunctionDecl *>(this)->computeNeedsNewVTableEntry();
5836+
return Bits.AbstractFunctionDecl.NeedsNewVTableEntry;
5837+
}
58075838

58085839
bool isEffectiveLinkageMoreVisibleThan(ValueDecl *other) const {
58095840
return (std::min(getEffectiveAccess(), AccessLevel::Public) >
@@ -5945,13 +5976,14 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK);
59455976
class FuncDecl : public AbstractFunctionDecl {
59465977
friend class AbstractFunctionDecl;
59475978
friend class SelfAccessKindRequest;
5948-
friend class IsStaticRequest;
59495979

59505980
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
59515981
SourceLoc FuncLoc; // Location of the 'func' token.
59525982

59535983
TypeLoc FnRetType;
59545984

5985+
OpaqueTypeDecl *OpaqueReturn = nullptr;
5986+
59555987
protected:
59565988
FuncDecl(DeclKind Kind,
59575989
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
@@ -5967,14 +5999,14 @@ class FuncDecl : public AbstractFunctionDecl {
59675999
StaticLoc(StaticLoc), FuncLoc(FuncLoc) {
59686000
assert(!Name.getBaseName().isSpecial());
59696001

6002+
Bits.FuncDecl.IsStatic =
6003+
StaticLoc.isValid() || StaticSpelling != StaticSpellingKind::None;
59706004
Bits.FuncDecl.StaticSpelling = static_cast<unsigned>(StaticSpelling);
59716005

59726006
Bits.FuncDecl.ForcedStaticDispatch = false;
59736007
Bits.FuncDecl.SelfAccess =
59746008
static_cast<unsigned>(SelfAccessKind::NonMutating);
59756009
Bits.FuncDecl.SelfAccessComputed = false;
5976-
Bits.FuncDecl.IsStaticComputed = false;
5977-
Bits.FuncDecl.IsStatic = false;
59786010
}
59796011

59806012
private:
@@ -5994,13 +6026,6 @@ class FuncDecl : public AbstractFunctionDecl {
59946026
return None;
59956027
}
59966028

5997-
Optional<bool> getCachedIsStatic() const {
5998-
if (Bits.FuncDecl.IsStaticComputed)
5999-
return Bits.FuncDecl.IsStatic;
6000-
6001-
return None;
6002-
}
6003-
60046029
public:
60056030
/// Factory function only for use by deserialization.
60066031
static FuncDecl *createDeserialized(ASTContext &Context, SourceLoc StaticLoc,
@@ -6023,16 +6048,16 @@ class FuncDecl : public AbstractFunctionDecl {
60236048

60246049
Identifier getName() const { return getFullName().getBaseIdentifier(); }
60256050

6026-
bool isStatic() const;
6027-
6051+
bool isStatic() const {
6052+
return Bits.FuncDecl.IsStatic;
6053+
}
60286054
/// \returns the way 'static'/'class' was spelled in the source.
60296055
StaticSpellingKind getStaticSpelling() const {
60306056
return static_cast<StaticSpellingKind>(Bits.FuncDecl.StaticSpelling);
60316057
}
60326058
/// \returns the way 'static'/'class' should be spelled for this declaration.
60336059
StaticSpellingKind getCorrectStaticSpelling() const;
60346060
void setStatic(bool IsStatic = true) {
6035-
Bits.FuncDecl.IsStaticComputed = true;
60366061
Bits.FuncDecl.IsStatic = IsStatic;
60376062
}
60386063

@@ -6104,7 +6129,15 @@ class FuncDecl : public AbstractFunctionDecl {
61046129
}
61056130

61066131
OperatorDecl *getOperatorDecl() const;
6107-
6132+
6133+
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
6134+
return OpaqueReturn;
6135+
}
6136+
void setOpaqueResultTypeDecl(OpaqueTypeDecl *decl) {
6137+
assert(!OpaqueReturn && "already has opaque type decl");
6138+
OpaqueReturn = decl;
6139+
}
6140+
61086141
/// Returns true if the function is forced to be statically dispatched.
61096142
bool hasForcedStaticDispatch() const {
61106143
return Bits.FuncDecl.ForcedStaticDispatch;
@@ -6353,7 +6386,13 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
63536386
ParameterList *Params,
63546387
SourceLoc EqualsLoc,
63556388
LiteralExpr *RawValueExpr,
6356-
DeclContext *DC);
6389+
DeclContext *DC)
6390+
: DeclContext(DeclContextKind::EnumElementDecl, DC),
6391+
ValueDecl(DeclKind::EnumElement, DC, Name, IdentifierLoc),
6392+
Params(Params),
6393+
EqualsLoc(EqualsLoc),
6394+
RawValueExpr(RawValueExpr)
6395+
{}
63576396

63586397
Identifier getName() const { return getFullName().getBaseIdentifier(); }
63596398

@@ -6369,7 +6408,6 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
63696408

63706409
Type getArgumentInterfaceType() const;
63716410

6372-
void setParameterList(ParameterList *params);
63736411
ParameterList *getParameterList() const { return Params; }
63746412

63756413
/// Retrieves a fully typechecked raw value expression associated

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ ERROR(cannot_convert_argument_value,none,
381381
(Type,Type))
382382

383383
NOTE(candidate_has_invalid_argument_at_position,none,
384-
"candidate expects value of type %0 for parameter #%1",
384+
"candidate expects value of type %0 at position #%1",
385385
(Type, unsigned))
386386

387387
ERROR(cannot_convert_array_to_variadic,none,

trunk/include/swift/AST/FileUnit.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class FileUnit : public DeclContext {
6060

6161
/// Look up an opaque return type by the mangled name of the declaration
6262
/// that defines it.
63-
virtual OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName) {
63+
virtual OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName,
64+
LazyResolver *resolver) {
6465
return nullptr;
6566
}
6667

trunk/include/swift/AST/Module.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ class ModuleDecl : public DeclContext, public TypeDecl {
354354

355355
/// Look up an opaque return type by the mangled name of the declaration
356356
/// that defines it.
357-
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName);
357+
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName,
358+
LazyResolver *resolver);
358359

359360
/// Find ValueDecls in the module and pass them to the given consumer object.
360361
///

trunk/include/swift/AST/SourceFile.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,6 @@ class SourceFile final : public FileUnit {
117117
/// The scope map that describes this source file.
118118
std::unique_ptr<ASTScope> Scope;
119119

120-
/// The set of validated opaque return type decls in the source file.
121-
llvm::SmallVector<OpaqueTypeDecl *, 4> OpaqueReturnTypes;
122-
llvm::StringMap<OpaqueTypeDecl *> ValidatedOpaqueReturnTypes;
123-
/// The set of parsed decls with opaque return types that have not yet
124-
/// been validated.
125-
llvm::SetVector<ValueDecl *> UnvalidatedDeclsWithOpaqueReturnTypes;
126-
127120
friend ASTContext;
128121
friend Impl;
129122
public:
@@ -137,6 +130,13 @@ class SourceFile final : public FileUnit {
137130
/// The list of local type declarations in the source file.
138131
llvm::SetVector<TypeDecl *> LocalTypeDecls;
139132

133+
/// The set of validated opaque return type decls in the source file.
134+
llvm::SmallVector<OpaqueTypeDecl *, 4> OpaqueReturnTypes;
135+
llvm::StringMap<OpaqueTypeDecl *> ValidatedOpaqueReturnTypes;
136+
/// The set of parsed decls with opaque return types that have not yet
137+
/// been validated.
138+
llvm::DenseSet<ValueDecl *> UnvalidatedDeclsWithOpaqueReturnTypes;
139+
140140
/// A set of special declaration attributes which require the
141141
/// Foundation module to be imported to work. If the foundation
142142
/// module is still not imported by the time type checking is
@@ -430,13 +430,14 @@ class SourceFile final : public FileUnit {
430430
void setSyntaxRoot(syntax::SourceFileSyntax &&Root);
431431
bool hasSyntaxRoot() const;
432432

433-
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName) override;
433+
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName,
434+
LazyResolver *resolver) override;
434435

435436
void addUnvalidatedDeclWithOpaqueResultType(ValueDecl *vd) {
436437
UnvalidatedDeclsWithOpaqueReturnTypes.insert(vd);
437438
}
438439

439-
ArrayRef<OpaqueTypeDecl *> getOpaqueReturnTypeDecls();
440+
void markDeclWithOpaqueResultTypeAsValidated(ValueDecl *vd);
440441

441442
private:
442443

0 commit comments

Comments
 (0)