Skip to content

Commit 8392254

Browse files
Merge pull request #4700 from swiftwasm/main
[pull] swiftwasm from main
2 parents bc663e3 + 4e1a1b8 commit 8392254

Some content is hidden

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

51 files changed

+637
-218
lines changed

SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,11 @@ public struct DiagnosticFixIt {
5353
}
5454

5555
public struct DiagnosticEngine {
56-
private let bridged: BridgedDiagnosticEngine
56+
private let bridged: swift.DiagnosticEngine
5757

58-
public init(bridged: BridgedDiagnosticEngine) {
58+
public init(bridged: swift.DiagnosticEngine) {
5959
self.bridged = bridged
6060
}
61-
public init?(bridged: BridgedOptionalDiagnosticEngine) {
62-
guard let object = bridged.object else {
63-
return nil
64-
}
65-
self.bridged = BridgedDiagnosticEngine(object: object)
66-
}
6761

6862
public func diagnose(_ position: SourceLoc?,
6963
_ id: DiagID,

SwiftCompilerSources/Sources/Parse/Regex.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private func _RegexLiteralLexingFn(
4646
_ curPtrPtr: UnsafeMutablePointer<UnsafePointer<CChar>>,
4747
_ bufferEndPtr: UnsafePointer<CChar>,
4848
_ mustBeRegex: CBool,
49-
_ bridgedDiagnosticEngine: BridgedOptionalDiagnosticEngine
49+
_ bridgedDiagnosticEngine: swift.DiagnosticEngine?
5050
) -> /*CompletelyErroneous*/ CBool {
5151
let inputPtr = curPtrPtr.pointee
5252

@@ -62,7 +62,8 @@ private func _RegexLiteralLexingFn(
6262

6363
if let error = error {
6464
// Emit diagnostic if diagnostics are enabled.
65-
if let diagEngine = DiagnosticEngine(bridged: bridgedDiagnosticEngine) {
65+
if let bridged = bridgedDiagnosticEngine {
66+
let diagEngine = DiagnosticEngine(bridged: bridged)
6667
let startLoc = SourceLoc(
6768
locationInFile: error.location.assumingMemoryBound(to: UInt8.self))!
6869
diagEngine.diagnose(startLoc, .regex_literal_parsing_error, error.message)
@@ -93,7 +94,7 @@ public func _RegexLiteralParsingFn(
9394
_ captureStructureOut: UnsafeMutableRawPointer,
9495
_ captureStructureSize: CUnsignedInt,
9596
_ bridgedDiagnosticBaseLoc: swift.SourceLoc,
96-
_ bridgedDiagnosticEngine: BridgedDiagnosticEngine
97+
_ bridgedDiagnosticEngine: swift.DiagnosticEngine
9798
) -> Bool {
9899
let str = String(cString: inputPtr)
99100
let captureBuffer = UnsafeMutableRawBufferPointer(

include/swift/AST/ASTBridging.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,12 @@ typedef enum ENUM_EXTENSIBILITY_ATTR(open) BridgedDiagID : uint32_t {
3939
#include "swift/AST/DiagnosticsAll.def"
4040
} BridgedDiagID;
4141

42-
typedef struct {
43-
void * _Nonnull object;
44-
} BridgedDiagnosticEngine;
45-
46-
typedef struct {
47-
void *_Nullable object;
48-
} BridgedOptionalDiagnosticEngine;
49-
5042
// FIXME: Can we bridge InFlightDiagnostic?
51-
void DiagnosticEngine_diagnose(BridgedDiagnosticEngine, swift::SourceLoc loc,
43+
void DiagnosticEngine_diagnose(swift::DiagnosticEngine &, swift::SourceLoc loc,
5244
BridgedDiagID diagID, BridgedArrayRef arguments,
5345
swift::CharSourceRange highlight,
5446
BridgedArrayRef fixIts);
5547

56-
bool DiagnosticEngine_hadAnyError(BridgedDiagnosticEngine);
57-
5848
SWIFT_END_NULLABILITY_ANNOTATIONS
5949

6050
#endif // SWIFT_AST_ASTBRIDGING_H

include/swift/AST/BridgingUtils.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

include/swift/AST/DiagnosticEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ namespace swift {
781781

782782
/// Class responsible for formatting diagnostics and presenting them
783783
/// to the user.
784-
class DiagnosticEngine {
784+
class SWIFT_IMPORT_REFERENCE DiagnosticEngine {
785785
public:
786786
/// The source manager used to interpret source locations and
787787
/// display diagnostics.

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,6 +4215,9 @@ NOTE(opaque_type_underlying_type_candidate_here,none,
42154215
ERROR(opaque_type_self_referential_underlying_type,none,
42164216
"function opaque return type was inferred as %0, which defines the "
42174217
"opaque type in terms of itself", (Type))
4218+
ERROR(opaque_type_cannot_contain_dynamic_self,none,
4219+
"function with opaque return type cannot return "
4220+
"the covariant 'Self' type of a class", ())
42184221
ERROR(opaque_type_var_no_init,none,
42194222
"property declares an opaque return type, but has no initializer "
42204223
"expression from which to infer an underlying type", ())

include/swift/Basic/Compiler.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,11 @@
178178
#define SWIFT_VFORMAT(fmt)
179179
#endif
180180

181+
// Tells Swift's ClangImporter to import a C++ type as a foreign reference type.
182+
#if __has_attribute(swift_attr)
183+
#define SWIFT_IMPORT_REFERENCE __attribute__((swift_attr("import_as_ref")))
184+
#else
185+
#define SWIFT_IMPORT_REFERENCE
186+
#endif
187+
181188
#endif // SWIFT_BASIC_COMPILER_H

include/swift/IRGen/IRABIDetailsProvider.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ class IRABIDetailsProvider {
4747
SizeType alignment;
4848
};
4949

50+
/// Information about any ABI additional parameters.
51+
struct ABIAdditionalParam {
52+
enum class ABIParameterRole { Self, Error };
53+
54+
ABIParameterRole role;
55+
TypeDecl *type;
56+
};
57+
58+
SmallVector<ABIAdditionalParam, 1> ABIAdditionalParams;
59+
5060
/// Returns the size and alignment for the given type, or \c None if the type
5161
/// is not a fixed layout type.
5262
llvm::Optional<SizeAndAlignment>
@@ -99,6 +109,10 @@ class IRABIDetailsProvider {
99109
/// their tag indices from the given EnumDecl
100110
llvm::MapVector<EnumElementDecl *, unsigned> getEnumTagMapping(EnumDecl *ED);
101111

112+
/// Returns the additional params if they exist after lowering the function.
113+
SmallVector<ABIAdditionalParam, 1>
114+
getFunctionABIAdditionalParams(AbstractFunctionDecl *fd);
115+
102116
private:
103117
std::unique_ptr<IRABIDetailsProviderImpl> impl;
104118
};

include/swift/Parse/RegexParserBridging.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
/// past.
2828
/// - MustBeRegex: whether an error during lexing should be considered a regex
2929
/// literal, or some thing else.
30-
/// - BridgedOptionalDiagnosticEngine: RegexLiteralLexingFn should diagnose the
31-
/// token using this engine.
30+
/// - OptionalDiagnosticEngine: RegexLiteralLexingFn should diagnose the
31+
/// token using this engine.
3232
///
3333
/// Returns: A bool indicating whether lexing was completely erroneous, and
3434
/// cannot be recovered from, or false if there either was no error,
3535
/// or there was a recoverable error.
3636
typedef bool (*RegexLiteralLexingFn)(
3737
/*CurPtrPtr*/ const char *_Nonnull *_Nonnull,
3838
/*BufferEnd*/ const char *_Nonnull,
39-
/*MustBeRegex*/ bool, BridgedOptionalDiagnosticEngine);
39+
/*MustBeRegex*/ bool, swift::DiagnosticEngine *_Nullable);
4040
void Parser_registerRegexLiteralLexingFn(RegexLiteralLexingFn _Nullable fn);
4141

4242
/// Parse a regex literal string. Takes the following arguments:
@@ -48,16 +48,16 @@ void Parser_registerRegexLiteralLexingFn(RegexLiteralLexingFn _Nullable fn);
4848
/// - CaptureStructureSize: The size of the capture structure buffer. Must be
4949
/// greater than or equal to `strlen(InputPtr) + 3`.
5050
/// - DiagnosticBaseLoc: Start location of the regex literal.
51-
/// - BridgedDiagnosticEngine: RegexLiteralParsingFn should diagnose the
52-
/// parsing errors using this engine.
51+
/// - DiagnosticEngine: RegexLiteralParsingFn should diagnose the
52+
/// parsing errors using this engine.
5353
///
5454
/// Returns: A bool value indicating if there was an error while parsing.
5555
typedef bool (*RegexLiteralParsingFn)(/*InputPtr*/ const char *_Nonnull,
5656
/*VersionOut*/ unsigned *_Nonnull,
5757
/*CaptureStructureOut*/ void *_Nonnull,
5858
/*CaptureStructureSize*/ unsigned,
5959
/*DiagnosticBaseLoc*/ swift::SourceLoc,
60-
BridgedDiagnosticEngine);
60+
swift::DiagnosticEngine &);
6161
void Parser_registerRegexLiteralParsingFn(RegexLiteralParsingFn _Nullable fn);
6262

6363
#endif // REGEX_PARSER_BRIDGING

include/swift/SIL/SILFunction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,9 @@ class SILFunction
472472
SILFunction *getDynamicallyReplacedFunction() const {
473473
return ReplacedFunction;
474474
}
475+
476+
static SILFunction *getFunction(SILDeclRef ref, SILModule &M);
477+
475478
void setDynamicallyReplacedFunction(SILFunction *f) {
476479
assert(ReplacedFunction == nullptr && "already set");
477480
assert(!hasObjCReplacement());

0 commit comments

Comments
 (0)