Skip to content

Commit 91a792b

Browse files
committed
Merge branch 'master' into id-like-to-request-a-table
2 parents a57e6cc + 2b04447 commit 91a792b

File tree

92 files changed

+1067
-820
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

+1067
-820
lines changed

include/swift/AST/ASTDemangler.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ 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;
6461

6562
ASTContext &getASTContext() { return Ctx; }
6663
DeclContext *getNotionalDC();

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ 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)
3637
SWIFT_TYPEID_NAMED(OperatorDecl *, OperatorDecl)
3738
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>,
3839
PropertyWrapperMutability)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class IterableDeclContext;
3434
class ModuleDecl;
3535
class NominalTypeDecl;
3636
class OperatorDecl;
37+
class OpaqueTypeDecl;
3738
class PrecedenceGroupDecl;
3839
struct PropertyWrapperBackingPropertyInfo;
3940
struct PropertyWrapperTypeInfo;

include/swift/AST/AnyRequest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class AnyRequest {
5454
friend llvm::DenseMapInfo<swift::AnyRequest>;
5555

5656
static hash_code hashForHolder(uint64_t typeID, hash_code requestHash) {
57-
return hash_combine(hash_value(typeID), requestHash);
57+
return hash_combine(typeID, requestHash);
5858
}
5959

6060
/// Abstract base class used to hold the specific request kind.

include/swift/AST/Decl.h

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,10 @@ class alignas(1 << DeclAlignInBits) Decl {
412412
HasSingleExpressionBody : 1
413413
);
414414

415-
SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+2+1+1+2,
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+
416419
/// Whether this function is a 'static' method.
417420
IsStatic : 1,
418421

@@ -848,17 +851,6 @@ class alignas(1 << DeclAlignInBits) Decl {
848851
return getValidationState() > ValidationState::Unchecked;
849852
}
850853

851-
/// Manually indicate that validation is complete for the declaration. For
852-
/// example: during importing, code synthesis, or derived conformances.
853-
///
854-
/// For normal code validation, please use DeclValidationRAII instead.
855-
///
856-
/// FIXME -- Everything should use DeclValidationRAII instead of this.
857-
void setValidationToChecked() {
858-
if (!isBeingValidated())
859-
Bits.Decl.ValidationState = unsigned(ValidationState::Checked);
860-
}
861-
862854
bool escapedFromIfConfig() const {
863855
return Bits.Decl.EscapedFromIfConfig;
864856
}
@@ -2599,6 +2591,9 @@ class ValueDecl : public Decl {
25992591
/// if the base declaration is \c open, the override might have to be too.
26002592
bool hasOpenAccess(const DeclContext *useDC) const;
26012593

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

2761-
/// Set the opaque return type decl for this decl.
2762-
///
2763-
/// `this` must be of a decl type that supports opaque return types, and
2764-
/// must not have previously had an opaque result type set.
2765-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *D);
2766-
27672756
/// Retrieve the attribute associating this declaration with a
27682757
/// function builder, if there is one.
27692758
CustomAttr *getAttachedFunctionBuilder() const;
@@ -4524,8 +4513,6 @@ class AbstractStorageDecl : public ValueDecl {
45244513
Bits.AbstractStorageDecl.IsStatic = IsStatic;
45254514
}
45264515

4527-
OpaqueTypeDecl *OpaqueReturn = nullptr;
4528-
45294516
public:
45304517

45314518
/// Should this declaration be treated as if annotated with transparent
@@ -4783,14 +4770,6 @@ class AbstractStorageDecl : public ValueDecl {
47834770

47844771
bool hasAnyDynamicReplacementAccessors() const;
47854772

4786-
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
4787-
return OpaqueReturn;
4788-
}
4789-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *decl) {
4790-
assert(!OpaqueReturn && "already has opaque type decl");
4791-
OpaqueReturn = decl;
4792-
}
4793-
47944773
// Implement isa/cast/dyncast/etc.
47954774
static bool classof(const Decl *D) {
47964775
return D->getKind() >= DeclKind::First_AbstractStorageDecl &&
@@ -5968,14 +5947,13 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK);
59685947
class FuncDecl : public AbstractFunctionDecl {
59695948
friend class AbstractFunctionDecl;
59705949
friend class SelfAccessKindRequest;
5950+
friend class IsStaticRequest;
59715951

59725952
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
59735953
SourceLoc FuncLoc; // Location of the 'func' token.
59745954

59755955
TypeLoc FnRetType;
59765956

5977-
OpaqueTypeDecl *OpaqueReturn = nullptr;
5978-
59795957
protected:
59805958
FuncDecl(DeclKind Kind,
59815959
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
@@ -5991,14 +5969,14 @@ class FuncDecl : public AbstractFunctionDecl {
59915969
StaticLoc(StaticLoc), FuncLoc(FuncLoc) {
59925970
assert(!Name.getBaseName().isSpecial());
59935971

5994-
Bits.FuncDecl.IsStatic =
5995-
StaticLoc.isValid() || StaticSpelling != StaticSpellingKind::None;
59965972
Bits.FuncDecl.StaticSpelling = static_cast<unsigned>(StaticSpelling);
59975973

59985974
Bits.FuncDecl.ForcedStaticDispatch = false;
59995975
Bits.FuncDecl.SelfAccess =
60005976
static_cast<unsigned>(SelfAccessKind::NonMutating);
60015977
Bits.FuncDecl.SelfAccessComputed = false;
5978+
Bits.FuncDecl.IsStaticComputed = false;
5979+
Bits.FuncDecl.IsStatic = false;
60025980
}
60035981

60045982
private:
@@ -6018,6 +5996,13 @@ class FuncDecl : public AbstractFunctionDecl {
60185996
return None;
60195997
}
60205998

5999+
Optional<bool> getCachedIsStatic() const {
6000+
if (Bits.FuncDecl.IsStaticComputed)
6001+
return Bits.FuncDecl.IsStatic;
6002+
6003+
return None;
6004+
}
6005+
60216006
public:
60226007
/// Factory function only for use by deserialization.
60236008
static FuncDecl *createDeserialized(ASTContext &Context, SourceLoc StaticLoc,
@@ -6040,16 +6025,16 @@ class FuncDecl : public AbstractFunctionDecl {
60406025

60416026
Identifier getName() const { return getFullName().getBaseIdentifier(); }
60426027

6043-
bool isStatic() const {
6044-
return Bits.FuncDecl.IsStatic;
6045-
}
6028+
bool isStatic() const;
6029+
60466030
/// \returns the way 'static'/'class' was spelled in the source.
60476031
StaticSpellingKind getStaticSpelling() const {
60486032
return static_cast<StaticSpellingKind>(Bits.FuncDecl.StaticSpelling);
60496033
}
60506034
/// \returns the way 'static'/'class' should be spelled for this declaration.
60516035
StaticSpellingKind getCorrectStaticSpelling() const;
60526036
void setStatic(bool IsStatic = true) {
6037+
Bits.FuncDecl.IsStaticComputed = true;
60536038
Bits.FuncDecl.IsStatic = IsStatic;
60546039
}
60556040

@@ -6121,15 +6106,7 @@ class FuncDecl : public AbstractFunctionDecl {
61216106
}
61226107

61236108
OperatorDecl *getOperatorDecl() const;
6124-
6125-
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
6126-
return OpaqueReturn;
6127-
}
6128-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *decl) {
6129-
assert(!OpaqueReturn && "already has opaque type decl");
6130-
OpaqueReturn = decl;
6131-
}
6132-
6109+
61336110
/// Returns true if the function is forced to be statically dispatched.
61346111
bool hasForcedStaticDispatch() const {
61356112
return Bits.FuncDecl.ForcedStaticDispatch;

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 at position #%1",
384+
"candidate expects value of type %0 for parameter #%1",
385385
(Type, unsigned))
386386

387387
ERROR(cannot_convert_array_to_variadic,none,

include/swift/AST/FileUnit.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ 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,
64-
LazyResolver *resolver) {
63+
virtual OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName) {
6564
return nullptr;
6665
}
6766

include/swift/AST/Module.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ 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,
358-
LazyResolver *resolver);
357+
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName);
359358

360359
/// Find ValueDecls in the module and pass them to the given consumer object.
361360
///

include/swift/AST/SearchPathOptions.h

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef SWIFT_AST_SEARCHPATHOPTIONS_H
1414
#define SWIFT_AST_SEARCHPATHOPTIONS_H
1515

16+
#include "swift/Basic/ArrayRefView.h"
1617
#include "llvm/ADT/Hashing.h"
1718

1819
#include <string>
@@ -81,30 +82,38 @@ class SearchPathOptions {
8182
/// would for a non-system header.
8283
bool DisableModulesValidateSystemDependencies = false;
8384

85+
private:
86+
static StringRef
87+
pathStringFromFrameworkSearchPath(const FrameworkSearchPath &next) {
88+
return next.Path;
89+
};
90+
91+
public:
8492
/// Return a hash code of any components from these options that should
8593
/// contribute to a Swift Bridging PCH hash.
8694
llvm::hash_code getPCHHashComponents() const {
87-
using llvm::hash_value;
8895
using llvm::hash_combine;
89-
auto Code = hash_value(SDKPath);
90-
for (auto Import : ImportSearchPaths) {
91-
Code = hash_combine(Code, Import);
92-
}
93-
for (auto VFSFile : VFSOverlayFiles) {
94-
Code = hash_combine(Code, VFSFile);
95-
}
96-
for (const auto &FrameworkPath : FrameworkSearchPaths) {
97-
Code = hash_combine(Code, FrameworkPath.Path);
98-
}
99-
for (auto LibraryPath : LibrarySearchPaths) {
100-
Code = hash_combine(Code, LibraryPath);
101-
}
102-
Code = hash_combine(Code, RuntimeResourcePath);
103-
for (auto RuntimeLibraryImportPath : RuntimeLibraryImportPaths) {
104-
Code = hash_combine(Code, RuntimeLibraryImportPath);
105-
}
106-
Code = hash_combine(Code, DisableModulesValidateSystemDependencies);
107-
return Code;
96+
using llvm::hash_combine_range;
97+
98+
using FrameworkPathView = ArrayRefView<FrameworkSearchPath, StringRef,
99+
pathStringFromFrameworkSearchPath>;
100+
FrameworkPathView frameworkPathsOnly{FrameworkSearchPaths};
101+
102+
return hash_combine(SDKPath,
103+
hash_combine_range(ImportSearchPaths.begin(),
104+
ImportSearchPaths.end()),
105+
hash_combine_range(VFSOverlayFiles.begin(),
106+
VFSOverlayFiles.end()),
107+
// FIXME: Should we include the system-ness of framework
108+
// search paths too?
109+
hash_combine_range(frameworkPathsOnly.begin(),
110+
frameworkPathsOnly.end()),
111+
hash_combine_range(LibrarySearchPaths.begin(),
112+
LibrarySearchPaths.end()),
113+
RuntimeResourcePath,
114+
hash_combine_range(RuntimeLibraryImportPaths.begin(),
115+
RuntimeLibraryImportPaths.end()),
116+
DisableModulesValidateSystemDependencies);
108117
}
109118
};
110119

include/swift/AST/SourceFile.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ 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+
120127
friend ASTContext;
121128
friend Impl;
122129
public:
@@ -130,13 +137,6 @@ class SourceFile final : public FileUnit {
130137
/// The list of local type declarations in the source file.
131138
llvm::SetVector<TypeDecl *> LocalTypeDecls;
132139

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,14 +430,13 @@ class SourceFile final : public FileUnit {
430430
void setSyntaxRoot(syntax::SourceFileSyntax &&Root);
431431
bool hasSyntaxRoot() const;
432432

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

436435
void addUnvalidatedDeclWithOpaqueResultType(ValueDecl *vd) {
437436
UnvalidatedDeclsWithOpaqueReturnTypes.insert(vd);
438437
}
439438

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

442441
private:
443442

0 commit comments

Comments
 (0)