Skip to content

Commit d49bcb9

Browse files
committed
Merge branch 'master_final' into tensorflow-merge
2 parents 3236d2d + 1d7d58a commit d49bcb9

File tree

110 files changed

+1629
-1190
lines changed

Some content is hidden

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

110 files changed

+1629
-1190
lines changed

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)

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_CONFIG_LIBRARY_DIRS@")
9+
set(SWIFT_LIBRARY_DIRS "@SWIFT_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_CONFIG_LIBRARY_DIRS@")
15+
set(SWIFT_LIBRARY_DIR "@SWIFT_LIBRARY_DIRS@")
1616

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

include/swift/AST/Decl.h

Lines changed: 31 additions & 36 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+1+1,
391+
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1,
392392
/// \see AbstractFunctionDecl::BodyKind
393393
BodyKind : 3,
394394

@@ -404,12 +404,6 @@ 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-
413407
/// Whether this member was synthesized as part of a derived
414408
/// protocol conformance.
415409
Synthesized : 1,
@@ -418,7 +412,10 @@ class alignas(1 << DeclAlignInBits) Decl {
418412
HasSingleExpressionBody : 1
419413
);
420414

421-
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+
422419
/// Whether this function is a 'static' method.
423420
IsStatic : 1,
424421

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

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-
868854
bool escapedFromIfConfig() const {
869855
return Bits.Decl.EscapedFromIfConfig;
870856
}
@@ -2605,6 +2591,9 @@ class ValueDecl : public Decl {
26052591
/// if the base declaration is \c open, the override might have to be too.
26062592
bool hasOpenAccess(const DeclContext *useDC) const;
26072593

2594+
/// FIXME: This is deprecated.
2595+
bool isRecursiveValidation() const;
2596+
26082597
/// Retrieve the "interface" type of this value, which uses
26092598
/// GenericTypeParamType if the declaration is generic. For a generic
26102599
/// function, this will have a GenericFunctionType with a
@@ -5582,6 +5571,8 @@ class ImportAsMemberStatus {
55825571

55835572
/// Base class for function-like declarations.
55845573
class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5574+
friend class NeedsNewVTableEntryRequest;
5575+
55855576
public:
55865577
enum class BodyKind {
55875578
/// The function did not have a body in the source code file.
@@ -5651,6 +5642,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
56515642
/// Location of the 'throws' token.
56525643
SourceLoc ThrowsLoc;
56535644

5645+
struct {
5646+
unsigned NeedsNewVTableEntryComputed : 1;
5647+
unsigned NeedsNewVTableEntry : 1;
5648+
} LazySemanticInfo = { };
5649+
56545650
AbstractFunctionDecl(DeclKind Kind, DeclContext *Parent, DeclName Name,
56555651
SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc,
56565652
bool HasImplicitSelfDecl,
@@ -5662,8 +5658,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
56625658
Bits.AbstractFunctionDecl.HasImplicitSelfDecl = HasImplicitSelfDecl;
56635659
Bits.AbstractFunctionDecl.Overridden = false;
56645660
Bits.AbstractFunctionDecl.Throws = Throws;
5665-
Bits.AbstractFunctionDecl.NeedsNewVTableEntry = false;
5666-
Bits.AbstractFunctionDecl.HasComputedNeedsNewVTableEntry = false;
56675661
Bits.AbstractFunctionDecl.Synthesized = false;
56685662
Bits.AbstractFunctionDecl.HasSingleExpressionBody = false;
56695663
}
@@ -5833,16 +5827,9 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
58335827
return getBodyKind() == BodyKind::MemberwiseInitializer;
58345828
}
58355829

5836-
void setNeedsNewVTableEntry(bool value) {
5837-
Bits.AbstractFunctionDecl.HasComputedNeedsNewVTableEntry = true;
5838-
Bits.AbstractFunctionDecl.NeedsNewVTableEntry = value;
5839-
}
5840-
5841-
bool needsNewVTableEntry() const {
5842-
if (!Bits.AbstractFunctionDecl.HasComputedNeedsNewVTableEntry)
5843-
const_cast<AbstractFunctionDecl *>(this)->computeNeedsNewVTableEntry();
5844-
return Bits.AbstractFunctionDecl.NeedsNewVTableEntry;
5845-
}
5830+
/// For a method of a class, checks whether it will require a new entry in the
5831+
/// vtable.
5832+
bool needsNewVTableEntry() const;
58465833

58475834
bool isEffectiveLinkageMoreVisibleThan(ValueDecl *other) const {
58485835
return (std::min(getEffectiveAccess(), AccessLevel::Public) >
@@ -5984,6 +5971,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK);
59845971
class FuncDecl : public AbstractFunctionDecl {
59855972
friend class AbstractFunctionDecl;
59865973
friend class SelfAccessKindRequest;
5974+
friend class IsStaticRequest;
59875975

59885976
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
59895977
SourceLoc FuncLoc; // Location of the 'func' token.
@@ -6005,14 +5993,14 @@ class FuncDecl : public AbstractFunctionDecl {
60055993
StaticLoc(StaticLoc), FuncLoc(FuncLoc) {
60065994
assert(!Name.getBaseName().isSpecial());
60075995

6008-
Bits.FuncDecl.IsStatic =
6009-
StaticLoc.isValid() || StaticSpelling != StaticSpellingKind::None;
60105996
Bits.FuncDecl.StaticSpelling = static_cast<unsigned>(StaticSpelling);
60115997

60125998
Bits.FuncDecl.ForcedStaticDispatch = false;
60135999
Bits.FuncDecl.SelfAccess =
60146000
static_cast<unsigned>(SelfAccessKind::NonMutating);
60156001
Bits.FuncDecl.SelfAccessComputed = false;
6002+
Bits.FuncDecl.IsStaticComputed = false;
6003+
Bits.FuncDecl.IsStatic = false;
60166004
}
60176005

60186006
private:
@@ -6032,6 +6020,13 @@ class FuncDecl : public AbstractFunctionDecl {
60326020
return None;
60336021
}
60346022

6023+
Optional<bool> getCachedIsStatic() const {
6024+
if (Bits.FuncDecl.IsStaticComputed)
6025+
return Bits.FuncDecl.IsStatic;
6026+
6027+
return None;
6028+
}
6029+
60356030
public:
60366031
/// Factory function only for use by deserialization.
60376032
static FuncDecl *createDeserialized(ASTContext &Context, SourceLoc StaticLoc,
@@ -6054,19 +6049,19 @@ class FuncDecl : public AbstractFunctionDecl {
60546049

60556050
Identifier getName() const { return getFullName().getBaseIdentifier(); }
60566051

6057-
bool isStatic() const {
6058-
return Bits.FuncDecl.IsStatic;
6059-
}
6052+
bool isStatic() const;
60606053
bool isCallable() const {
60616054
return getName().str() == "callAsFunction" && isInstanceMember();
60626055
}
6056+
60636057
/// \returns the way 'static'/'class' was spelled in the source.
60646058
StaticSpellingKind getStaticSpelling() const {
60656059
return static_cast<StaticSpellingKind>(Bits.FuncDecl.StaticSpelling);
60666060
}
60676061
/// \returns the way 'static'/'class' should be spelled for this declaration.
60686062
StaticSpellingKind getCorrectStaticSpelling() const;
60696063
void setStatic(bool IsStatic = true) {
6064+
Bits.FuncDecl.IsStaticComputed = true;
60706065
Bits.FuncDecl.IsStatic = IsStatic;
60716066
}
60726067

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/TypeCheckRequests.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,49 @@ class OpaqueResultTypeRequest
12991299
bool isCached() const { return true; }
13001300
};
13011301

1302+
/// Determines if a function declaration is 'static'.
1303+
class IsStaticRequest :
1304+
public SimpleRequest<IsStaticRequest,
1305+
bool(FuncDecl *),
1306+
CacheKind::SeparatelyCached> {
1307+
public:
1308+
using SimpleRequest::SimpleRequest;
1309+
1310+
private:
1311+
friend SimpleRequest;
1312+
1313+
// Evaluation.
1314+
llvm::Expected<bool>
1315+
evaluate(Evaluator &evaluator, FuncDecl *value) const;
1316+
1317+
public:
1318+
// Separate caching.
1319+
bool isCached() const { return true; }
1320+
Optional<bool> getCachedResult() const;
1321+
void cacheResult(bool value) const;
1322+
};
1323+
1324+
class NeedsNewVTableEntryRequest
1325+
: public SimpleRequest<NeedsNewVTableEntryRequest,
1326+
bool(AbstractFunctionDecl *),
1327+
CacheKind::SeparatelyCached> {
1328+
public:
1329+
using SimpleRequest::SimpleRequest;
1330+
1331+
private:
1332+
friend SimpleRequest;
1333+
1334+
// Evaluation.
1335+
llvm::Expected<bool> evaluate(Evaluator &evaluator,
1336+
AbstractFunctionDecl *decl) const;
1337+
1338+
public:
1339+
// Separate caching.
1340+
bool isCached() const { return true; }
1341+
Optional<bool> getCachedResult() const;
1342+
void cacheResult(bool value) const;
1343+
};
1344+
13021345
// Allow AnyValue to compare two Type values, even though Type doesn't
13031346
// support ==.
13041347
template<>

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,7 @@ SWIFT_REQUEST(TypeChecker, USRGenerationRequest, std::string(const ValueDecl *),
147147
Cached, NoLocationInfo)
148148
SWIFT_REQUEST(TypeChecker, IsABICompatibleOverrideRequest,
149149
bool(ValueDecl *), Cached, NoLocationInfo)
150+
SWIFT_REQUEST(TypeChecker, IsStaticRequest,
151+
bool(FuncDecl *), SeparatelyCached, NoLocationInfo)
152+
SWIFT_REQUEST(TypeChecker, NeedsNewVTableEntryRequest,
153+
bool(AbstractFunctionDecl *), SeparatelyCached, NoLocationInfo)

include/swift/AST/USRGeneration.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
12+
//
13+
// Unique Symbol References (USRs) provide a textual encoding for
14+
// declarations. These are used for indexing, analogous to how mangled names
15+
// are used in object files.
16+
//
17+
//===----------------------------------------------------------------------===//
1218

1319
#ifndef SWIFT_AST_USRGENERATION_H
1420
#define SWIFT_AST_USRGENERATION_H

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ namespace swift {
329329

330330
/// Whether to enable experimental differentiable programming features:
331331
/// `@differentiable` declaration attribute, etc.
332-
// SWIFT_ENABLE_TENSORFLOW
333-
// The default on tensorflow branch is true. On master, it is false.
334-
bool EnableExperimentalDifferentiableProgramming = true;
332+
bool EnableExperimentalDifferentiableProgramming = false;
335333

336334
/// Whether to enable #quote, #unquote and @quoted.
337335
bool EnableExperimentalQuasiquotes = false;

include/swift/Basic/StringExtras.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "swift/Basic/LLVM.h"
2222
#include "swift/Basic/OptionSet.h"
2323
#include "llvm/ADT/SmallVector.h"
24-
#include "llvm/ADT/StringMap.h"
2524
#include "llvm/ADT/StringRef.h"
2625
#include "llvm/ADT/StringSet.h"
2726
#include "llvm/Support/Allocator.h"
@@ -65,6 +64,8 @@ namespace swift {
6564

6665
public:
6766
StringRef copyString(StringRef string);
67+
68+
llvm::BumpPtrAllocator &getAllocator() { return Allocator; }
6869
};
6970

7071
namespace camel_case {
@@ -430,11 +431,13 @@ StringRef matchLeadingTypeName(StringRef name, OmissionTypeName typeName);
430431
/// Describes a set of names with an inheritance relationship.
431432
class InheritedNameSet {
432433
const InheritedNameSet *Parent;
433-
llvm::StringSet<> Names;
434+
llvm::StringSet<llvm::BumpPtrAllocator &> Names;
434435

435436
public:
436437
/// Construct a new inherited name set with the given parent.
437-
explicit InheritedNameSet(const InheritedNameSet *parent) : Parent(parent) { }
438+
InheritedNameSet(const InheritedNameSet *parent,
439+
llvm::BumpPtrAllocator &allocator)
440+
: Parent(parent), Names(allocator) { }
438441

439442
// Add a new name to the set.
440443
void add(StringRef name);

include/swift/Parse/ASTGen.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ class ASTGen {
7979
//===--------------------------------------------------------------------===//
8080
// Expressions.
8181

82+
Expr *generate(const syntax::ExprSyntax &Expr, const SourceLoc Loc);
83+
Expr *generate(const syntax::IdentifierExprSyntax &Expr, const SourceLoc Loc);
84+
Expr *generate(const syntax::EditorPlaceholderExprSyntax &Expr,
85+
const SourceLoc Loc);
86+
Expr *generate(const syntax::SpecializeExprSyntax &Expr, const SourceLoc Loc);
8287
Expr *generate(const syntax::IntegerLiteralExprSyntax &Expr,
8388
const SourceLoc Loc);
8489
Expr *generate(const syntax::FloatLiteralExprSyntax &Expr,
@@ -96,7 +101,13 @@ class ASTGen {
96101
const SourceLoc Loc);
97102
Expr *generate(const syntax::UnknownExprSyntax &Expr, const SourceLoc Loc);
98103

104+
std::pair<DeclName, DeclNameLoc> generateUnqualifiedDeclName(
105+
const syntax::TokenSyntax &idTok,
106+
const Optional<syntax::DeclNameArgumentsSyntax> &args,
107+
const SourceLoc Loc);
108+
99109
private:
110+
100111
Expr *generateMagicIdentifierLiteralExpression(
101112
const syntax::TokenSyntax &PoundToken, const SourceLoc Loc);
102113

@@ -168,10 +179,9 @@ class ASTGen {
168179
//===--------------------------------------------------------------------===//
169180
// Generics.
170181

171-
TypeRepr *generate(const syntax::GenericArgumentSyntax &Arg,
172-
const SourceLoc Loc);
173-
llvm::SmallVector<TypeRepr *, 4>
174-
generate(const syntax::GenericArgumentListSyntax &Args, const SourceLoc Loc);
182+
void generate(const syntax::GenericArgumentClauseSyntax &Arg,
183+
const SourceLoc Loc, SourceLoc &lAngleLoc, SourceLoc &rAngleLoc,
184+
SmallVectorImpl<TypeRepr *> &args);
175185

176186
GenericParamList *
177187
generate(const syntax::GenericParameterClauseListSyntax &clause,

0 commit comments

Comments
 (0)