Skip to content

Commit 0b7eae6

Browse files
Merge pull request #2603 from swiftwasm/katei/merge-main-2021-01-29
Merge main 2021-01-29
2 parents ca53527 + 73d1010 commit 0b7eae6

File tree

221 files changed

+6807
-4279
lines changed

Some content is hidden

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

221 files changed

+6807
-4279
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,6 @@ set(SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS "2.0" CACHE STRING
336336
# User-configurable debugging options.
337337
#
338338

339-
option(SWIFT_AST_VERIFIER
340-
"Enable the AST verifier in the built compiler, and run it on every compilation"
341-
TRUE)
342-
343339
option(SWIFT_SIL_VERIFY_ALL
344340
"Run SIL verification after each transform when building Swift files in the build process"
345341
FALSE)

CODE_OWNERS.TXT

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ E: [email protected]
4747
G: rjmccall
4848
D: Demangler, IRGen, Runtime
4949

50+
N: Victoria Mitchell
51+
52+
G: QuietMisdreavus
53+
D: SymbolGraphGen
54+
5055
N: Max Moiseev
5156
5257
G: moiseev

docs/HowToGuides/GettingStarted.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ toolchain as a one-off, there are a couple of differences:
6868
If you plan on contributing regularly, cloning over SSH provides a better
6969
experience. After you've [uploaded your SSH keys to GitHub][]:
7070
```sh
71-
git clone [email protected]:apple/swift.git .
71+
git clone [email protected]:apple/swift.git swift
72+
cd swift
7273
utils/update-checkout --clone-with-ssh
7374
```
7475
- Via HTTPS:
7576
If you want to check out the sources as read-only,
7677
or are not familiar with setting up SSH,
7778
you can use HTTPS instead:
7879
```sh
79-
git clone https://github.com/apple/swift.git .
80+
git clone https://github.com/apple/swift.git swift
81+
cd swift
8082
utils/update-checkout --clone
8183
```
8284
**Note:** If you've already forked the project on GitHub at this stage,

docs/OptimizationTips.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ this allows the compiler to elide unnecessary copies by retaining the container
245245
instead of performing a deep copy. This is done by only copying the underlying
246246
container if the reference count of the container is greater than 1 and the
247247
container is mutated. For instance in the following, no copying will occur when
248-
``d`` is assigned to ``c``, but when ``d`` undergoes structural mutation by
248+
``c`` is assigned to ``d``, but when ``d`` undergoes structural mutation by
249249
appending ``2``, ``d`` will be copied and then ``2`` will be appended to ``d``:
250250

251251
::

include/swift/ABI/Task.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,16 @@ class AsyncTask : public HeapObject, public Job {
343343
};
344344

345345
struct GroupStatus {
346-
static const unsigned long maskReady = 0x00FFFFF0000000000l;
347-
static const unsigned long oneReadyTask = 0x00000010000000000l;
346+
static const uint64_t maskReady = 0x00FFFFF0000000000ll;
347+
static const uint64_t oneReadyTask = 0x00000010000000000ll;
348348

349-
static const unsigned long maskPending = 0x0000000FFFFF00000l;
350-
static const unsigned long onePendingTask = 0x00000000000100000l;
349+
static const uint64_t maskPending = 0x0000000FFFFF00000ll;
350+
static const uint64_t onePendingTask = 0x00000000000100000ll;
351351

352-
static const unsigned long maskWaiting = 0x000000000000FFFFFl;
353-
static const unsigned long oneWaitingTask = 0x00000000000000001l;
352+
static const uint64_t maskWaiting = 0x000000000000FFFFFll;
353+
static const uint64_t oneWaitingTask = 0x00000000000000001ll;
354354

355-
unsigned long status;
355+
uint64_t status;
356356

357357
unsigned int readyTasks() {
358358
return (status & maskReady) >> 40;
@@ -436,7 +436,7 @@ class AsyncTask : public HeapObject, public Job {
436436
mutable std::mutex mutex;
437437

438438
/// Used for queue management, counting number of waiting and ready tasks
439-
std::atomic<unsigned long> status;
439+
std::atomic<uint64_t> status;
440440

441441
/// Queue containing completed tasks offered into this channel.
442442
///

include/swift/AST/ASTContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,10 @@ class ASTContext final {
11541154
/// standard library's String implementation.
11551155
bool isASCIIString(StringRef s) const;
11561156

1157+
/// Retrieve the name of to be used for the entry point, either main or an
1158+
/// alternative specified via the -entry-point-function-name frontend flag.
1159+
std::string getEntryPointFunctionName() const;
1160+
11571161
private:
11581162
friend Decl;
11591163
Optional<RawComment> getRawComment(const Decl *D);

include/swift/AST/ClangModuleLoader.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ class ClangModuleLoader : public ModuleLoader {
177177
StringRef relatedEntityKind,
178178
llvm::function_ref<void(TypeDecl *)> receiver) = 0;
179179

180+
/// Instantiate and import class template using given arguments.
181+
///
182+
/// This method will find the clang::ClassTemplateSpecialization decl if
183+
/// it already exists, or it will create one. Then it will import this
184+
/// decl the same way as we import typedeffed class templates - using
185+
/// the hidden struct prefixed with `__CxxTemplateInst`.
186+
virtual StructDecl *
187+
instantiateCXXClassTemplate(clang::ClassTemplateDecl *decl,
188+
ArrayRef<clang::TemplateArgument> arguments) = 0;
189+
180190
/// Try to parse the string as a Clang function type.
181191
///
182192
/// Returns null if there was a parsing failure.

include/swift/AST/Decl.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,6 +3402,42 @@ class EnumDecl final : public NominalTypeDecl {
34023402
class StructDecl final : public NominalTypeDecl {
34033403
SourceLoc StructLoc;
34043404

3405+
// We import C++ class templates as generic structs. Then when in Swift code
3406+
// we want to substitude generic parameters with actual arguments, we
3407+
// convert the arguments to C++ equivalents and ask Clang to instantiate the
3408+
// C++ template. Then we import the C++ class template instantiation
3409+
// as a non-generic structs with a name prefixed with `__CxxTemplateInst`.
3410+
//
3411+
// To reiterate:
3412+
// 1) We need to have a C++ class template declaration in the Clang AST. This
3413+
// declaration is simply imported from a Clang module.
3414+
// 2) We need a Swift generic struct in the Swift AST. This will provide
3415+
// template arguments to Clang.
3416+
// 3) We produce a C++ class template instantiation in the Clang AST
3417+
// using 1) and 2). This declaration does not exist in the Clang module
3418+
// AST initially in the general case, it's added there on instantiation.
3419+
// 4) We import the instantiation as a Swift struct, with the name prefixed
3420+
// with `__CxxTemplateInst`.
3421+
//
3422+
// This causes a problem for serialization/deserialization of the Swift
3423+
// module. Imagine the Swift struct from 4) is used in the function return
3424+
// type. We cannot just serialize the non generic Swift struct, because on
3425+
// deserialization we would need to find its backing Clang declaration
3426+
// (the C++ class template instantiation), and it won't be found in the
3427+
// general case. Only the C++ class template from step 1) is in the Clang
3428+
// AST.
3429+
//
3430+
// What we need is to serialize enough information to be
3431+
// able to instantiate C++ class template on deserialization. It turns out
3432+
// that all that information is conveniently covered by the BoundGenericType,
3433+
// which we store in this field. The field is set during the typechecking at
3434+
// the time when we instantiate the C++ class template.
3435+
//
3436+
// Alternative, and likely better solution long term, is to serialize the
3437+
// C++ class template instantiation into a synthetic Clang module, and load
3438+
// this Clang module on deserialization.
3439+
Type TemplateInstantiationType = Type();
3440+
34053441
public:
34063442
StructDecl(SourceLoc StructLoc, Identifier Name, SourceLoc NameLoc,
34073443
ArrayRef<TypeLoc> Inherited,
@@ -3445,6 +3481,9 @@ class StructDecl final : public NominalTypeDecl {
34453481
bool isCxxNonTrivial() const { return Bits.StructDecl.IsCxxNonTrivial; }
34463482

34473483
void setIsCxxNonTrivial(bool v) { Bits.StructDecl.IsCxxNonTrivial = v; }
3484+
3485+
Type getTemplateInstantiationType() const { return TemplateInstantiationType; }
3486+
void setTemplateInstantiationType(Type t) { TemplateInstantiationType = t; }
34483487
};
34493488

34503489
/// This is the base type for AncestryOptions. Each flag describes possible

include/swift/AST/DiagnosticsParse.def

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,6 @@ ERROR(snake_case_deprecated,none,
960960
"%0 has been replaced with %1 in Swift 3",
961961
(StringRef, StringRef))
962962

963-
964963
// Assignment statement
965964
ERROR(expected_expr_assignment,none,
966965
"expected expression in assignment", ())
@@ -988,6 +987,10 @@ NOTE(indent_expression_to_silence,none,
988987
ERROR(expected_expr_throw,PointsToFirstBadToken,
989988
"expected expression in 'throw' statement", ())
990989

990+
// Await/Async
991+
ERROR(expected_await_not_async,none,
992+
"found 'async' in expression; did you mean 'await'?", ())
993+
991994
// Yield Statment
992995
ERROR(expected_expr_yield,PointsToFirstBadToken,
993996
"expected expression in 'yield' statement", ())

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,10 @@ ERROR(unexportable_clang_function_type,none,
27882788
"it may use anonymous types or types defined outside of a module",
27892789
(Type))
27902790

2791+
ERROR(cxx_class_instantiation_failed,none,
2792+
"couldn't instantiate a C++ class template",
2793+
())
2794+
27912795
WARNING(warn_implementation_only_conflict,none,
27922796
"%0 inconsistently imported as implementation-only",
27932797
(Identifier))

0 commit comments

Comments
 (0)