Skip to content

Commit 01db90d

Browse files
committed
Merge branch 'master' of github.com:apple/swift into autodiff-upstream-stdlib-differentiation
2 parents b6d7653 + 9cfe91a commit 01db90d

File tree

58 files changed

+2574
-168
lines changed

Some content is hidden

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

58 files changed

+2574
-168
lines changed

include/swift/AST/ClangModuleLoader.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ class ClangModuleLoader : public ModuleLoader {
128128

129129
/// Retrieves the Swift wrapper for the given Clang module, creating
130130
/// it if necessary.
131-
virtual ModuleDecl *getWrapperForModule(const clang::Module *mod) const = 0;
131+
virtual ModuleDecl *
132+
getWrapperForModule(const clang::Module *mod,
133+
bool returnOverlayIfPossible = false) const = 0;
132134

133135
/// Adds a new search path to the Clang CompilerInstance, as if specified with
134136
/// -I or -F.

include/swift/AST/DiagnosticsSIL.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ NOTE(autodiff_cannot_param_subset_thunk_partially_applied_orig_fn,none,
512512
"function; use an explicit closure instead", ())
513513
NOTE(autodiff_cannot_differentiate_through_multiple_results,none,
514514
"cannot differentiate through multiple results", ())
515+
NOTE(autodiff_cannot_differentiate_through_inout_arguments,none,
516+
"cannot differentiate through 'inout' arguments", ())
515517
// TODO(TF-1149): Remove this diagnostic.
516518
NOTE(autodiff_loadable_value_addressonly_tangent_unsupported,none,
517519
"cannot yet differentiate value whose type %0 has a compile-time known "

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@ ERROR(expr_swift_keypath_invalid_component,none,
585585
"invalid component of Swift key path", ())
586586
ERROR(expr_swift_keypath_not_starting_with_type,none,
587587
"a Swift key path must begin with a type", ())
588+
ERROR(expr_swift_keypath_not_starting_with_dot,none,
589+
"a Swift key path with contextual root must begin with a leading dot",
590+
())
588591
ERROR(expr_smart_keypath_value_covert_to_contextual_type,none,
589592
"key path value type %0 cannot be converted to contextual type %1",
590593
(Type, Type))

include/swift/AST/Expr.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5035,6 +5035,10 @@ class KeyPathExpr : public Expr {
50355035
// The processed/resolved type, like Foo.Bar in \Foo.Bar.?.baz.
50365036
TypeRepr *RootType = nullptr;
50375037

5038+
/// Determines whether a key path starts with '.' which denotes necessity for
5039+
/// a contextual root type.
5040+
bool HasLeadingDot = false;
5041+
50385042
public:
50395043
/// A single stored component, which will be one of:
50405044
/// - an unresolved DeclNameRef, which has to be type-checked
@@ -5396,10 +5400,11 @@ class KeyPathExpr : public Expr {
53965400
bool isImplicit = false);
53975401

53985402
KeyPathExpr(SourceLoc backslashLoc, Expr *parsedRoot, Expr *parsedPath,
5399-
bool isImplicit = false)
5403+
bool hasLeadingDot, bool isImplicit = false)
54005404
: Expr(ExprKind::KeyPath, isImplicit), StartLoc(backslashLoc),
54015405
EndLoc(parsedPath ? parsedPath->getEndLoc() : parsedRoot->getEndLoc()),
5402-
ParsedRoot(parsedRoot), ParsedPath(parsedPath) {
5406+
ParsedRoot(parsedRoot), ParsedPath(parsedPath),
5407+
HasLeadingDot(hasLeadingDot) {
54035408
assert((parsedRoot || parsedPath) &&
54045409
"keypath must have either root or path");
54055410
Bits.KeyPathExpr.IsObjC = false;
@@ -5463,6 +5468,9 @@ class KeyPathExpr : public Expr {
54635468
/// True if this is an ObjC key path expression.
54645469
bool isObjC() const { return Bits.KeyPathExpr.IsObjC; }
54655470

5471+
/// True if this key path expression has a leading dot.
5472+
bool expectsContextualRoot() const { return HasLeadingDot; }
5473+
54665474
static bool classof(const Expr *E) {
54675475
return E->getKind() == ExprKind::KeyPath;
54685476
}

include/swift/AST/Module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ class ModuleDecl : public DeclContext, public TypeDecl {
465465
/// Retrieve the top-level module. If this module is already top-level, this
466466
/// returns itself. If this is a submodule such as \c Foo.Bar.Baz, this
467467
/// returns the module \c Foo.
468-
ModuleDecl *getTopLevelModule();
468+
ModuleDecl *getTopLevelModule(bool overlay = false);
469469

470470
bool isResilient() const {
471471
return getResilienceStrategy() != ResilienceStrategy::Default;

include/swift/ClangImporter/ClangImporter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ class ClangImporter final : public ClangModuleLoader {
330330

331331
/// Retrieves the Swift wrapper for the given Clang module, creating
332332
/// it if necessary.
333-
ModuleDecl *getWrapperForModule(const clang::Module *mod) const override;
333+
ModuleDecl *
334+
getWrapperForModule(const clang::Module *mod,
335+
bool returnOverlayIfPossible = false) const override;
334336

335337
std::string getBridgingHeaderContents(StringRef headerPath, off_t &fileSize,
336338
time_t &fileModTime);

include/swift/ClangImporter/SwiftAbstractBasicReader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef SWIFT_CLANGIMPORTER_SWIFTABSTRACTBASICREADER_H
2020
#define SWIFT_CLANGIMPORTER_SWIFTABSTRACTBASICREADER_H
2121

22+
#include "clang/AST/ASTContext.h"
2223
#include "clang/AST/AbstractTypeReader.h"
2324

2425
// This include is required to instantiate the template code in

include/swift/SILOptimizer/Utils/Differentiation/AdjointValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class AdjointValue final {
148148
std::get<1>(elt).print(s);
149149
},
150150
[&s] { s << ", "; });
151-
} else if (auto tupleType = getType().getAs<TupleType>()) {
151+
} else if (getType().is<TupleType>()) {
152152
s << "Tuple>(";
153153
interleave(
154154
base->value.aggregate,

0 commit comments

Comments
 (0)