Skip to content

[pull] swiftwasm from master #1087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c6cc769
build: default the lld/gold enabling as per reality
compnerd May 1, 2020
917c937
Allow shadowing checks to deal with operator decls
hamishknight May 18, 2020
54df0a4
[Frontend] Add flag to enable new operator lookup
hamishknight May 18, 2020
912baa8
[Serialization] Use direct operator lookup for xrefs
hamishknight May 18, 2020
cc062ee
Fix precedencegroup and operator decl lookup
hamishknight May 18, 2020
e7cb6bb
[Sema] Diagnose cross-file operator redeclarations
hamishknight May 18, 2020
97c89d8
Remove three ObjC fields from non-ObjC runtime
davezarzycki May 15, 2020
f8c5803
fix typo in remove(_:)'s documentation
WowbaggersLiquidLunch May 22, 2020
2c17600
test: account for indirect imports
compnerd May 22, 2020
f9c8210
[Sema][NFC] Split test expectation to lines in `object_literals`
omochi May 22, 2020
80919e9
Sema: Don't clone TypeReprs in ConstraintSystem::shrink()
slavapestov May 23, 2020
ae77d22
AST: Don't clone TypeReprs in GenericParamList::clone()
slavapestov May 23, 2020
6303852
AST: Don't clone TypeReprs in ParamDecl::cloneWithoutType()
slavapestov May 23, 2020
98edf08
AST: Remove TypeRepr::clone()
slavapestov May 23, 2020
00485c3
This test requires ios to be build.
aschwaighofer May 23, 2020
9e2cdf4
Merge pull request #31506 from hamishknight/hello-operator
hamishknight May 23, 2020
435b239
Merge pull request #31811 from davezarzycki/pr31811
compnerd May 23, 2020
4c115e1
build: cleanup some unnecessary settings for Windows
compnerd May 23, 2020
a4d182c
Merge pull request #31987 from aschwaighofer/fix_framepointer_arm64
aschwaighofer May 23, 2020
da000dd
Merge pull request #31984 from omochi/split-line-test-expectation
omochi May 23, 2020
fb9c771
Merge pull request #31975 from WowbaggersLiquidLunch/patch-2
xwu May 23, 2020
8339e8c
[ConstraintSystem][NFC] add tests for label matching diagnostics
omochi May 23, 2020
c5730be
API checker: only diagnose adding enum cases to exhaustive enums
nkcsgexi May 23, 2020
271289f
Merge pull request #31994 from compnerd/windows-14
compnerd May 23, 2020
79bed6c
Merge pull request #31481 from compnerd/not-everything-that-glitters-…
compnerd May 23, 2020
7372a25
Foundation: fix typo in Publishers+Timer.swift (#31966)
MaxDesiatov May 23, 2020
619cdcb
Merge pull request #31992 from slavapestov/remove-typerepr-clone
slavapestov May 24, 2020
d3162e4
Merge pull request #31934 from omochi/test-labels
xedin May 24, 2020
9581918
Merge pull request #31997 from nkcsgexi/exhaustive-enum-check
nkcsgexi May 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,22 @@ set(CLANG_COMPILER_VERSION "" CACHE STRING
"The internal version of the Clang compiler")

# Indicate whether Swift should attempt to use the lld linker.
set(SWIFT_ENABLE_LLD_LINKER TRUE CACHE BOOL
if(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(SWIFT_ENABLE_LLD_LINKER_default TRUE)
else()
set(SWIFT_ENABLE_LLD_LINKER_default FALSE)
endif()
set(SWIFT_ENABLE_LLD_LINKER ${SWIFT_ENABLE_LLD_LINKER_default} CACHE BOOL
"Enable using the lld linker when available")

# Indicate whether Swift should attempt to use the gold linker.
# This is not used on Darwin.
set(SWIFT_ENABLE_GOLD_LINKER TRUE CACHE BOOL
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL Windows)
set(SWIFT_ENABLE_GOLD_LINKER_default FALSE)
else()
set(SWIFT_ENABLE_GOLD_LINKER_default TRUE)
endif()
set(SWIFT_ENABLE_GOLD_LINKER ${SWIFT_ENABLE_GOLD_LINKER_default} CACHE BOOL
"Enable using the gold linker when available")

set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
Expand Down
18 changes: 6 additions & 12 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,12 @@ function(_add_host_variant_link_flags target)
endif()

if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
# FIXME: On Apple platforms, find_program needs to look for "ld64.lld"
find_program(LDLLD_PATH "ld.lld")
if((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS AND NOT CMAKE_SYSTEM_NAME STREQUAL WINDOWS))
target_link_options(${target} PRIVATE -fuse-ld=lld)
elseif(SWIFT_ENABLE_GOLD_LINKER AND
"${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
target_link_options(${target} PRIVATE -fuse-ld=gold.exe)
else()
target_link_options(${target} PRIVATE -fuse-ld=gold)
endif()
if(SWIFT_ENABLE_LLD_LINKER)
target_link_options(${target} PRIVATE
-fuse-ld=lld$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
elseif(SWIFT_ENABLE_GOLD_LINKER)
target_link_options(${target} PRIVATE
-fuse-ld=gold$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
endif()
endif()

Expand Down
19 changes: 14 additions & 5 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,12 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {

constexpr TargetAnyClassMetadata(TargetClassMetadata<Runtime> *superclass)
: TargetHeapMetadata<Runtime>(MetadataKind::Class),
Superclass(superclass),
CacheData{nullptr, nullptr},
Data(SWIFT_CLASS_IS_SWIFT_MASK) {}
Superclass(superclass)
#if SWIFT_OBJC_INTEROP
, CacheData{nullptr, nullptr},
Data(SWIFT_CLASS_IS_SWIFT_MASK)
#endif
{}

#if SWIFT_OBJC_INTEROP
// Allow setting the metadata kind to a class ISA on class metadata.
Expand All @@ -1027,8 +1030,7 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {
/// The metadata for the superclass. This is null for the root class.
ConstTargetMetadataPointer<Runtime, swift::TargetClassMetadata> Superclass;

// TODO: remove the CacheData and Data fields in non-ObjC-interop builds.

#if SWIFT_OBJC_INTEROP
/// The cache data is used for certain dynamic lookups; it is owned
/// by the runtime and generally needs to interoperate with
/// Objective-C's use.
Expand All @@ -1043,11 +1045,16 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {
static constexpr StoredPointer offsetToData() {
return offsetof(TargetAnyClassMetadata, Data);
}
#endif

/// Is this object a valid swift type metadata? That is, can it be
/// safely downcast to ClassMetadata?
bool isTypeMetadata() const {
#if SWIFT_OBJC_INTEROP
return (Data & SWIFT_CLASS_IS_SWIFT_MASK);
#else
return true;
#endif
}
/// A different perspective on the same bit
bool isPureObjC() const {
Expand Down Expand Up @@ -1270,6 +1277,7 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
return bounds;
}

#if SWIFT_OBJC_INTEROP
/// Given a statically-emitted metadata template, this sets the correct
/// "is Swift" bit for the current runtime. Depending on the deployment
/// target a binary was compiled for, statically emitted metadata templates
Expand All @@ -1294,6 +1302,7 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {

assert(isTypeMetadata());
}
#endif

bool isCanonicalStaticallySpecializedGenericMetadata() const {
auto *description = getDescription();
Expand Down
26 changes: 8 additions & 18 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7054,6 +7054,10 @@ class PrecedenceGroupDecl : public Decl {
return Name;
}

// This is needed to allow templated code to work with both ValueDecls and
// PrecedenceGroupDecls.
DeclBaseName getBaseName() const { return Name; }

SourceLoc getLBraceLoc() const { return LBraceLoc; }
SourceLoc getRBraceLoc() const { return RBraceLoc; }

Expand Down Expand Up @@ -7211,6 +7215,10 @@ class OperatorDecl : public Decl {
SourceLoc getNameLoc() const { return NameLoc; }
Identifier getName() const { return name; }

// This is needed to allow templated code to work with both ValueDecls and
// OperatorDecls.
DeclBaseName getBaseName() const { return name; }

/// Get the list of identifiers after the colon in the operator declaration.
///
/// This list includes the names of designated types. For infix operators, the
Expand Down Expand Up @@ -7271,12 +7279,6 @@ class InfixOperatorDecl : public OperatorDecl {

PrecedenceGroupDecl *getPrecedenceGroup() const;

/// True if this decl's attributes conflict with those declared by another
/// operator.
bool conflictsWith(InfixOperatorDecl *other) {
return getPrecedenceGroup() != other->getPrecedenceGroup();
}

static bool classof(const Decl *D) {
return D->getKind() == DeclKind::InfixOperator;
}
Expand Down Expand Up @@ -7305,12 +7307,6 @@ class PrefixOperatorDecl : public OperatorDecl {
return { getOperatorLoc(), getNameLoc() };
}

/// True if this decl's attributes conflict with those declared by another
/// PrefixOperatorDecl.
bool conflictsWith(PrefixOperatorDecl *other) {
return false;
}

static bool classof(const Decl *D) {
return D->getKind() == DeclKind::PrefixOperator;
}
Expand Down Expand Up @@ -7338,12 +7334,6 @@ class PostfixOperatorDecl : public OperatorDecl {
SourceRange getSourceRange() const {
return { getOperatorLoc(), getNameLoc() };
}

/// True if this decl's attributes conflict with those declared by another
/// PostfixOperatorDecl.
bool conflictsWith(PostfixOperatorDecl *other) {
return false;
}

static bool classof(const Decl *D) {
return D->getKind() == DeclKind::PostfixOperator;
Expand Down
29 changes: 29 additions & 0 deletions include/swift/AST/DeclContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ namespace swift {
class GenericSignature;
class GenericTypeParamDecl;
class GenericTypeParamType;
class InfixOperatorDecl;
class InfixOperatorLookupResult;
class PrecedenceGroupDecl;
class ProtocolDecl;
class Requirement;
class SourceFile;
class Type;
class ModuleDecl;
class GenericTypeDecl;
class NominalTypeDecl;
class PrecedenceGroupLookupResult;
class PostfixOperatorDecl;
class PrefixOperatorDecl;
class ProtocolConformance;
class ValueDecl;
class Initializer;
Expand Down Expand Up @@ -562,6 +568,29 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
ObjCSelector selector,
SmallVectorImpl<AbstractFunctionDecl *> &results) const;

/// Looks up an infix operator with a given \p name.
///
/// This returns a vector of results, as it's possible to find multiple infix
/// operators with different precedence groups.
InfixOperatorLookupResult lookupInfixOperator(Identifier name) const;

/// Looks up an prefix operator with a given \p name.
///
/// If multiple results are found, one is chosen in a stable manner, as
/// prefix operator decls cannot differ other than in name. If no results are
/// found, returns \c nullptr.
PrefixOperatorDecl *lookupPrefixOperator(Identifier name) const;

/// Looks up an postfix operator with a given \p name.
///
/// If multiple results are found, one is chosen in a stable manner, as
/// postfix operator decls cannot differ other than in name. If no results are
/// found, returns \c nullptr.
PostfixOperatorDecl *lookupPostfixOperator(Identifier name) const;

/// Looks up a precedence group with a given \p name.
PrecedenceGroupLookupResult lookupPrecedenceGroup(Identifier name) const;

/// Return the ASTContext for a specified DeclContext by
/// walking up to the enclosing module and returning its ASTContext.
LLVM_READONLY
Expand Down
15 changes: 0 additions & 15 deletions include/swift/AST/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,21 +590,6 @@ class ModuleDecl : public DeclContext, public TypeDecl {
/// FIXME: Remove the integrated REPL.
void clearLookupCache();

/// @{

/// Look up the given operator in this module.
///
/// If the operator is not found, or if there is an ambiguity, returns null.
InfixOperatorDecl *lookupInfixOperator(Identifier name,
SourceLoc diagLoc = {});
PrefixOperatorDecl *lookupPrefixOperator(Identifier name,
SourceLoc diagLoc = {});
PostfixOperatorDecl *lookupPostfixOperator(Identifier name,
SourceLoc diagLoc = {});
PrecedenceGroupDecl *lookupPrecedenceGroup(Identifier name,
SourceLoc diagLoc = {});
/// @}

/// Finds all class members defined in this module.
///
/// This does a simple local lookup, not recursively looking through imports.
Expand Down
20 changes: 20 additions & 0 deletions include/swift/AST/NameLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,26 @@ bool removeOverriddenDecls(SmallVectorImpl<ValueDecl*> &decls);
bool removeShadowedDecls(SmallVectorImpl<ValueDecl*> &decls,
const DeclContext *dc);

/// Remove any operators in the given set that are shadowed by
/// other operators in that set.
///
/// \param decls The set of operators being considered.
/// \param dc The DeclContext from which the lookup was performed.
///
/// \returns true if any shadowed declarations were removed.
bool removeShadowedDecls(TinyPtrVector<OperatorDecl *> &decls,
const DeclContext *dc);

/// Remove any precedence groups in the given set that are shadowed by
/// other precedence groups in that set.
///
/// \param decls The set of precedence groups being considered.
/// \param dc The DeclContext from which the lookup was performed.
///
/// \returns true if any shadowed declarations were removed.
bool removeShadowedDecls(TinyPtrVector<PrecedenceGroupDecl *> &decls,
const DeclContext *dc);

/// Finds decls visible in the given context and feeds them to the given
/// VisibleDeclConsumer. If the current DeclContext is nested in a function,
/// the SourceLoc is used to determine which declarations in that function
Expand Down
Loading