Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
683b9fa
[stdlib] Adjust/fix String’s indexing operations to deal with the con…
lorentey Mar 2, 2022
6e18955
[stdlib] Add bookkeeping to keep track of the encoding of strings and…
lorentey Mar 2, 2022
15c7721
[stdlib] Use the new index encoding flags when marking the encoding o…
lorentey Mar 2, 2022
a44997e
[stdlib] Factor scalar-aligned String index validation out into a set…
lorentey Mar 2, 2022
87073f2
[stdlib] Substring.replaceSubrange: fix startIndex/endIndex adjustment
lorentey Mar 3, 2022
8ab2379
[stdlib] Round indices down to nearest Character in String’s index al…
lorentey Mar 17, 2022
836bf9a
[stdlib] Mark index encodings in String.UTF8View & UTF16View
lorentey Mar 17, 2022
6245da2
[stdlib] Substring: Be consistent about how we refer to the underlyin…
lorentey Mar 17, 2022
0c0cbe2
[stdlib] _StringGutsSlice: Don’t mark methods on non-@usableFromInlin…
lorentey Mar 18, 2022
321284e
[stdlib] Review & fix index validation during String index conversions
lorentey Mar 18, 2022
a343570
[stdlib][NFC] String normalization: fix terminology (index ⟹ offset)
lorentey Mar 18, 2022
5a22ceb
[stdlib] _StringGutsSlice: Small adjustments
lorentey Mar 18, 2022
2464aa6
[stdlib] String: Ensure indices are marked scalar aligned before roun…
lorentey Mar 22, 2022
6d400c8
[stdlib] Substring: remove _encodedOffsetRange in favor of existing _…
lorentey Mar 22, 2022
c436654
[stdlib] Substring._characterStride(startingAt:): Limit stride to the…
lorentey Mar 22, 2022
0523b67
[stdlib] String.index(_:offsetBy:limitedBy:): compare limit against o…
lorentey Mar 24, 2022
99f693e
[test] stdlib/StringIndex: Review & extend with more cases
lorentey Mar 24, 2022
1326c43
[stdlib][NFC] Update some outdated comments
lorentey Mar 24, 2022
98d5959
[stdlib] String.Index: Adjust printing
lorentey Mar 24, 2022
90fee62
[stdlib] String.UTF16View: Mark foreign indices as UTF-16 encoded
lorentey Mar 24, 2022
2988992
[stdlib] String: Add some extra invariant checks
lorentey Mar 24, 2022
67f01a1
[stdlib] Stop inlining String.subscript
lorentey Mar 25, 2022
d588112
[stdlib] String.UnicodeScalarView: Review index validation
lorentey Mar 25, 2022
8610bdf
[stdlib] String.unicodeScalars: Add a _modify accessor
lorentey Mar 29, 2022
5f6c300
[stdlib] String.UTF8View: Review/fix index validation
lorentey Mar 29, 2022
4ad8b26
[stdlib] String.UTF16View: Review/fix index validation
lorentey Mar 29, 2022
e821269
[stdlib] String: Apply transcoded offset when converting indices from…
lorentey Mar 29, 2022
4aae824
[stdlib] String: Deprecate old bounds checking methods
lorentey Mar 29, 2022
06090ce
[test] Add more String coverage
lorentey Mar 29, 2022
4eab835
[stdlib] String: prefer passing ranges to start+end argument pairs
lorentey Mar 30, 2022
dc69903
[stdlib] StringGuts.scalarAlign: Preserve encoding flags in returned …
lorentey Mar 30, 2022
755712a
[stdlib] StringGuts.replaceSubrange: Fast path for replacing with a f…
lorentey Mar 30, 2022
9714f97
[stdlib] Substring: round indices down to nearest character in indexi…
lorentey Mar 30, 2022
b29d8f4
[stdlib] Substring: restrict grapheme breaking to the bounds of the s…
lorentey Mar 30, 2022
1c9c5cc
[test] test/StringIndex: Add some tests exercising replaceSubrange
lorentey Mar 30, 2022
b7c54ac
[stdlib] Substring.init: Stop checking things twice
lorentey Mar 30, 2022
c9adf7a
[stdlib] Substring: Review view creation/conversion code
lorentey Mar 30, 2022
3616a05
[stdlib] Substring.makeContiguousUTF8: Do not lose context in `base`
lorentey Mar 30, 2022
ff58d54
[stdlib][NFC] Substring adjustments
lorentey Mar 30, 2022
f7c674e
[stdlib] Slice._bounds, Range<String.Index>._encodedOffsetRange: New …
lorentey Apr 5, 2022
2e9fd9e
[stdlib] Substring.UnicodeScalarView: Add _invariantCheck
lorentey Apr 5, 2022
e0bd5f7
[stdlib] Fix Substring.UnicodeScalarView.replaceSubrange
lorentey Apr 5, 2022
42c8238
[test] stdlib/StringIndex: Simplify
lorentey Apr 5, 2022
4247279
[stdlib] String.UnicodeScalarView: Optimize replaceSubrange
lorentey Apr 6, 2022
73312fe
[stdlib] Grapheme breaking: Refactor to simplify logic
lorentey Apr 6, 2022
3f2550f
[test] stdlib/StringGraphemeBreaking: Add backwards checks
lorentey Apr 6, 2022
7121600
[test] Move useful helpers into StdlibUnicodeUnittest
lorentey Apr 7, 2022
b034c48
[CodeCompletion] Record fixes while solving result builders for code …
ahoppen Apr 7, 2022
1abd15b
[Sema] Print whether a type variable allows binding to a hole
ahoppen Apr 6, 2022
0b9644a
[CodeCompletion] Report type relations when completing inside result …
ahoppen Apr 8, 2022
83df814
[stdlib] _StringObject.isKnownUTF16 → isForeignUTF8
lorentey Apr 7, 2022
d24ae9d
[stdlib] Remove Substring._endIsCharacterAligned
lorentey Apr 7, 2022
b06e6e5
[stdlib] String: Fix major perf regression due to extra arc traffic
lorentey Apr 7, 2022
eadef7a
[stdlib] String.Index: Use symbolic names rather than magic constants
lorentey Apr 9, 2022
d18b5f5
[stdlib] Branchless _StringGuts.hasMatchingEncoding
lorentey Apr 9, 2022
3c99689
[stdlib] String: Implement happy paths for index validation
lorentey Apr 10, 2022
58ab3fe
Apply suggestions from code review
lorentey Apr 10, 2022
67adcab
Apply notes from code review
lorentey Apr 10, 2022
bbb0048
[stdlib] Minor enhancements
lorentey Apr 10, 2022
d3df05c
[stdlib] String.Index: Remove custom printing
lorentey Apr 10, 2022
dcfc26c
[stdlib][NFC] Doc adjustments
lorentey Apr 10, 2022
ed7d60c
[stdlib] Remove unused fn
lorentey Apr 11, 2022
f27005b
ModuleInterface: When printing synthesized extensions, we need to be …
tshortli Apr 9, 2022
680bf2e
[CursorInfo] Add ObjC location to generated symbol graph
bnbarham Apr 13, 2022
b33fefb
[stdlib] String: be more consistent about when markEncoding is called
lorentey Apr 14, 2022
89d69a9
[stdlib] Revert noop change
lorentey Apr 14, 2022
cb2194c
[stdlib] Fix ABI and portability issues
lorentey Apr 14, 2022
c67f08b
[stdlib][NFC] Remove obsolete note
lorentey Apr 14, 2022
8cef6d5
Don't emit `@preconcurrency import` warnings for Swift interfaces
DougGregor Apr 14, 2022
c5e99e4
Concurrency: include missing header
compnerd Apr 14, 2022
4a0f6ce
CS: `optional` storage key path components are read-only
AnthonyLatsis Apr 14, 2022
1d97379
Merge pull request #42353 from bnbarham/add-objc-loc
bnbarham Apr 14, 2022
1a210bb
Merge pull request #42210 from ahoppen/pr/result-builder-type-relatio…
ahoppen Apr 14, 2022
4ebf04a
Merge pull request #42365 from apple/compnerd/new
compnerd Apr 14, 2022
364dc39
Turn on Existential Metatypes
CodaFi Apr 14, 2022
52d224c
[Test] Fix broken IDE test
bnbarham Apr 14, 2022
94623f0
Merge pull request #42370 from bnbarham/fix-broken-test
milseman Apr 14, 2022
e52ccf4
[SymbolGraph] Initialize newly added IncludeClangDocs field
bnbarham Apr 14, 2022
d8ade63
[TypeChecker] NFC: Un-XFAIL SwiftUI test-case which has been fixed
xedin Apr 14, 2022
3f24533
Ensure AtomicWaitQueue allocates its inner queues in an aligned fashi…
grynspan Apr 14, 2022
57f0e67
Merge pull request #41417 from lorentey/the-horror-of-se-0180
lorentey Apr 14, 2022
a8b0ee2
runtime: blanket application of namespacing and inclusion of `new`
compnerd Apr 14, 2022
cc0627a
Merge pull request #42276 from tshortli/global-actor-broken-swift-int…
tshortli Apr 14, 2022
a2328b0
[Type Resolution] Resolve (any P.Type).Type as the metatype of an
hborla Apr 14, 2022
1677676
Merge pull request #42373 from bnbarham/fix-uninit-field
bnbarham Apr 14, 2022
aad67a8
Only run this new test on macOS
DougGregor Apr 15, 2022
7a69823
Merge pull request #42375 from xedin/rdar-66110075
xedin Apr 15, 2022
04d5df6
Merge pull request #42354 from CodaFi/metatextual-analysis
CodaFi Apr 15, 2022
2453211
[NFC] Remove Legacy Parser-Based Redeclaration Diagnostics
CodaFi Apr 15, 2022
26219fc
Merge pull request #42376 from compnerd/new
compnerd Apr 15, 2022
155cd2e
Merge pull request #42355 from apple/jgrynspan/AtomicWaitQueue-aligne…
grynspan Apr 15, 2022
b175165
Merge pull request #42382 from CodaFi/redress
swift-ci Apr 15, 2022
9de1a79
Merge pull request #42362 from DougGregor/preconcurrency-silence-swif…
DougGregor Apr 15, 2022
fb4720d
[BuilderTransform] Replace use of TypeExpr with a special $builderSel…
xedin Apr 13, 2022
eb8c43e
[CSGen] Remove a hack from `visitTypeExpr` that used to support resul…
xedin Apr 13, 2022
66a8ae0
[test] Move string test helper methods to StdlibUnittest
lorentey Apr 15, 2022
47d6909
Merge pull request #42363 from AnthonyLatsis/swift-keypath-objc-optio…
AnthonyLatsis Apr 15, 2022
43d9901
Merge pull request #42385 from lorentey/the-horror-of-se-0180-continues
compnerd Apr 15, 2022
018cd08
Merge pull request #42329 from xedin/builder-var
xedin Apr 15, 2022
c36716e
Merge pull request #42380 from hborla/nested-existential-metatype-res…
hborla Apr 15, 2022
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 include/swift/AST/DiagnosticsCommon.def
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ ERROR(cannot_parse_group_info_file,none,
ERROR(error_no_group_info,none,
"no group info found for file: '%0'", (StringRef))

NOTE(previous_decldef,none,
"previous definition of %0 is here", (DeclBaseName))

NOTE(brace_stmt_suggest_do,none,
"did you mean to use a 'do' statement?", ())

Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ ERROR(number_cant_start_decl_name,none,
(StringRef))
ERROR(expected_identifier_after_case_comma, PointsToFirstBadToken,
"expected identifier after comma in enum 'case' declaration", ())
ERROR(decl_redefinition,none,
"definition conflicts with previous value", ())
ERROR(let_cannot_be_computed_property,none,
"'let' declarations cannot be computed properties", ())
ERROR(let_cannot_be_observing_property,none,
Expand Down
1 change: 1 addition & 0 deletions include/swift/AST/KnownIdentifiers.def
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ IDENTIFIER(InvocationEncoder)
IDENTIFIER(whenLocal)
IDENTIFIER(decodeNextArgument)
IDENTIFIER(SerializationRequirement)
IDENTIFIER_WITH_NAME(builderSelf, "$builderSelf")

#undef IDENTIFIER
#undef IDENTIFIER_
Expand Down
6 changes: 6 additions & 0 deletions include/swift/AST/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ struct PrintOptions {
/// Whether to use an empty line to separate two members in a single decl.
bool EmptyLineBetweenMembers = false;

/// Whether to print empty members of a declaration on a single line, e.g.:
/// ```
/// extension Foo: Bar {}
/// ```
bool PrintEmptyMembersOnSameLine = false;

/// Whether to print the extensions from conforming protocols.
bool PrintExtensionFromConformingProtocols = false;

Expand Down
4 changes: 1 addition & 3 deletions include/swift/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,7 @@ class Parser {
return diagnose(Tok.getLoc(),
Diagnostic(DiagID, std::forward<ArgTypes>(Args)...));
}

void diagnoseRedefinition(ValueDecl *Prev, ValueDecl *New);


/// Add a fix-it to remove the space in consecutive identifiers.
/// Add a camel-cased option if it is different than the first option.
void diagnoseConsecutiveIDs(StringRef First, SourceLoc FirstLoc,
Expand Down
12 changes: 4 additions & 8 deletions include/swift/Runtime/AtomicWaitQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define SWIFT_RUNTIME_ATOMICWAITQUEUE_H

#include "swift/Runtime/Heap.h"
#include "swift/Runtime/HeapObject.h"
#include "swift/Runtime/Mutex.h"
#include <assert.h>

Expand Down Expand Up @@ -84,7 +85,7 @@ class AtomicWaitQueue {
/// global lock and while *not* holding the wait queue lock.
void release_locked() {
if (referenceCount == 1) {
delete &asImpl();
swift_cxx_deleteObject(&asImpl());
} else {
referenceCount--;
}
Expand Down Expand Up @@ -211,7 +212,7 @@ class AtomicWaitQueue {
// If we created the queue but never published it, destroy it.
if (CurrentQueue) {
CurrentQueue->WaitQueueLock.unlock();
delete CurrentQueue;
swift_cxx_deleteObject(CurrentQueue);
}
}

Expand Down Expand Up @@ -425,12 +426,7 @@ class AtomicWaitQueue {
private:
template <class... Args>
static Impl *createNewQueue(Args &&...args) {
#if !defined(__cpp_aligned_new)
static_assert(!swift::requires_aligned_alloc<std::alignment_of<Impl>::value>::value ||
is_aligned_alloc_aware<Impl>::value,
"type is over-aligned for non-alignment aware operator new");
#endif
auto queue = new Impl(std::forward<Args>(args)...);
auto queue = swift_cxx_newObject<Impl>(std::forward<Args>(args)...);
queue->WaitQueueLock.lock();
return queue;
}
Expand Down
45 changes: 45 additions & 0 deletions include/swift/Runtime/HeapObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <cstddef>
#include <cstdint>
#include <new>
#include <utility>
#include "swift/Runtime/Config.h"

#if SWIFT_OBJC_INTEROP
Expand Down Expand Up @@ -131,6 +133,49 @@ void *swift_slowAlloc(size_t bytes, size_t alignMask);
SWIFT_RUNTIME_EXPORT
void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask);

/// Allocate and construct an instance of type \c T.
///
/// \param args The arguments to pass to the constructor for \c T.
///
/// \returns A pointer to a new, fully constructed instance of \c T. This
/// function never returns \c nullptr. The caller is responsible for
/// eventually destroying the resulting object by passing it to
/// \c swift_cxx_deleteObject().
///
/// This function avoids the use of the global \c operator \c new (which may be
/// overridden by other code in a process) in favor of calling
/// \c swift_slowAlloc() and constructing the new object with placement new.
///
/// This function is capable of returning well-aligned memory even on platforms
/// that do not implement the C++17 "over-aligned new" feature.
template <typename T, typename... Args>
static inline T *swift_cxx_newObject(Args &&... args) {
auto result = reinterpret_cast<T *>(swift_slowAlloc(sizeof(T),
alignof(T) - 1));
::new (result) T(std::forward<Args>(args)...);
return result;
}

/// Destruct and deallocate an instance of type \c T.
///
/// \param ptr A pointer to an instance of type \c T previously created with a
/// call to \c swift_cxx_newObject().
///
/// This function avoids the use of the global \c operator \c delete (which may
/// be overridden by other code in a process) in favor of directly calling the
/// destructor for \a *ptr and then freeing its memory by calling
/// \c swift_slowDealloc().
///
/// The effect of passing a pointer to this function that was \em not returned
/// from \c swift_cxx_newObject() is undefined.
template <typename T>
static inline void swift_cxx_deleteObject(T *ptr) {
if (ptr) {
ptr->~T();
swift_slowDealloc(ptr, sizeof(T), alignof(T) - 1);
}
}

/// Atomically increments the retain count of an object.
///
/// \param object - may be null, in which case this is a no-op
Expand Down
11 changes: 7 additions & 4 deletions include/swift/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -5296,18 +5296,21 @@ class ConstraintSystem {
= FreeTypeVariableBinding::Disallow,
bool allowFixes = false);

/// Construct and solve a system of constraints based on the given expression
/// and its contextual information.
/// Assuming that constraints have already been generated, solve the
/// constraint system for code completion, writing all solutions to
/// \p solutions.
///
/// This method is designed to be used for code completion which means that
/// it doesn't mutate given expression, even if there is a single valid
/// solution, and constraint solver is allowed to produce partially correct
/// solutions. Such solutions can have any number of holes in them.
///
/// \param target The expression involved in code completion.
///
/// \param solutions The solutions produced for the given target without
/// filtering.
void solveForCodeCompletion(SmallVectorImpl<Solution> &solutions);

/// Generate constraints for \p target and solve the resulting constraint
/// system for code completion (see overload above).
///
/// \returns `false` if this call fails (e.g. pre-check or constraint
/// generation fails), `true` otherwise.
Expand Down
25 changes: 12 additions & 13 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2311,7 +2311,8 @@ void PrintAST::printMembers(ArrayRef<Decl *> members, bool needComma,
bool openBracket, bool closeBracket) {
if (openBracket) {
Printer << " {";
Printer.printNewline();
if (!Options.PrintEmptyMembersOnSameLine || !members.empty())
Printer.printNewline();
}
{
IndentRAII indentMore(*this);
Expand Down Expand Up @@ -3104,13 +3105,12 @@ static FeatureSet getUniqueFeaturesUsed(Decl *decl) {
return features;
}

static void printCompatibilityCheckIf(ASTPrinter &printer,
bool isElsif,
static void printCompatibilityCheckIf(ASTPrinter &printer, bool isElseIf,
bool includeCompilerCheck,
const BasicFeatureSet &features) {
assert(!features.empty());

printer << (isElsif ? "#elsif " : "#if ");
printer << (isElseIf ? "#elseif " : "#if ");
if (includeCompilerCheck)
printer << "compiler(>=5.3) && ";

Expand All @@ -3126,7 +3126,7 @@ static void printCompatibilityCheckIf(ASTPrinter &printer,
printer.printNewline();
}

/// Generate a #if ... #elsif ... #endif chain for the given
/// Generate a #if ... #elseif ... #endif chain for the given
/// suppressible feature checks.
static void printWithSuppressibleFeatureChecks(ASTPrinter &printer,
PrintOptions &options,
Expand All @@ -3147,18 +3147,17 @@ static void printWithSuppressibleFeatureChecks(ASTPrinter &printer,
return;
}

// Otherwise, enter a `#if` or `#elsif` for the next feature.
// Otherwise, enter a `#if` or `#elseif` for the next feature.
Feature feature = generator.next();
printCompatibilityCheckIf(printer, /*elsif*/ !firstInChain,
includeCompilerCheck,
{feature});
printCompatibilityCheckIf(printer, /*elseif*/ !firstInChain,
includeCompilerCheck, {feature});

// Print the body.
printBody();
printer.printNewline();

// Start suppressing the feature and recurse to either generate
// more `#elsif` clauses or finish off with `#endif`.
// more `#elseif` clauses or finish off with `#endif`.
suppressingFeature(options, feature, [&] {
printWithSuppressibleFeatureChecks(printer, options, /*first*/ false,
includeCompilerCheck, generator,
Expand All @@ -3171,13 +3170,13 @@ static void printWithSuppressibleFeatureChecks(ASTPrinter &printer,
///
/// In the most general form, with both required features and multiple
/// suppressible features in play, the generated code pattern looks like
/// the following (assuming that feaature $bar implies feature $baz):
/// the following (assuming that feature $bar implies feature $baz):
///
/// ```
/// #if compiler(>=5.3) && $foo
/// #if $bar
/// @foo @bar @baz func @test() {}
/// #elsif $baz
/// #elseif $baz
/// @foo @baz func @test() {}
/// #else
/// @foo func @test() {}
Expand Down Expand Up @@ -3205,7 +3204,7 @@ void swift::printWithCompatibilityFeatureChecks(ASTPrinter &printer,
bool hasRequiredFeatures = features.hasAnyRequired();
if (hasRequiredFeatures) {
printCompatibilityCheckIf(printer,
/*elsif*/ false,
/*elseif*/ false,
/*compiler check*/ true,
features.requiredFeatures());
}
Expand Down
1 change: 1 addition & 0 deletions lib/DriverTool/swift_symbolgraph_extract_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args,
ParsedArgs.hasArg(OPT_v),
ParsedArgs.hasArg(OPT_skip_inherited_docs),
ParsedArgs.hasArg(OPT_include_spi_symbols),
/*IncludeClangDocs=*/false,
};

if (auto *A = ParsedArgs.getLastArg(OPT_minimum_access_level)) {
Expand Down
Loading