Skip to content

Commit d790477

Browse files
authored
Merge branch 'main' into name-lookup-filtering-expanded-top-level
2 parents 8e63bf1 + e355fd8 commit d790477

Some content is hidden

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

45 files changed

+310
-112
lines changed

docs/CppInteroperability/GettingStartedWithC++Interop.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module CxxTest {
3232
Add the C++ module to the include path and enable C++ interop:
3333
- Navigate to your project directory
3434
- In `Project` navigate to `Build Settings` -> `Swift Compiler`
35-
- Under `Custom Flags` -> `Other Swift Flags` add `-cxx-interoperability-mode=swift-5.9`
35+
- Under `Custom Flags` -> `Other Swift Flags` add `-cxx-interoperability-mode=default`
3636
- Under `Search Paths` -> `Import Paths` add your search path to the C++ module (i.e, `./ProjectName/CxxTest`).
3737

3838
- This should now allow your to import your C++ Module into any `.swift` file.
@@ -81,7 +81,7 @@ After creating your Swift package project, follow the steps [Creating a Module t
8181
- Swift code will be in `Sources/CxxInterop` called `main.swift`
8282
- C++ source code follows the example shown in [Creating a Module to contain your C++ source code](#creating-a-module-to-contain-your-c-source-code)
8383
- Under targets, add the name of your C++ module and the directory containing the Swift code as a target.
84-
- In the target defining your Swift target, add a`dependencies` to the C++ Module, the `path`, `source`, and `swiftSettings` with `unsafeFlags` with the source to the C++ Module, and enable `-cxx-interoperability-mode=swift-5.9`
84+
- In the target defining your Swift target, add a`dependencies` to the C++ Module, the `path`, `source`, and `swiftSettings` with `unsafeFlags` with the source to the C++ Module, and enable `-cxx-interoperability-mode=default`
8585

8686
```
8787
//In Package Manifest
@@ -111,7 +111,7 @@ let package = Package(
111111
sources: [ "main.swift" ],
112112
swiftSettings: [.unsafeFlags([
113113
"-I", "Sources/CxxTest",
114-
"-cxx-interoperability-mode=swift-5.9",
114+
"-cxx-interoperability-mode=default",
115115
])]
116116
),
117117
]
@@ -144,7 +144,7 @@ After creating your project follow the steps [Creating a Module to contain your
144144
- Create a `CMakeLists.txt` file and configure for your project
145145
- In`add_library` invoke `cxx-support` with the path to the C++ implementation file
146146
- Add the `target_include_directories` with `cxx-support` and path to the C++ Module `${CMAKE_SOURCE_DIR}/Sources/CxxTest`
147-
- Add the `add_executable` to the specific files/directory you would like to generate source, with`SHELL:-cxx-interoperability-mode=swift-5.9`.
147+
- Add the `add_executable` to the specific files/directory you would like to generate source, with`SHELL:-cxx-interoperability-mode=default`.
148148
- In the example below we will be following the file structure used in [Creating a Swift Package](#Creating-a-Swift-Package)
149149

150150
```
@@ -167,7 +167,7 @@ target_include_directories(cxx-support PUBLIC
167167
168168
add_executable(CxxInterop ./Sources/CxxInterop/main.swift)
169169
target_compile_options(CxxInterop PRIVATE
170-
"SHELL:-cxx-interoperability-mode=swift-5.9"
170+
"SHELL:-cxx-interoperability-mode=default"
171171
target_link_libraries(CxxInterop PRIVATE cxx-support)
172172
173173
```

include/swift/AST/ASTContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "swift/Basic/LangOptions.h"
3131
#include "swift/Basic/Located.h"
3232
#include "swift/Basic/Malloc.h"
33+
#include "swift/Basic/BlockList.h"
3334
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"
3435
#include "clang/AST/DeclTemplate.h"
3536
#include "llvm/ADT/ArrayRef.h"
@@ -365,6 +366,8 @@ class ASTContext final {
365366
/// The Swift module currently being compiled.
366367
ModuleDecl *MainModule = nullptr;
367368

369+
/// The block list where we can find special actions based on module name;
370+
BlockListStore blockListConfig;
368371
private:
369372
/// The current generation number, which reflects the number of
370373
/// times that external modules have been loaded.

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,9 @@ WARNING(compiler_plugin_not_loaded,none,
524524
ERROR(dont_enable_interop_and_compat,none,
525525
"do not pass both -enable-experimental-cxx-interop and "
526526
"-cxx-interoperability-mode. Remove -enable-experimental-cxx-interop.", ())
527-
528-
ERROR(invalid_interop_compat_mode,none,
529-
"invalid option passed to -cxx-interoperability-mode. Please select either "
530-
"'off' or 'swift-5.9'.", ())
527+
528+
NOTE(valid_cxx_interop_modes,none,
529+
"valid arguments to '-cxx-interoperability-mode=' are %0", (StringRef))
531530
NOTE(swift_will_maintain_compat,none,
532531
"Swift will maintain source compatibility for imported APIs based on the "
533532
"selected compatibility mode, so updating the Swift compiler will not "

include/swift/Basic/BlockList.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//===--- BlockList.h ---------------------------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines some miscellaneous overloads of hash_value() and
14+
// simple_display().
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef SWIFT_BASIC_BLOCKLIST_H
19+
#define SWIFT_BASIC_BLOCKLIST_H
20+
21+
#include "swift/Basic/LLVM.h"
22+
#include "llvm/ADT/StringRef.h"
23+
24+
namespace swift {
25+
26+
enum class BlockListAction: uint8_t {
27+
ShouldUseBinaryModule = 0,
28+
ShouldUseTextualModule,
29+
};
30+
31+
enum class BlockListKeyKind: uint8_t {
32+
ModuleName,
33+
ProjectName
34+
};
35+
36+
class BlockListStore {
37+
public:
38+
struct Implementation;
39+
bool hasBlockListAction(StringRef key, BlockListKeyKind keyKind,
40+
BlockListAction action);
41+
BlockListStore();
42+
~BlockListStore();
43+
private:
44+
friend class ASTContext;
45+
void addConfigureFilePath(StringRef path);
46+
Implementation &Impl;
47+
};
48+
49+
} // namespace swift
50+
51+
#endif // SWIFT_BASIC_BLOCKLIST_H

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ namespace swift {
556556
/// The model of concurrency to be used.
557557
ConcurrencyModel ActiveConcurrencyModel = ConcurrencyModel::Standard;
558558

559+
/// All block list configuration files to be honored in this compilation.
560+
std::vector<std::string> BlocklistConfigFilePath;
561+
559562
bool isConcurrencyModelTaskToThread() const {
560563
return ActiveConcurrencyModel == ConcurrencyModel::TaskToThread;
561564
}

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ def Raccess_note : Separate<["-"], "Raccess-note">,
240240
def Raccess_note_EQ : Joined<["-"], "Raccess-note=">,
241241
Alias<Raccess_note>;
242242

243+
def block_list_file
244+
: Separate<["-"], "blocklist-file">, MetaVarName<"<path>">,
245+
HelpText<"The path to a blocklist configuration file">;
243246
} // end let Flags = [FrontendOption, NoDriverOption]
244247

245248
def debug_crash_Group : OptionGroup<"<automatic crashing options>">;

include/swift/SIL/TypeLowering.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,14 +1260,16 @@ class TypeConverter {
12601260
/// Check the result of
12611261
/// getTypeLowering(AbstractionPattern,Type,TypeExpansionContext).
12621262
void verifyLowering(const TypeLowering &, AbstractionPattern origType,
1263-
Type origSubstType, TypeExpansionContext forExpansion);
1263+
CanType origSubstType,
1264+
TypeExpansionContext forExpansion);
12641265
bool
1265-
visitAggregateLeaves(Lowering::AbstractionPattern origType, Type substType,
1266+
visitAggregateLeaves(Lowering::AbstractionPattern origType,
1267+
CanType substType,
12661268
TypeExpansionContext context,
1267-
std::function<bool(Type, Lowering::AbstractionPattern,
1269+
std::function<bool(CanType, Lowering::AbstractionPattern,
12681270
ValueDecl *, Optional<unsigned>)>
12691271
isLeafAggregate,
1270-
std::function<bool(Type, Lowering::AbstractionPattern,
1272+
std::function<bool(CanType, Lowering::AbstractionPattern,
12711273
ValueDecl *, Optional<unsigned>)>
12721274
visit);
12731275
#endif

lib/AST/ASTContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,14 @@ ASTContext::ASTContext(
713713
registerNameLookupRequestFunctions(evaluator);
714714

715715
createModuleToExecutablePluginMap();
716+
716717
// Provide a default OnDiskOutputBackend if user didn't supply one.
717718
if (!OutputBackend)
718719
OutputBackend = llvm::makeIntrusiveRefCnt<llvm::vfs::OnDiskOutputBackend>();
720+
// Insert all block list config paths.
721+
for (auto path: langOpts.BlocklistConfigFilePath) {
722+
blockListConfig.addConfigureFilePath(path);
723+
}
719724
}
720725

721726
ASTContext::~ASTContext() {

lib/ASTGen/Sources/ASTGen/Decls.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ extension ASTGenVisitor {
8989

9090
let firstName: UnsafeMutableRawPointer?
9191
let secondName: UnsafeMutableRawPointer?
92-
let type: UnsafeMutableRawPointer?
93-
94-
if let nodeFirstName = node.firstName,
95-
// Swift AST represnts "_" as nil.
96-
nodeFirstName.text != "_" {
92+
93+
let nodeFirstName = node.firstName
94+
if nodeFirstName.text != "_" {
95+
// Swift AST represents "_" as nil.
9796
var text = nodeFirstName.text
9897
firstName = text.withUTF8 { buf in
9998
SwiftASTContext_getIdentifier(ctx, buf.baseAddress, buf.count)
@@ -111,11 +110,7 @@ extension ASTGenVisitor {
111110
secondName = nil
112111
}
113112

114-
if let typeSyntax = node.type {
115-
type = visit(typeSyntax).rawValue
116-
} else {
117-
type = nil
118-
}
113+
let type = visit(node.type).rawValue
119114

120115
return .decl(ParamDecl_create(ctx, loc, loc, firstName, loc, secondName, type, declContext))
121116
}

lib/ASTGen/Sources/ASTGen/Diagnostics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func emitDiagnostic(
110110
message: fixIt.message.message,
111111
severity: .note,
112112
position: diagnostic.position,
113-
fixItChanges: fixIt.changes.changes
113+
fixItChanges: fixIt.changes
114114
)
115115
}
116116

@@ -231,7 +231,7 @@ extension SourceManager {
231231
severity: .note,
232232
node: diagnostic.node,
233233
position: diagnostic.position,
234-
fixItChanges: fixIt.changes.changes
234+
fixItChanges: fixIt.changes
235235
)
236236
}
237237

0 commit comments

Comments
 (0)