Skip to content

Commit aced44a

Browse files
authored
Merge pull request #63187 from apple/rebranch
Merge `rebranch` into `main` to support `stable/20221013` llvm-project branch
2 parents b3b90a8 + 562c731 commit aced44a

File tree

127 files changed

+1290
-723
lines changed

Some content is hidden

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

127 files changed

+1290
-723
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ endif()
4646
ENABLE_LANGUAGE(C)
4747

4848
# Use C++14.
49-
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
49+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
5050
set(CMAKE_CXX_STANDARD_REQUIRED YES)
5151
set(CMAKE_CXX_EXTENSIONS NO)
5252

@@ -55,6 +55,7 @@ include(SwiftUtils)
5555
include(CheckSymbolExists)
5656
include(CMakeDependentOption)
5757
include(CheckLanguage)
58+
include(GNUInstallDirs)
5859

5960
# Enable Swift for the host compiler build if we have the language. It is
6061
# optional until we have a bootstrap story.
@@ -323,6 +324,10 @@ if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
323324
add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}")
324325
endif()
325326

327+
set(SWIFT_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
328+
"Path for binary subdirectory to use during installation.
329+
Used by add_swift_tool_symlink in AddSwift.cmake so that llvm_install_symlink generates the installation script properly.")
330+
326331
#
327332
# User-configurable Swift Standard Library specific options.
328333
#

SwiftCompilerSources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ function(add_swift_compiler_modules_library name)
7575
set(swift_compile_options
7676
"-Xfrontend" "-validate-tbd-against-ir=none"
7777
"-Xfrontend" "-enable-experimental-cxx-interop"
78+
"-Xcc" "-std=c++17"
7879
"-Xcc" "-UIBOutlet" "-Xcc" "-UIBAction" "-Xcc" "-UIBInspectable")
7980
if (NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
8081
list(APPEND swift_compile_options "-Xfrontend" "-disable-implicit-string-processing-module-import")

cmake/modules/AddSwift.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,8 @@ function(add_swift_fuzzer_host_tool executable)
976976
endfunction()
977977

978978
macro(add_swift_tool_symlink name dest component)
979-
add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
980-
llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE COMPONENT ${component})
979+
llvm_add_tool_symlink(SWIFT ${name} ${dest} ALWAYS_GENERATE)
980+
llvm_install_symlink(SWIFT ${name} ${dest} ALWAYS_GENERATE COMPONENT ${component})
981981
endmacro()
982982

983983
# Declare that files in this library are built with LLVM's support

include/swift/AST/DeclContext.h

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext
254254
friend class AbstractClosureExpr; // uses setParent
255255

256256
template<class A, class B, class C>
257-
friend struct ::llvm::cast_convert_val;
257+
friend struct ::llvm::CastInfo;
258258

259259
// See swift/AST/Decl.h
260260
static DeclContext *castDeclToDeclContext(const Decl *D);
@@ -787,7 +787,7 @@ class IterableDeclContext {
787787
unsigned HasNestedClassDeclarations : 1;
788788

789789
template<class A, class B, class C>
790-
friend struct ::llvm::cast_convert_val;
790+
friend struct ::llvm::CastInfo;
791791

792792
static IterableDeclContext *castDeclToIterableDeclContext(const Decl *D);
793793

@@ -977,16 +977,26 @@ SourceLoc extractNearestSourceLoc(const IterableDeclContext *idc);
977977

978978
namespace llvm {
979979
template<class FromTy>
980-
struct cast_convert_val< ::swift::DeclContext, FromTy, FromTy> {
981-
static ::swift::DeclContext *doit(const FromTy &Val) {
982-
return ::swift::DeclContext::castDeclToDeclContext(Val);
980+
struct CastInfo<::swift::DeclContext, FromTy, std::enable_if_t<is_simple_type<FromTy>::value>>
981+
: public CastIsPossible<::swift::DeclContext, FromTy>,
982+
public DefaultDoCastIfPossible<::swift::DeclContext *, FromTy,
983+
CastInfo<::swift::DeclContext, FromTy>> {
984+
static inline ::swift::DeclContext *castFailed() { return nullptr; }
985+
986+
static inline ::swift::DeclContext *doCast(const FromTy &val) {
987+
return ::swift::DeclContext::castDeclToDeclContext(val);
983988
}
984989
};
985990

986991
template<class FromTy>
987-
struct cast_convert_val< ::swift::IterableDeclContext, FromTy, FromTy> {
988-
static ::swift::IterableDeclContext *doit(const FromTy &Val) {
989-
return ::swift::IterableDeclContext::castDeclToIterableDeclContext(Val);
992+
struct CastInfo<::swift::IterableDeclContext, FromTy, std::enable_if_t<is_simple_type<FromTy>::value>>
993+
: public CastIsPossible<::swift::IterableDeclContext, FromTy>,
994+
public DefaultDoCastIfPossible<::swift::IterableDeclContext *, FromTy,
995+
CastInfo<::swift::IterableDeclContext, FromTy>> {
996+
static inline ::swift::IterableDeclContext *castFailed() { return nullptr; }
997+
998+
static inline ::swift::IterableDeclContext *doCast(const FromTy &val) {
999+
return ::swift::IterableDeclContext::castDeclToIterableDeclContext(val);
9901000
}
9911001
};
9921002
}

include/swift/AST/ExtInfo.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -412,46 +412,46 @@ class ASTExtInfoBuilder {
412412

413413
// Note that we don't have setters. That is by design, use
414414
// the following with methods instead of mutating these objects.
415-
LLVM_NODISCARD
415+
[[nodiscard]]
416416
ASTExtInfoBuilder withRepresentation(Representation rep) const {
417417
return ASTExtInfoBuilder((bits & ~RepresentationMask) | (unsigned)rep,
418418
shouldStoreClangType(rep) ? clangTypeInfo
419419
: ClangTypeInfo(),
420420
globalActor);
421421
}
422-
LLVM_NODISCARD
422+
[[nodiscard]]
423423
ASTExtInfoBuilder withNoEscape(bool noEscape = true) const {
424424
return ASTExtInfoBuilder(noEscape ? (bits | NoEscapeMask)
425425
: (bits & ~NoEscapeMask),
426426
clangTypeInfo, globalActor);
427427
}
428-
LLVM_NODISCARD
428+
[[nodiscard]]
429429
ASTExtInfoBuilder withConcurrent(bool concurrent = true) const {
430430
return ASTExtInfoBuilder(concurrent ? (bits | SendableMask)
431431
: (bits & ~SendableMask),
432432
clangTypeInfo, globalActor);
433433
}
434-
LLVM_NODISCARD
434+
[[nodiscard]]
435435
ASTExtInfoBuilder withAsync(bool async = true) const {
436436
return ASTExtInfoBuilder(async ? (bits | AsyncMask)
437437
: (bits & ~AsyncMask),
438438
clangTypeInfo, globalActor);
439439
}
440-
LLVM_NODISCARD
440+
[[nodiscard]]
441441
ASTExtInfoBuilder withThrows(bool throws = true) const {
442442
return ASTExtInfoBuilder(
443443
throws ? (bits | ThrowsMask) : (bits & ~ThrowsMask), clangTypeInfo,
444444
globalActor);
445445
}
446-
LLVM_NODISCARD
446+
[[nodiscard]]
447447
ASTExtInfoBuilder
448448
withDifferentiabilityKind(DifferentiabilityKind differentiability) const {
449449
return ASTExtInfoBuilder(
450450
(bits & ~DifferentiabilityMask) |
451451
((unsigned)differentiability << DifferentiabilityMaskOffset),
452452
clangTypeInfo, globalActor);
453453
}
454-
LLVM_NODISCARD
454+
[[nodiscard]]
455455
ASTExtInfoBuilder withClangFunctionType(const clang::Type *type) const {
456456
return ASTExtInfoBuilder(bits, ClangTypeInfo(type), globalActor);
457457
}
@@ -461,7 +461,7 @@ class ASTExtInfoBuilder {
461461
/// SIL type lowering transiently generates AST function types with SIL
462462
/// representations. However, they shouldn't persist in the AST, and
463463
/// don't need to be parsed, printed, or serialized.
464-
LLVM_NODISCARD
464+
[[nodiscard]]
465465
ASTExtInfoBuilder
466466
withSILRepresentation(SILFunctionTypeRepresentation rep) const {
467467
return ASTExtInfoBuilder((bits & ~RepresentationMask) | (unsigned)rep,
@@ -470,7 +470,7 @@ class ASTExtInfoBuilder {
470470
globalActor);
471471
}
472472

473-
LLVM_NODISCARD
473+
[[nodiscard]]
474474
ASTExtInfoBuilder withGlobalActor(Type globalActor) const {
475475
return ASTExtInfoBuilder(bits, clangTypeInfo, globalActor);
476476
}
@@ -555,44 +555,44 @@ class ASTExtInfo {
555555
/// Helper method for changing the representation.
556556
///
557557
/// Prefer using \c ASTExtInfoBuilder::withRepresentation for chaining.
558-
LLVM_NODISCARD
558+
[[nodiscard]]
559559
ASTExtInfo withRepresentation(ASTExtInfoBuilder::Representation rep) const {
560560
return builder.withRepresentation(rep).build();
561561
}
562562

563563
/// Helper method for changing only the noEscape field.
564564
///
565565
/// Prefer using \c ASTExtInfoBuilder::withNoEscape for chaining.
566-
LLVM_NODISCARD
566+
[[nodiscard]]
567567
ASTExtInfo withNoEscape(bool noEscape = true) const {
568568
return builder.withNoEscape(noEscape).build();
569569
}
570570

571571
/// Helper method for changing only the concurrent field.
572572
///
573573
/// Prefer using \c ASTExtInfoBuilder::withConcurrent for chaining.
574-
LLVM_NODISCARD
574+
[[nodiscard]]
575575
ASTExtInfo withConcurrent(bool concurrent = true) const {
576576
return builder.withConcurrent(concurrent).build();
577577
}
578578

579579
/// Helper method for changing only the throws field.
580580
///
581581
/// Prefer using \c ASTExtInfoBuilder::withThrows for chaining.
582-
LLVM_NODISCARD
582+
[[nodiscard]]
583583
ASTExtInfo withThrows(bool throws = true) const {
584584
return builder.withThrows(throws).build();
585585
}
586586

587587
/// Helper method for changing only the async field.
588588
///
589589
/// Prefer using \c ASTExtInfoBuilder::withAsync for chaining.
590-
LLVM_NODISCARD
590+
[[nodiscard]]
591591
ASTExtInfo withAsync(bool async = true) const {
592592
return builder.withAsync(async).build();
593593
}
594594

595-
LLVM_NODISCARD
595+
[[nodiscard]]
596596
ASTExtInfo withGlobalActor(Type globalActor) const {
597597
return builder.withGlobalActor(globalActor).build();
598598
}
@@ -785,44 +785,44 @@ class SILExtInfoBuilder {
785785

786786
// Note that we don't have setters. That is by design, use
787787
// the following with methods instead of mutating these objects.
788-
LLVM_NODISCARD
788+
[[nodiscard]]
789789
SILExtInfoBuilder withRepresentation(Representation rep) const {
790790
return SILExtInfoBuilder((bits & ~RepresentationMask) | (unsigned)rep,
791791
shouldStoreClangType(rep) ? clangTypeInfo
792792
: ClangTypeInfo());
793793
}
794-
LLVM_NODISCARD
794+
[[nodiscard]]
795795
SILExtInfoBuilder withIsPseudogeneric(bool isPseudogeneric = true) const {
796796
return SILExtInfoBuilder(isPseudogeneric ? (bits | PseudogenericMask)
797797
: (bits & ~PseudogenericMask),
798798
clangTypeInfo);
799799
}
800-
LLVM_NODISCARD
800+
[[nodiscard]]
801801
SILExtInfoBuilder withNoEscape(bool noEscape = true) const {
802802
return SILExtInfoBuilder(noEscape ? (bits | NoEscapeMask)
803803
: (bits & ~NoEscapeMask),
804804
clangTypeInfo);
805805
}
806-
LLVM_NODISCARD
806+
[[nodiscard]]
807807
SILExtInfoBuilder withConcurrent(bool isSendable = true) const {
808808
return SILExtInfoBuilder(isSendable ? (bits | SendableMask)
809809
: (bits & ~SendableMask),
810810
clangTypeInfo);
811811
}
812-
LLVM_NODISCARD
812+
[[nodiscard]]
813813
SILExtInfoBuilder withAsync(bool isAsync = true) const {
814814
return SILExtInfoBuilder(isAsync ? (bits | AsyncMask) : (bits & ~AsyncMask),
815815
clangTypeInfo);
816816
}
817-
LLVM_NODISCARD
817+
[[nodiscard]]
818818
SILExtInfoBuilder
819819
withDifferentiabilityKind(DifferentiabilityKind differentiability) const {
820820
return SILExtInfoBuilder(
821821
(bits & ~DifferentiabilityMask) |
822822
((unsigned)differentiability << DifferentiabilityMaskOffset),
823823
clangTypeInfo);
824824
}
825-
LLVM_NODISCARD
825+
[[nodiscard]]
826826
SILExtInfoBuilder withClangFunctionType(const clang::Type *type) const {
827827
return SILExtInfoBuilder(bits, ClangTypeInfo(type).getCanonical());
828828
}

include/swift/AST/IRGenOptions.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,6 @@ class IRGenOptions {
252252
/// well-formed?
253253
unsigned Verify : 1;
254254

255-
/// Should we use the legacy pass manager.
256-
unsigned LegacyPassManager : 1;
257-
258255
OptimizationMode OptMode;
259256

260257
/// Which sanitizer is turned on.
@@ -474,7 +471,7 @@ class IRGenOptions {
474471
IRGenOptions()
475472
: DWARFVersion(2),
476473
OutputKind(IRGenOutputKind::LLVMAssemblyAfterOptimization),
477-
Verify(true), LegacyPassManager(0), OptMode(OptimizationMode::NotSet),
474+
Verify(true), OptMode(OptimizationMode::NotSet),
478475
Sanitizers(OptionSet<SanitizerKind>()),
479476
SanitizersWithRecoveryInstrumentation(OptionSet<SanitizerKind>()),
480477
SanitizeAddressUseODRIndicator(false),

include/swift/AST/IRGenRequests.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ struct IRGenDescriptor {
150150
StringRef PrivateDiscriminator;
151151
ArrayRef<std::string> parallelOutputFilenames;
152152
llvm::GlobalVariable **outModuleHash;
153+
llvm::raw_pwrite_stream *out = nullptr;
153154

154155
friend llvm::hash_code hash_value(const IRGenDescriptor &owner) {
155156
return llvm::hash_combine(owner.Ctx, owner.SymbolsToEmit, owner.SILMod);

include/swift/Basic/BasicBridging.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#ifndef SWIFT_BASIC_BASICBRIDGING_H
1414
#define SWIFT_BASIC_BASICBRIDGING_H
1515

16+
// Workaround to avoid a compiler error because `cas::ObjectRef` is not defined
17+
// when including VirtualFileSystem.h
18+
#include "llvm/CAS/CASReference.h"
19+
1620
#include "swift/Basic/BridgedSwiftObject.h"
1721
#include "swift/Basic/SourceLoc.h"
1822
#include <stddef.h>

include/swift/Basic/RelativePointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ class RelativeDirectPointer<T, Nullable, Offset,
551551
}
552552

553553
template <typename... ArgTy>
554-
typename std::result_of<T *(ArgTy...)>::type operator()(ArgTy... arg) const {
554+
typename std::invoke_result<T*, ArgTy...>::type operator()(ArgTy... arg) const {
555555
#if SWIFT_PTRAUTH
556556
void *ptr = this->super::getWithoutCast();
557557
return reinterpret_cast<T *>(ptrauth_sign_unauthenticated(

include/swift/Basic/STLExtras.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class OptionalTransformIterator {
405405
typename std::iterator_traits<Iterator>::reference;
406406

407407
using ResultReference =
408-
typename std::result_of<OptionalTransform(UnderlyingReference)>::type;
408+
typename std::invoke_result<OptionalTransform, UnderlyingReference>::type;
409409

410410
public:
411411
/// Used to indicate when the current iterator has already been

0 commit comments

Comments
 (0)