Skip to content

Commit d6e3236

Browse files
authored
---
yaml --- r: 343246 b: refs/heads/master-rebranch c: 50147c4 h: refs/heads/master
1 parent 0e84394 commit d6e3236

Some content is hidden

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

59 files changed

+1616
-259
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: 1e173d8931e70817080eb19aafe2ed4852d1f5ef
1458+
refs/heads/master-rebranch: 50147c4debf3ea846034941bedfc7fcd558036c8
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/include/swift/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ class ASTContext final {
826826
/// of the given decl context.
827827
///
828828
/// \param IDC The context whose member decls should be lazily parsed.
829-
void parseMembers(IterableDeclContext *IDC);
829+
std::vector<Decl *> parseMembers(IterableDeclContext *IDC);
830830

831831
/// Get the lazy function data for the given generic context.
832832
///

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ SWIFT_TYPEID(AncestryFlags)
3333
SWIFT_TYPEID_NAMED(GenericSignature *, GenericSignature)
3434
SWIFT_TYPEID_NAMED(GenericTypeParamType *, GenericTypeParamType)
3535
SWIFT_TYPEID(Requirement)
36+
SWIFT_TYPEID_NAMED(IterableDeclContext *, IterableDeclContext)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,26 @@
1717
#ifndef SWIFT_AST_ASTTYPEIDS_H
1818
#define SWIFT_AST_ASTTYPEIDS_H
1919

20+
#include "swift/Basic/LLVM.h"
2021
#include "swift/Basic/TypeID.h"
2122
namespace swift {
2223

2324
class CustomAttr;
25+
class Decl;
2426
class GenericSignature;
2527
class GenericTypeParamType;
28+
class IterableDeclContext;
2629
class NominalTypeDecl;
30+
class OperatorDecl;
2731
struct PropertyWrapperBackingPropertyInfo;
2832
struct PropertyWrapperTypeInfo;
2933
enum class CtorInitializerKind;
3034
struct PropertyWrapperMutability;
35+
class ProtocolDecl;
3136
class Requirement;
37+
enum class ResilienceExpansion : unsigned;
3238
class Type;
39+
class ValueDecl;
3340
class VarDecl;
3441
class TypeAliasDecl;
3542
class Type;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7248,6 +7248,17 @@ void simple_display(llvm::raw_ostream &out, const Decl *decl);
72487248
/// Display ValueDecl subclasses.
72497249
void simple_display(llvm::raw_ostream &out, const ValueDecl *decl);
72507250

7251+
/// Display ExtensionDecls.
7252+
inline void simple_display(llvm::raw_ostream &out, const ExtensionDecl *decl) {
7253+
simple_display(out, static_cast<const Decl *>(decl));
7254+
}
7255+
7256+
/// Display NominalTypeDecls.
7257+
inline void simple_display(llvm::raw_ostream &out,
7258+
const NominalTypeDecl *decl) {
7259+
simple_display(out, static_cast<const Decl *>(decl));
7260+
}
7261+
72517262
/// Extract the source location from the given declaration.
72527263
SourceLoc extractNearestSourceLoc(const Decl *decl);
72537264

@@ -7261,6 +7272,11 @@ inline SourceLoc extractNearestSourceLoc(const GenericTypeDecl *type) {
72617272
return extractNearestSourceLoc(static_cast<const Decl *>(type));
72627273
}
72637274

7275+
/// Extract the source location from the given declaration.
7276+
inline SourceLoc extractNearestSourceLoc(const NominalTypeDecl *type) {
7277+
return extractNearestSourceLoc(static_cast<const Decl *>(type));
7278+
}
7279+
72647280
/// Extract the source location from the given declaration.
72657281
inline SourceLoc extractNearestSourceLoc(const AbstractFunctionDecl *func) {
72667282
return extractNearestSourceLoc(static_cast<const Decl *>(func));

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,8 @@ class IterableDeclContext {
699699
/// time, but I think it's a better trade to just keep a count here.
700700
unsigned MemberCount : 29;
701701

702-
/// Whether parsing the members of this context has been delayed.
703-
unsigned HasUnparsedMembers : 1;
702+
/// Whether we have already added the parsed members into the context.
703+
unsigned AddedParsedMembers : 1;
704704

705705
/// Whether delayed parsing detected a possible operator definition
706706
/// while skipping the body of this context.
@@ -722,8 +722,8 @@ class IterableDeclContext {
722722
IterableDeclContext(IterableDeclContextKind kind)
723723
: LastDeclAndKind(nullptr, kind) {
724724
MemberCount = 0;
725+
AddedParsedMembers = 0;
725726
HasOperatorDeclarations = 0;
726-
HasUnparsedMembers = 0;
727727
HasNestedClassDeclarations = 0;
728728
}
729729

@@ -732,13 +732,7 @@ class IterableDeclContext {
732732
return LastDeclAndKind.getInt();
733733
}
734734

735-
bool hasUnparsedMembers() const {
736-
return HasUnparsedMembers;
737-
}
738-
739-
void setHasUnparsedMembers() {
740-
HasUnparsedMembers = 1;
741-
}
735+
bool hasUnparsedMembers() const;
742736

743737
bool maybeHasOperatorDeclarations() const {
744738
return HasOperatorDeclarations;
@@ -839,9 +833,14 @@ void simple_display(llvm::raw_ostream &out, const ParamT *dc) {
839833
out << "(null)";
840834
}
841835

836+
void simple_display(llvm::raw_ostream &out, const IterableDeclContext *idc);
837+
842838
/// Extract the source location from the given declaration context.
843839
SourceLoc extractNearestSourceLoc(const DeclContext *dc);
844840

841+
/// Extract the source location from the given declaration context.
842+
SourceLoc extractNearestSourceLoc(const IterableDeclContext *idc);
843+
845844
} // end namespace swift
846845

847846
namespace llvm {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ class LazyMemberParser {
9090
public:
9191
virtual ~LazyMemberParser() = default;
9292

93-
/// Populates a given decl context \p IDC with all of its members.
94-
///
95-
/// The implementation should add the members to IDC.
96-
virtual void parseMembers(IterableDeclContext *IDC) = 0;
93+
/// Retrieves the parsed members for the given decl context \p IDC.
94+
virtual std::vector<Decl *> parseMembers(IterableDeclContext *IDC) = 0;
9795

9896
/// Return whether the iterable decl context needs parsing.
9997
virtual bool hasUnparsedMembers(const IterableDeclContext *IDC) = 0;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//===--- ParseRequests.h - Parsing Requests ---------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines parsing requests.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
#ifndef SWIFT_PARSE_REQUESTS_H
17+
#define SWIFT_PARSE_REQUESTS_H
18+
19+
#include "swift/AST/ASTTypeIDs.h"
20+
#include "swift/AST/SimpleRequest.h"
21+
22+
namespace swift {
23+
24+
/// Report that a request of the given kind is being evaluated, so it
25+
/// can be recorded by the stats reporter.
26+
template<typename Request>
27+
void reportEvaluatedRequest(UnifiedStatsReporter &stats,
28+
const Request &request);
29+
30+
/// Parse the members of a nominal type declaration or extension.
31+
class ParseMembersRequest :
32+
public SimpleRequest<ParseMembersRequest,
33+
ArrayRef<Decl *>(IterableDeclContext *),
34+
CacheKind::Cached>
35+
{
36+
public:
37+
using SimpleRequest::SimpleRequest;
38+
39+
private:
40+
friend SimpleRequest;
41+
42+
// Evaluation.
43+
ArrayRef<Decl *> evaluate(Evaluator &evaluator,
44+
IterableDeclContext *idc) const;
45+
46+
public:
47+
// Caching
48+
bool isCached() const { return true; }
49+
};
50+
51+
/// The zone number for the parser.
52+
#define SWIFT_TYPEID_ZONE Parse
53+
#define SWIFT_TYPEID_HEADER "swift/AST/ParseTypeIDZone.def"
54+
#include "swift/Basic/DefineTypeIDZone.h"
55+
#undef SWIFT_TYPEID_ZONE
56+
#undef SWIFT_TYPEID_HEADER
57+
58+
// Set up reporting of evaluated requests.
59+
#define SWIFT_REQUEST(Zone, RequestType) \
60+
template<> \
61+
inline void reportEvaluatedRequest(UnifiedStatsReporter &stats, \
62+
const RequestType &request) { \
63+
++stats.getFrontendCounters().RequestType; \
64+
}
65+
#include "swift/AST/ParseTypeIDZone.def"
66+
#undef SWIFT_REQUEST
67+
68+
} // end namespace swift
69+
70+
#endif // SWIFT_PARSE_REQUESTS_H
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===--- ParseTypeIDZone.def ------------------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This definition file describes the requests in the parser's zone.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
SWIFT_REQUEST(Parse, ParseMembersRequest)

branches/master-rebranch/include/swift/Basic/Statistics.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ FRONTEND_STATISTIC(Parse, NumFunctionsParsed)
195195
/// Number of full braced decl list parsed.
196196
FRONTEND_STATISTIC(Parse, NumIterableDeclContextParsed)
197197

198+
#define SWIFT_REQUEST(ZONE, NAME) FRONTEND_STATISTIC(Parse, NAME)
199+
#include "swift/AST/ParseTypeIDZone.def"
200+
#undef SWIFT_REQUEST
201+
198202
/// Number of conformances that were deserialized by this frontend job.
199203
FRONTEND_STATISTIC(Sema, NumConformancesDeserialized)
200204

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enum class Zone : uint8_t {
3535
IDE = 137,
3636
IDETypeChecking = 97,
3737
NameLookup = 9,
38+
Parse = 8,
3839
TypeChecker = 10,
3940
// N.B. This is not a formal zone and exists solely to support the unit tests.
4041
ArithmeticEvaluator = 255,

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ class Parser {
971971

972972
void parseDeclDelayed();
973973

974-
void parseDeclListDelayed(IterableDeclContext *IDC);
974+
std::vector<Decl *> parseDeclListDelayed(IterableDeclContext *IDC);
975975

976976
bool parseMemberDeclList(SourceLoc LBLoc, SourceLoc &RBLoc,
977977
SourceLoc PosBeforeLB,
@@ -1080,9 +1080,10 @@ class Parser {
10801080
ParserStatus parseDeclItem(bool &PreviousHadSemi,
10811081
Parser::ParseDeclOptions Options,
10821082
llvm::function_ref<void(Decl*)> handler);
1083-
bool parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc,
1084-
Diag<> ErrorDiag, ParseDeclOptions Options,
1085-
IterableDeclContext *IDC);
1083+
std::vector<Decl *> parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc,
1084+
Diag<> ErrorDiag, ParseDeclOptions Options,
1085+
IterableDeclContext *IDC,
1086+
bool &hadError);
10861087
ParserResult<ExtensionDecl> parseDeclExtension(ParseDeclOptions Flags,
10871088
DeclAttributes &Attributes);
10881089
ParserResult<EnumDecl> parseDeclEnum(ParseDeclOptions Flags,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class PersistentParserState: public LazyMemberParser {
153153
void delayTopLevel(TopLevelCodeDecl *TLCD, SourceRange BodyRange,
154154
SourceLoc PreviousLoc);
155155

156-
void parseMembers(IterableDeclContext *IDC) override;
156+
std::vector<Decl *> parseMembers(IterableDeclContext *IDC) override;
157157

158158
bool hasDelayedDecl() {
159159
return CodeCompletionDelayedDeclState.get() != nullptr;

branches/master-rebranch/include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
/// This macro follows the same conventions as PASS(Id, Tag, Description),
3737
/// but is used for IRGen passes which are built outside of the
3838
/// SILOptimizer library.
39-
///
39+
///
4040
/// An IRGen pass is created by IRGen and needs to be registered with the pass
4141
/// manager dynamically.
4242
#ifndef IRGEN_PASS
@@ -312,6 +312,8 @@ PASS(SerializeSILPass, "serialize-sil",
312312
PASS(YieldOnceCheck, "yield-once-check",
313313
"Check correct usage of yields in yield-once coroutines")
314314
PASS(OSLogOptimization, "os-log-optimization", "Optimize os log calls")
315+
PASS(MandatoryCombiner, "mandatory-combiner",
316+
"Perform mandatory peephole combines")
315317
PASS(BugReducerTester, "bug-reducer-tester",
316318
"sil-bug-reducer Tool Testing by Asserting on a Sentinel Function")
317319
PASS_RANGE(AllPasses, AADumper, BugReducerTester)

branches/master-rebranch/include/swift/Serialization/ModuleFormat.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 516; // encode GenericSignature and GenericEnvironment together
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 517; // better string hash seed
56+
57+
/// A standard hash seed used for all string hashes in a serialized module.
58+
///
59+
/// This is the same as the default used by llvm::djbHash, just provided
60+
/// explicitly here to note that it's part of the format.
61+
const uint32_t SWIFTMODULE_HASH_SEED = 5381;
5662

5763
using DeclIDField = BCFixed<31>;
5864

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,13 @@ namespace swift {
389389
/// The ASTContext will automatically call these upon construction.
390390
void registerNameLookupRequestFunctions(Evaluator &evaluator);
391391

392+
/// Register Parse-level request functions with the evaluator.
393+
///
394+
/// Clients that form an ASTContext and will perform any parsing queries
395+
/// using Parse-level logic should call these functions after forming the
396+
/// ASTContext.
397+
void registerParseRequestFunctions(Evaluator &evaluator);
398+
392399
/// Register Sema-level request functions with the evaluator.
393400
///
394401
/// Clients that form an ASTContext and will perform any semantic queries

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,12 +2015,14 @@ LazyContextData *ASTContext::getOrCreateLazyContextData(
20152015
return entry;
20162016
}
20172017

2018-
void ASTContext::parseMembers(IterableDeclContext *IDC) {
2018+
std::vector<Decl *> ASTContext::parseMembers(IterableDeclContext *IDC) {
20192019
assert(IDC->hasUnparsedMembers());
20202020
for (auto *p: getImpl().lazyParsers) {
20212021
if (p->hasUnparsedMembers(IDC))
2022-
p->parseMembers(IDC);
2022+
return p->parseMembers(IDC);
20232023
}
2024+
2025+
return { };
20242026
}
20252027

20262028
LazyIterableDeclContextData *ASTContext::getOrCreateLazyIterableContextData(

0 commit comments

Comments
 (0)