Skip to content

Commit 0a80fcc

Browse files
Merge pull request #4040 from swiftwasm/main
[pull] swiftwasm from main
2 parents e3a594d + ad2d86c commit 0a80fcc

Some content is hidden

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

46 files changed

+741
-278
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,13 @@ function(add_libswift_module module)
636636
""
637637
"DEPENDS"
638638
${ARGN})
639-
set(sources ${ALSM_UNPARSED_ARGUMENTS})
640-
list(TRANSFORM sources PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
639+
set(raw_sources ${ALSM_UNPARSED_ARGUMENTS})
640+
set(sources)
641+
foreach(raw_source ${raw_sources})
642+
get_filename_component(
643+
raw_source "${raw_source}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
644+
list(APPEND sources "${raw_source}")
645+
endforeach()
641646
642647
set(target_name "LibSwift${module}")
643648

include/swift/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ class ASTContext final {
621621
KnownProtocolKind builtinProtocol,
622622
llvm::function_ref<DeclName (ASTContext &ctx)> initName) const;
623623

624-
/// Retrieve _StringProcessing.Regex.init(_regexString: String).
624+
/// Retrieve _StringProcessing.Regex.init(_regexString: String, version: Int).
625625
ConcreteDeclRef getRegexInitDecl(Type regexType) const;
626626

627627
/// Retrieve the declaration of Swift.<(Int, Int) -> Bool.

include/swift/AST/Expr.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,18 +966,23 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
966966
class RegexLiteralExpr : public LiteralExpr {
967967
SourceLoc Loc;
968968
StringRef RegexText;
969+
unsigned Version;
969970

970-
RegexLiteralExpr(SourceLoc loc, StringRef regexText, bool isImplicit)
971+
RegexLiteralExpr(SourceLoc loc, StringRef regexText, unsigned version,
972+
bool isImplicit)
971973
: LiteralExpr(ExprKind::RegexLiteral, isImplicit), Loc(loc),
972-
RegexText(regexText) {}
974+
RegexText(regexText), Version(version) {}
973975

974976
public:
975977
static RegexLiteralExpr *createParsed(ASTContext &ctx, SourceLoc loc,
976-
StringRef regexText);
978+
StringRef regexText, unsigned version);
977979

978980
/// Retrieve the raw regex text.
979981
StringRef getRegexText() const { return RegexText; }
980982

983+
/// Retrieve the version of the regex string.
984+
unsigned getVersion() const { return Version; }
985+
981986
SourceRange getSourceRange() const { return Loc; }
982987

983988
static bool classof(const Expr *E) {

include/swift/AST/KnownIdentifiers.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ IDENTIFIER(zero)
252252
// String processing
253253
IDENTIFIER(Regex)
254254
IDENTIFIER_(regexString)
255+
IDENTIFIER(version)
255256
IDENTIFIER_(StringProcessing)
256257

257258
// Distributed actors

include/swift/Parse/ExperimentalRegexBridging.h

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,43 @@
55
extern "C" {
66
#endif
77

8-
typedef const char *(* ParseRegexStrawperson)(const char *);
9-
10-
void Parser_registerParseRegexStrawperson(ParseRegexStrawperson fn);
11-
bool Parser_hasParseRegexStrawperson();
8+
/// Attempt to lex a regex literal string. Takes the following arguments:
9+
///
10+
/// - CurPtrPtr: A pointer to the current pointer of lexer, which should be the
11+
/// start of the literal. This will be advanced to the point at
12+
/// which the lexer should resume, or will remain the same if this
13+
/// is not a regex literal.
14+
/// - BufferEnd: A pointer to the end of the buffer, which should not be lexed
15+
/// past.
16+
/// - ErrorOut: If an error is encountered, this will be set to the error
17+
/// string.
18+
///
19+
/// Returns: A bool indicating whether lexing was completely erroneous, and
20+
/// cannot be recovered from, or false if there either was no error,
21+
/// or there was a recoverable error.
22+
typedef bool(* RegexLiteralLexingFn)(/*CurPtrPtr*/ const char **,
23+
/*BufferEnd*/ const char *,
24+
/*ErrorOut*/ const char **);
25+
void Parser_registerRegexLiteralLexingFn(RegexLiteralLexingFn fn);
26+
27+
/// Parse a regex literal string. Takes the following arguments:
28+
///
29+
/// - InputPtr: A null-terminated C string of the regex literal.
30+
/// - ErrorOut: A buffer accepting an error string upon error.
31+
/// - VersionOut: A buffer accepting a regex literal format version.
32+
/// - CaptureStructureOut: A buffer accepting a byte sequence representing the
33+
/// capture structure of the literal.
34+
/// - CaptureStructureSize: The size of the capture structure buffer. Must be
35+
/// greater than or equal to `strlen(InputPtr)`.
36+
typedef void(* RegexLiteralParsingFn)(/*InputPtr*/ const char *,
37+
/*ErrorOut*/ const char **,
38+
/*VersionOut*/ unsigned *,
39+
/*CaptureStructureOut*/ char *,
40+
/*CaptureStructureSize*/ unsigned);
41+
void Parser_registerRegexLiteralParsingFn(RegexLiteralParsingFn fn);
1242

1343
#ifdef __cplusplus
1444
} // extern "C"
1545
#endif
1646

1747
#endif // EXPERIMENTAL_REGEX_BRIDGING
18-
19-
20-
//const char* experimental_regex_strawperson(const char *in);
21-

include/swift/Parse/Lexer.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,9 @@ class Lexer {
595595
void lexStringLiteral(unsigned CustomDelimiterLen = 0);
596596
void lexEscapedIdentifier();
597597

598-
void lexRegexLiteral(const char *TokStart);
598+
/// Attempt to lex a regex literal, returning true if a regex literal was
599+
/// lexed, false if this is not a regex literal.
600+
bool tryLexRegexLiteral(const char *TokStart);
599601

600602
void tryLexEditorPlaceholder();
601603
const char *findEndOfCurlyQuoteStringLiteral(const char *,
@@ -612,9 +614,6 @@ class Lexer {
612614

613615
/// Emit diagnostics for single-quote string and suggest replacement
614616
/// with double-quoted equivalent.
615-
///
616-
/// Or, if we're in strawperson mode, we will emit a custom
617-
/// error message instead, determined by the Swift library.
618617
void diagnoseSingleQuoteStringLiteral(const char *TokStart,
619618
const char *TokEnd);
620619

include/swift/SIL/OwnershipUtils.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,9 @@ inline bool isForwardingConsume(SILValue value) {
104104
bool findInnerTransitiveGuaranteedUses(
105105
SILValue guaranteedValue, SmallVectorImpl<Operand *> *usePoints = nullptr);
106106

107-
/// Like findInnerTransitiveGuaranteedUses except that rather than it being a
108-
/// precondition that the provided value not be a BorrowedValue, it is a [type-
109-
/// system-enforced] precondition that the provided value be a BorrowedValue.
110-
///
111-
/// TODO: Merge with findInnerTransitiveGuaranteedUses.
112-
bool findInnerTransitiveGuaranteedUsesOfBorrowedValue(
107+
/// Find all uses in the extended lifetime (i.e. including copies) of a simple
108+
/// (i.e. not reborrowed) borrow scope and its transitive uses.
109+
bool findExtendedUsesOfSimpleBorrowedValue(
113110
BorrowedValue borrowedValue,
114111
SmallVectorImpl<Operand *> *usePoints = nullptr);
115112

include/swift/SIL/SILValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
438438

439439
template <class T> inline T *getSingleConsumingUserOfType() const;
440440

441-
/// Returns true if this operand has exactly two.
441+
/// Returns true if this operand has exactly two uses.
442442
///
443443
/// This is useful if one has found a predefined set of 2 unique users and
444444
/// wants to check if there are any other users without iterating over the

include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ class CanonicalizeBorrowScope {
147147
bool consolidateBorrowScope();
148148
};
149149

150-
bool shrinkBorrowScope(BeginBorrowInst *bbi, InstructionDeleter &deleter);
150+
bool shrinkBorrowScope(
151+
BeginBorrowInst *bbi, InstructionDeleter &deleter,
152+
SmallVectorImpl<CopyValueInst *> &modifiedCopyValueInsts);
151153

152154
} // namespace swift
153155

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ ConcreteDeclRef ASTContext::getRegexInitDecl(Type regexType) const {
12211221
auto *spModule = getLoadedModule(Id_StringProcessing);
12221222
DeclName name(*const_cast<ASTContext *>(this),
12231223
DeclBaseName::createConstructor(),
1224-
{Id_regexString});
1224+
{Id_regexString, Id_version});
12251225
SmallVector<ValueDecl *, 1> results;
12261226
spModule->lookupQualified(getRegexType(), DeclNameRef(name),
12271227
NL_IncludeUsableFromInline, results);

0 commit comments

Comments
 (0)