Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0842795
[NFC] Let SynthesizedProtocolAttrs be @unchecked
beccadax Oct 21, 2021
d2d786a
[NFC] Add ClangImporter header diagnostic helper
beccadax Nov 13, 2021
1695d61
[ClangImporter] Import SwiftAttrs early
beccadax Nov 13, 2021
b9480f1
Allow imported types to add a Sendable conformance
beccadax Nov 13, 2021
21f58ec
[NFC] Attach SynthesizedFile to any FileUnit
beccadax Oct 27, 2021
8007d70
Print Sendable conformances for clang types
beccadax Oct 27, 2021
ad0e709
Make NS_ENUM &c. Sendable even when audited
beccadax Nov 12, 2021
4e383e3
Fix swift-dependency-tool dependencies
beccadax Nov 18, 2021
1880118
Restructure getDisplayDecl() Sendable forcing
beccadax Nov 19, 2021
aea5ed4
utils: update windows builders to include string processing
compnerd Nov 21, 2021
3abd7b0
Add a targetOSVersionAtLeast builtin.
devincoughlin Feb 13, 2020
2264668
tests: fix the immortal-arc-elimination.swift test
eeckstein Nov 23, 2021
61db072
cmake: fix libswift build dependencies
eeckstein Nov 22, 2021
43f6a97
[gardening] Add "&" to eliminate warning.
gottesmm Nov 24, 2021
dbf74b5
cmake: need to link swiftrt.o for libswift-executables on linux
eeckstein Nov 26, 2021
5bf4da8
SILOptimizer: avoid trawling through the directories for includes
compnerd Nov 26, 2021
6785663
SIL: support non-clang compilers again
compnerd Nov 26, 2021
3074d0a
Merge pull request #40297 from compnerd/propriety
compnerd Nov 29, 2021
e1518ea
Merge pull request #40298 from compnerd/there-cannot-be-only-one
compnerd Nov 29, 2021
07a78fd
Merge pull request #40281 from compnerd/string
compnerd Nov 29, 2021
5a1e042
Merge pull request #40267 from beccadax/send-me-an-object-recommit
beccadax Nov 29, 2021
cbf3c58
Merge pull request #40285 from eeckstein/libswift-build-fixes
eeckstein Nov 29, 2021
abaa58b
Merge pull request #40294 from gottesmm/pr-2dee32d125a4206a79e40580d3…
swift-ci Nov 29, 2021
2a9c148
Merge pull request #40286 from eeckstein/fix-immortal-arc-test
eeckstein Nov 29, 2021
f8e5d94
Merge branch 'main' of github.com:apple/swift into maxd/main-merge
MaxDesiatov Nov 29, 2021
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
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1094,9 +1094,6 @@ if(SWIFT_ENABLE_DISPATCH)
include(Libdispatch)
endif()

add_bootstrapping_target(0)
add_bootstrapping_target(1)

# Add all of the subdirectories, where we actually do work.

###############
Expand Down
4 changes: 4 additions & 0 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ function(add_libswift name)
"-parse-as-library" ${sources}
"-wmo" ${libswift_compile_options}
"-I" "${SWIFT_SOURCE_DIR}/include/swift"
"-I" "${SWIFT_SOURCE_DIR}/include"
"-I" "${build_dir}"
COMMENT "Building libswift module ${module}")

Expand Down Expand Up @@ -975,13 +976,15 @@ function(add_swift_host_tool executable)
INSTALL_RPATH "${RPATH_LIST}")

elseif(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX" AND ASHT_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE)
set(swiftrt "swiftImageRegistrationObject${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
if(LIBSWIFT_BUILD_MODE STREQUAL "HOSTTOOLS")
# At build time and and run time, link against the swift libraries in the
# installed host toolchain.
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_LIBSWIFT} DIRECTORY)
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
set(host_lib_dir "${swift_dir}/lib/swift/linux")

target_link_libraries(${executable} PRIVATE ${swiftrt})
target_link_libraries(${executable} PRIVATE "swiftCore")

target_link_directories(${executable} PRIVATE ${host_lib_dir})
Expand All @@ -995,6 +998,7 @@ function(add_swift_host_tool executable)
if (NOT "${ASHT_BOOTSTRAPPING}" STREQUAL "0")
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
target_link_libraries(${executable} PRIVATE ${swiftrt})
target_link_libraries(${executable} PRIVATE "swiftCore")
endif()

Expand Down
29 changes: 0 additions & 29 deletions cmake/modules/SwiftUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,6 @@ function(get_bootstrapping_swift_lib_dir bs_lib_dir bootstrapping)
set(bs_lib_dir ${bs_lib_dir} PARENT_SCOPE)
endfunction()

function(add_bootstrapping_target bootstrapping)
if(${LIBSWIFT_BUILD_MODE} MATCHES "BOOTSTRAPPING.*")

set(target "bootstrapping${bootstrapping}-all")
add_custom_target(${target})

if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING")
set(lib_target "bootstrapping${bootstrapping}-corelib")
add_custom_target(${lib_target})
add_dependencies(${target} ${lib_target})
endif()

if(SWIFT_PATH_TO_LIBICU_BUILD)
# Need to symlink the libicu libraries to be able to run
# the bootstrapping compiler with a custom library path.
get_bootstrapping_path(output_dir
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}" "${bootstrapping}")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
message("TODO: support for copying ICU libraries on Windows")
endif()
add_custom_command(TARGET "${target}" POST_BUILD
COMMAND
"ln" "-s" "-f" "${SWIFT_PATH_TO_LIBICU_BUILD}/lib/libicu*" "."
WORKING_DIRECTORY "${output_dir}"
COMMENT "symlink ICU libraries for bootstrapping stage ${bootstrapping}")
endif()
endif()
endfunction()

function(is_build_type_optimized build_type result_var_name)
if("${build_type}" STREQUAL "Debug")
set("${result_var_name}" FALSE PARENT_SCOPE)
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(async, Async,
106)

SIMPLE_DECL_ATTR(Sendable, Sendable,
OnFunc | OnConstructor | OnAccessor |
OnFunc | OnConstructor | OnAccessor | OnAnyClangDecl |
ABIBreakingToAdd | ABIBreakingToRemove |
APIBreakingToAdd | APIBreakingToRemove,
107)
Expand Down
25 changes: 22 additions & 3 deletions include/swift/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ class DeclAttribute : public AttributeBase {
);

SWIFT_INLINE_BITFIELD(SynthesizedProtocolAttr, DeclAttribute,
NumKnownProtocolKindBits,
kind : NumKnownProtocolKindBits
NumKnownProtocolKindBits+1,
kind : NumKnownProtocolKindBits,
isUnchecked : 1
);
} Bits;

Expand Down Expand Up @@ -288,6 +289,9 @@ class DeclAttribute : public AttributeBase {

/// Whether this attribute is only valid when distributed is enabled.
DistributedOnly = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 17),

/// Whether this attribute is valid on additional decls in ClangImporter.
OnAnyClangDecl = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 18),
};

LLVM_READNONE
Expand Down Expand Up @@ -1276,11 +1280,13 @@ class SynthesizedProtocolAttr : public DeclAttribute {

public:
SynthesizedProtocolAttr(KnownProtocolKind protocolKind,
LazyConformanceLoader *Loader)
LazyConformanceLoader *Loader,
bool isUnchecked)
: DeclAttribute(DAK_SynthesizedProtocol, SourceLoc(), SourceRange(),
/*Implicit=*/true), Loader(Loader)
{
Bits.SynthesizedProtocolAttr.kind = unsigned(protocolKind);
Bits.SynthesizedProtocolAttr.isUnchecked = unsigned(isUnchecked);
}

/// Retrieve the known protocol kind naming the protocol to be
Expand All @@ -1289,6 +1295,10 @@ class SynthesizedProtocolAttr : public DeclAttribute {
return KnownProtocolKind(Bits.SynthesizedProtocolAttr.kind);
}

bool isUnchecked() const {
return bool(Bits.SynthesizedProtocolAttr.isUnchecked);
}

/// Retrieve the lazy loader that will be used to populate the
/// synthesized conformance.
LazyConformanceLoader *getLazyLoader() const { return Loader; }
Expand Down Expand Up @@ -2217,6 +2227,15 @@ class DeclAttributes {
return nullptr;
}

/// Returns the "winning" \c NonSendableAttr or \c SendableAttr in this
/// attribute list, or \c nullptr if there are none.
const DeclAttribute *getEffectiveSendableAttr() const;

DeclAttribute *getEffectiveSendableAttr() {
return const_cast<DeclAttribute *>(
const_cast<const DeclAttributes *>(this)->getEffectiveSendableAttr());
}

private:
/// Predicate used to filter MatchingAttributeRange.
template <typename ATTR, bool AllowInvalid> struct ToAttributeKind {
Expand Down
3 changes: 3 additions & 0 deletions include/swift/AST/Builtins.def
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,9 @@ BUILTIN_MISC_OPERATION(InitializeDistributedRemoteActor,
BUILTIN_MISC_OPERATION(ResumeNonThrowingContinuationReturning,
"resumeNonThrowingContinuationReturning", "", Special)

/// targetOSVersionAtLeast has type (Builtin.Int32, Builtin.Int32, Builtin.Int32) -> Builtin.Int32
BUILTIN_MISC_OPERATION(TargetOSVersionAtLeast, "targetOSVersionAtLeast", "n", Special)

/// Resume a throwing continuation normally with the given result.
BUILTIN_MISC_OPERATION(ResumeThrowingContinuationReturning,
"resumeThrowingContinuationReturning", "", Special)
Expand Down
4 changes: 4 additions & 0 deletions include/swift/AST/DiagnosticsClangImporter.def
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ NOTE(unresolvable_clang_decl_is_a_framework_bug,none,
WARNING(clang_swift_attr_unhandled,none,
"Ignoring unknown Swift attribute or modifier '%0'", (StringRef))

WARNING(clang_error_code_must_be_sendable,none,
"cannot make error code type '%0' non-sendable because Swift errors "
"are always sendable", (StringRef))

WARNING(implicit_bridging_header_imported_from_module,none,
"implicit import of bridging header '%0' via module %1 "
"is deprecated and will be removed in a later version of Swift",
Expand Down
18 changes: 14 additions & 4 deletions include/swift/AST/FileUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#include "swift/AST/RawComment.h"
#include "swift/Basic/BasicSourceInfo.h"

#include "llvm/ADT/PointerIntPair.h"

namespace swift {
class SynthesizedFileUnit;

/// A container for module-scope declarations that itself provides a scope; the
/// smallest unit of code organization.
///
Expand All @@ -33,19 +37,25 @@ class FileUnit : public DeclContext, public ASTAllocated<FileUnit> {
friend class DirectOperatorLookupRequest;
friend class DirectPrecedenceGroupLookupRequest;

// FIXME: Stick this in a PointerIntPair.
const FileUnitKind Kind;
// The pointer is FileUnit insted of SynthesizedFileUnit to break circularity.
llvm::PointerIntPair<FileUnit *, 3, FileUnitKind> SynthesizedFileAndKind;

protected:
FileUnit(FileUnitKind kind, ModuleDecl &M)
: DeclContext(DeclContextKind::FileUnit, &M), Kind(kind) {
: DeclContext(DeclContextKind::FileUnit, &M),
SynthesizedFileAndKind(nullptr, kind) {
}

public:
FileUnitKind getKind() const {
return Kind;
return SynthesizedFileAndKind.getInt();
}

/// Returns the synthesized file for this source file, if it exists.
SynthesizedFileUnit *getSynthesizedFile() const;

SynthesizedFileUnit &getOrCreateSynthesizedFile();

/// Look up a (possibly overloaded) value set at top-level scope
/// (but with the specified access path, which may come from an import decl)
/// within this file.
Expand Down
4 changes: 3 additions & 1 deletion include/swift/AST/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,9 @@ class ModuleDecl
/// The order of the results is not guaranteed to be meaningful.
///
/// This can differ from \c getTopLevelDecls, e.g. it returns decls from a
/// shadowed clang module.
/// shadowed clang module. It does not force synthesized top-level decls that
/// should be printed to be added; use \c swift::getTopLevelDeclsForDisplay()
/// for that.
void getDisplayDecls(SmallVectorImpl<Decl*> &results) const;

using LinkLibraryCallback = llvm::function_ref<void(LinkLibrary)>;
Expand Down
5 changes: 5 additions & 0 deletions include/swift/AST/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ struct PrintOptions {
/// Whether to print unavailable parts of the AST.
bool SkipUnavailable = false;

/// Whether to print synthesized extensions created by '@_nonSendable', even
/// if SkipImplicit or SkipUnavailable is set.
bool AlwaysPrintNonSendableExtensions = true;

bool SkipSwiftPrivateClangDecls = false;

/// Whether to skip internal stdlib declarations.
Expand Down Expand Up @@ -667,6 +671,7 @@ struct PrintOptions {
PO.ShouldQualifyNestedDeclarations = QualifyNestedDeclarations::TypesOnly;
PO.PrintParameterSpecifiers = true;
PO.SkipImplicit = true;
PO.AlwaysPrintNonSendableExtensions = false;
PO.AlwaysTryPrintParameterLabels = true;
return PO;
}
Expand Down
7 changes: 7 additions & 0 deletions include/swift/AST/ProtocolConformance.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ class NormalProtocolConformance : public RootProtocolConformance,
return ContextAndBits.getInt() & UncheckedFlag;
}

/// Mark the conformance as unchecked (equivalent to the @unchecked
/// conformance attribute).
void setUnchecked() {
// OK to mutate because the flags are not part of the folding set node ID.
ContextAndBits.setInt(ContextAndBits.getInt() | UncheckedFlag);
}

/// Get the kind of source from which this conformance comes.
ConformanceEntryKind getSourceKind() const {
return SourceKindAndImplyingConformance.getInt();
Expand Down
8 changes: 0 additions & 8 deletions include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ class SourceFile final : public FileUnit {
/// same module.
mutable Identifier PrivateDiscriminator;

/// A synthesized file corresponding to this file, created on-demand.
SynthesizedFileUnit *SynthesizedFile = nullptr;

/// The root TypeRefinementContext for this SourceFile.
///
/// This is set during type checking.
Expand Down Expand Up @@ -409,11 +406,6 @@ class SourceFile final : public FileUnit {
Optional<ExternalSourceLocs::RawLocs>
getExternalRawLocsForDecl(const Decl *D) const override;

/// Returns the synthesized file for this source file, if it exists.
SynthesizedFileUnit *getSynthesizedFile() const { return SynthesizedFile; };

SynthesizedFileUnit &getOrCreateSynthesizedFile();

virtual bool walk(ASTWalker &walker) override;

/// The buffer ID for the file that was imported, or None if there
Expand Down
8 changes: 3 additions & 5 deletions include/swift/AST/SynthesizedFileUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@

namespace swift {

class SourceFile;

/// A container for synthesized declarations, attached to a `SourceFile`.
///
/// Currently, only module-level synthesized declarations are supported.
class SynthesizedFileUnit final : public FileUnit {
/// The parent source file.
SourceFile &SF;
FileUnit &FU;

/// Synthesized top level declarations.
TinyPtrVector<Decl *> TopLevelDecls;
Expand All @@ -36,11 +34,11 @@ class SynthesizedFileUnit final : public FileUnit {
mutable Identifier PrivateDiscriminator;

public:
SynthesizedFileUnit(SourceFile &SF);
SynthesizedFileUnit(FileUnit &FU);
~SynthesizedFileUnit() = default;

/// Returns the parent source file.
SourceFile &getSourceFile() const { return SF; }
FileUnit &getFileUnit() const { return FU; }

/// Add a synthesized top-level declaration.
void addTopLevelDecl(Decl *D) { TopLevelDecls.push_back(D); }
Expand Down
10 changes: 10 additions & 0 deletions include/swift/Runtime/RuntimeFunctions.def
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,16 @@ FUNCTION(TSanInoutAccess, __tsan_external_write, C_CC, AlwaysAvailable,
ATTRS(NoUnwind),
EFFECT(NoEffect))

// int32 __isPlatformVersionAtLeast(uint32_t platform, uint32_t major,
// uint32_t minor, uint32_t patch);
// This a C builtin provided by compiler-rt.
FUNCTION(PlatformVersionAtLeast, __isPlatformVersionAtLeast,
C_CC, AlwaysAvailable,
RETURNS(Int32Ty),
ARGS(Int32Ty, Int32Ty, Int32Ty, Int32Ty),
ATTRS(NoUnwind),
EFFECT(NoEffect))

FUNCTION(GetKeyPath, swift_getKeyPath, C_CC, AlwaysAvailable,
RETURNS(RefCountedPtrTy),
ARGS(Int8PtrTy, Int8PtrTy),
Expand Down
4 changes: 4 additions & 0 deletions include/swift/SIL/BridgedSwiftObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include <stdint.h>

#if !defined(__has_feature)
#define __has_feature(feature) 0
#endif

// TODO: These macro definitions are duplicated in Visibility.h. Move
// them to a single file if we find a location that both Visibility.h and
// BridgedSwiftObject.h can import.
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SILOptimizer/OptimizerBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef SWIFT_SILOPTIMIZER_OPTIMIZERBRIDGING_H
#define SWIFT_SILOPTIMIZER_OPTIMIZERBRIDGING_H

#include "../SIL/SILBridging.h"
#include "swift/SIL/SILBridging.h"

SWIFT_BEGIN_NULLABILITY_ANNOTATIONS

Expand Down
7 changes: 7 additions & 0 deletions include/swift/Sema/IDETypeChecking.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ namespace swift {
LookupResult
lookupSemanticMember(DeclContext *DC, Type ty, DeclName name);

/// Get all of the top-level declarations that should be printed as part of
/// this module. This may force synthesis of top-level declarations that
/// \c ModuleDecl::getDisplayDecls() would only return if previous
/// work happened to have synthesized them.
void
getTopLevelDeclsForDisplay(ModuleDecl *M, SmallVectorImpl<Decl*> &Results);

struct ExtensionInfo {
// The extension with the declarations to apply.
ExtensionDecl *Ext;
Expand Down
5 changes: 3 additions & 2 deletions lib/APIDigester/ModuleAnalyzerNodes.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "llvm/ADT/STLExtras.h"
#include "swift/AST/ASTMangler.h"
#include "swift/Basic/Defer.h"
#include "swift/Sema/IDETypeChecking.h"
#include "swift/SIL/SILDeclRef.h"
#include "swift/AST/ASTMangler.h"
#include <swift/APIDigester/ModuleAnalyzerNodes.h>
#include <algorithm>

Expand Down Expand Up @@ -1872,7 +1873,7 @@ void SwiftDeclCollector::printTopLevelNames() {
void SwiftDeclCollector::lookupVisibleDecls(ArrayRef<ModuleDecl *> Modules) {
for (auto M: Modules) {
llvm::SmallVector<Decl*, 512> Decls;
M->getDisplayDecls(Decls);
swift::getTopLevelDeclsForDisplay(M, Decls);
for (auto D : Decls) {
if (Ctx.shouldIgnore(D))
continue;
Expand Down
Loading