Skip to content

Commit 6447f71

Browse files
authored
Merge pull request #1087 from swiftwasm/master
[pull] swiftwasm from master
2 parents 4ccc04f + 9581918 commit 6447f71

File tree

76 files changed

+1400
-862
lines changed

Some content is hidden

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

76 files changed

+1400
-862
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,22 @@ set(CLANG_COMPILER_VERSION "" CACHE STRING
148148
"The internal version of the Clang compiler")
149149

150150
# Indicate whether Swift should attempt to use the lld linker.
151-
set(SWIFT_ENABLE_LLD_LINKER TRUE CACHE BOOL
151+
if(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
152+
set(SWIFT_ENABLE_LLD_LINKER_default TRUE)
153+
else()
154+
set(SWIFT_ENABLE_LLD_LINKER_default FALSE)
155+
endif()
156+
set(SWIFT_ENABLE_LLD_LINKER ${SWIFT_ENABLE_LLD_LINKER_default} CACHE BOOL
152157
"Enable using the lld linker when available")
153158

154159
# Indicate whether Swift should attempt to use the gold linker.
155160
# This is not used on Darwin.
156-
set(SWIFT_ENABLE_GOLD_LINKER TRUE CACHE BOOL
161+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL Windows)
162+
set(SWIFT_ENABLE_GOLD_LINKER_default FALSE)
163+
else()
164+
set(SWIFT_ENABLE_GOLD_LINKER_default TRUE)
165+
endif()
166+
set(SWIFT_ENABLE_GOLD_LINKER ${SWIFT_ENABLE_GOLD_LINKER_default} CACHE BOOL
157167
"Enable using the gold linker when available")
158168

159169
set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One

cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,12 @@ function(_add_host_variant_link_flags target)
370370
endif()
371371

372372
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
373-
# FIXME: On Apple platforms, find_program needs to look for "ld64.lld"
374-
find_program(LDLLD_PATH "ld.lld")
375-
if((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
376-
(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS AND NOT CMAKE_SYSTEM_NAME STREQUAL WINDOWS))
377-
target_link_options(${target} PRIVATE -fuse-ld=lld)
378-
elseif(SWIFT_ENABLE_GOLD_LINKER AND
379-
"${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
380-
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
381-
target_link_options(${target} PRIVATE -fuse-ld=gold.exe)
382-
else()
383-
target_link_options(${target} PRIVATE -fuse-ld=gold)
384-
endif()
373+
if(SWIFT_ENABLE_LLD_LINKER)
374+
target_link_options(${target} PRIVATE
375+
-fuse-ld=lld$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
376+
elseif(SWIFT_ENABLE_GOLD_LINKER)
377+
target_link_options(${target} PRIVATE
378+
-fuse-ld=gold$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
385379
endif()
386380
endif()
387381

include/swift/ABI/Metadata.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,12 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {
10121012

10131013
constexpr TargetAnyClassMetadata(TargetClassMetadata<Runtime> *superclass)
10141014
: TargetHeapMetadata<Runtime>(MetadataKind::Class),
1015-
Superclass(superclass),
1016-
CacheData{nullptr, nullptr},
1017-
Data(SWIFT_CLASS_IS_SWIFT_MASK) {}
1015+
Superclass(superclass)
1016+
#if SWIFT_OBJC_INTEROP
1017+
, CacheData{nullptr, nullptr},
1018+
Data(SWIFT_CLASS_IS_SWIFT_MASK)
1019+
#endif
1020+
{}
10181021

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

1030-
// TODO: remove the CacheData and Data fields in non-ObjC-interop builds.
1031-
1033+
#if SWIFT_OBJC_INTEROP
10321034
/// The cache data is used for certain dynamic lookups; it is owned
10331035
/// by the runtime and generally needs to interoperate with
10341036
/// Objective-C's use.
@@ -1043,11 +1045,16 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {
10431045
static constexpr StoredPointer offsetToData() {
10441046
return offsetof(TargetAnyClassMetadata, Data);
10451047
}
1048+
#endif
10461049

10471050
/// Is this object a valid swift type metadata? That is, can it be
10481051
/// safely downcast to ClassMetadata?
10491052
bool isTypeMetadata() const {
1053+
#if SWIFT_OBJC_INTEROP
10501054
return (Data & SWIFT_CLASS_IS_SWIFT_MASK);
1055+
#else
1056+
return true;
1057+
#endif
10511058
}
10521059
/// A different perspective on the same bit
10531060
bool isPureObjC() const {
@@ -1270,6 +1277,7 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
12701277
return bounds;
12711278
}
12721279

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

12951303
assert(isTypeMetadata());
12961304
}
1305+
#endif
12971306

12981307
bool isCanonicalStaticallySpecializedGenericMetadata() const {
12991308
auto *description = getDescription();

include/swift/AST/Decl.h

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7054,6 +7054,10 @@ class PrecedenceGroupDecl : public Decl {
70547054
return Name;
70557055
}
70567056

7057+
// This is needed to allow templated code to work with both ValueDecls and
7058+
// PrecedenceGroupDecls.
7059+
DeclBaseName getBaseName() const { return Name; }
7060+
70577061
SourceLoc getLBraceLoc() const { return LBraceLoc; }
70587062
SourceLoc getRBraceLoc() const { return RBraceLoc; }
70597063

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

7218+
// This is needed to allow templated code to work with both ValueDecls and
7219+
// OperatorDecls.
7220+
DeclBaseName getBaseName() const { return name; }
7221+
72147222
/// Get the list of identifiers after the colon in the operator declaration.
72157223
///
72167224
/// This list includes the names of designated types. For infix operators, the
@@ -7271,12 +7279,6 @@ class InfixOperatorDecl : public OperatorDecl {
72717279

72727280
PrecedenceGroupDecl *getPrecedenceGroup() const;
72737281

7274-
/// True if this decl's attributes conflict with those declared by another
7275-
/// operator.
7276-
bool conflictsWith(InfixOperatorDecl *other) {
7277-
return getPrecedenceGroup() != other->getPrecedenceGroup();
7278-
}
7279-
72807282
static bool classof(const Decl *D) {
72817283
return D->getKind() == DeclKind::InfixOperator;
72827284
}
@@ -7305,12 +7307,6 @@ class PrefixOperatorDecl : public OperatorDecl {
73057307
return { getOperatorLoc(), getNameLoc() };
73067308
}
73077309

7308-
/// True if this decl's attributes conflict with those declared by another
7309-
/// PrefixOperatorDecl.
7310-
bool conflictsWith(PrefixOperatorDecl *other) {
7311-
return false;
7312-
}
7313-
73147310
static bool classof(const Decl *D) {
73157311
return D->getKind() == DeclKind::PrefixOperator;
73167312
}
@@ -7338,12 +7334,6 @@ class PostfixOperatorDecl : public OperatorDecl {
73387334
SourceRange getSourceRange() const {
73397335
return { getOperatorLoc(), getNameLoc() };
73407336
}
7341-
7342-
/// True if this decl's attributes conflict with those declared by another
7343-
/// PostfixOperatorDecl.
7344-
bool conflictsWith(PostfixOperatorDecl *other) {
7345-
return false;
7346-
}
73477337

73487338
static bool classof(const Decl *D) {
73497339
return D->getKind() == DeclKind::PostfixOperator;

include/swift/AST/DeclContext.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,19 @@ namespace swift {
5555
class GenericSignature;
5656
class GenericTypeParamDecl;
5757
class GenericTypeParamType;
58+
class InfixOperatorDecl;
59+
class InfixOperatorLookupResult;
60+
class PrecedenceGroupDecl;
5861
class ProtocolDecl;
5962
class Requirement;
6063
class SourceFile;
6164
class Type;
6265
class ModuleDecl;
6366
class GenericTypeDecl;
6467
class NominalTypeDecl;
68+
class PrecedenceGroupLookupResult;
69+
class PostfixOperatorDecl;
70+
class PrefixOperatorDecl;
6571
class ProtocolConformance;
6672
class ValueDecl;
6773
class Initializer;
@@ -562,6 +568,29 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
562568
ObjCSelector selector,
563569
SmallVectorImpl<AbstractFunctionDecl *> &results) const;
564570

571+
/// Looks up an infix operator with a given \p name.
572+
///
573+
/// This returns a vector of results, as it's possible to find multiple infix
574+
/// operators with different precedence groups.
575+
InfixOperatorLookupResult lookupInfixOperator(Identifier name) const;
576+
577+
/// Looks up an prefix operator with a given \p name.
578+
///
579+
/// If multiple results are found, one is chosen in a stable manner, as
580+
/// prefix operator decls cannot differ other than in name. If no results are
581+
/// found, returns \c nullptr.
582+
PrefixOperatorDecl *lookupPrefixOperator(Identifier name) const;
583+
584+
/// Looks up an postfix operator with a given \p name.
585+
///
586+
/// If multiple results are found, one is chosen in a stable manner, as
587+
/// postfix operator decls cannot differ other than in name. If no results are
588+
/// found, returns \c nullptr.
589+
PostfixOperatorDecl *lookupPostfixOperator(Identifier name) const;
590+
591+
/// Looks up a precedence group with a given \p name.
592+
PrecedenceGroupLookupResult lookupPrecedenceGroup(Identifier name) const;
593+
565594
/// Return the ASTContext for a specified DeclContext by
566595
/// walking up to the enclosing module and returning its ASTContext.
567596
LLVM_READONLY

include/swift/AST/Module.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -590,21 +590,6 @@ class ModuleDecl : public DeclContext, public TypeDecl {
590590
/// FIXME: Remove the integrated REPL.
591591
void clearLookupCache();
592592

593-
/// @{
594-
595-
/// Look up the given operator in this module.
596-
///
597-
/// If the operator is not found, or if there is an ambiguity, returns null.
598-
InfixOperatorDecl *lookupInfixOperator(Identifier name,
599-
SourceLoc diagLoc = {});
600-
PrefixOperatorDecl *lookupPrefixOperator(Identifier name,
601-
SourceLoc diagLoc = {});
602-
PostfixOperatorDecl *lookupPostfixOperator(Identifier name,
603-
SourceLoc diagLoc = {});
604-
PrecedenceGroupDecl *lookupPrecedenceGroup(Identifier name,
605-
SourceLoc diagLoc = {});
606-
/// @}
607-
608593
/// Finds all class members defined in this module.
609594
///
610595
/// This does a simple local lookup, not recursively looking through imports.

include/swift/AST/NameLookup.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,26 @@ bool removeOverriddenDecls(SmallVectorImpl<ValueDecl*> &decls);
455455
bool removeShadowedDecls(SmallVectorImpl<ValueDecl*> &decls,
456456
const DeclContext *dc);
457457

458+
/// Remove any operators in the given set that are shadowed by
459+
/// other operators in that set.
460+
///
461+
/// \param decls The set of operators being considered.
462+
/// \param dc The DeclContext from which the lookup was performed.
463+
///
464+
/// \returns true if any shadowed declarations were removed.
465+
bool removeShadowedDecls(TinyPtrVector<OperatorDecl *> &decls,
466+
const DeclContext *dc);
467+
468+
/// Remove any precedence groups in the given set that are shadowed by
469+
/// other precedence groups in that set.
470+
///
471+
/// \param decls The set of precedence groups being considered.
472+
/// \param dc The DeclContext from which the lookup was performed.
473+
///
474+
/// \returns true if any shadowed declarations were removed.
475+
bool removeShadowedDecls(TinyPtrVector<PrecedenceGroupDecl *> &decls,
476+
const DeclContext *dc);
477+
458478
/// Finds decls visible in the given context and feeds them to the given
459479
/// VisibleDeclConsumer. If the current DeclContext is nested in a function,
460480
/// the SourceLoc is used to determine which declarations in that function

0 commit comments

Comments
 (0)