Skip to content

Commit f0480a7

Browse files
Merge pull request #4449 from swiftwasm/main
[pull] swiftwasm from main
2 parents 782aa0e + c36716e commit f0480a7

File tree

79 files changed

+3969
-975
lines changed

Some content is hidden

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

79 files changed

+3969
-975
lines changed

include/swift/AST/DiagnosticsCommon.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ ERROR(cannot_parse_group_info_file,none,
3838
ERROR(error_no_group_info,none,
3939
"no group info found for file: '%0'", (StringRef))
4040

41-
NOTE(previous_decldef,none,
42-
"previous definition of %0 is here", (DeclBaseName))
43-
4441
NOTE(brace_stmt_suggest_do,none,
4542
"did you mean to use a 'do' statement?", ())
4643

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ ERROR(number_cant_start_decl_name,none,
219219
(StringRef))
220220
ERROR(expected_identifier_after_case_comma, PointsToFirstBadToken,
221221
"expected identifier after comma in enum 'case' declaration", ())
222-
ERROR(decl_redefinition,none,
223-
"definition conflicts with previous value", ())
224222
ERROR(let_cannot_be_computed_property,none,
225223
"'let' declarations cannot be computed properties", ())
226224
ERROR(let_cannot_be_observing_property,none,

include/swift/AST/KnownIdentifiers.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ IDENTIFIER(InvocationEncoder)
303303
IDENTIFIER(whenLocal)
304304
IDENTIFIER(decodeNextArgument)
305305
IDENTIFIER(SerializationRequirement)
306+
IDENTIFIER_WITH_NAME(builderSelf, "$builderSelf")
306307

307308
#undef IDENTIFIER
308309
#undef IDENTIFIER_

include/swift/AST/PrintOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ struct PrintOptions {
391391
/// Whether to use an empty line to separate two members in a single decl.
392392
bool EmptyLineBetweenMembers = false;
393393

394+
/// Whether to print empty members of a declaration on a single line, e.g.:
395+
/// ```
396+
/// extension Foo: Bar {}
397+
/// ```
398+
bool PrintEmptyMembersOnSameLine = false;
399+
394400
/// Whether to print the extensions from conforming protocols.
395401
bool PrintExtensionFromConformingProtocols = false;
396402

include/swift/Parse/Parser.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,7 @@ class Parser {
784784
return diagnose(Tok.getLoc(),
785785
Diagnostic(DiagID, std::forward<ArgTypes>(Args)...));
786786
}
787-
788-
void diagnoseRedefinition(ValueDecl *Prev, ValueDecl *New);
789-
787+
790788
/// Add a fix-it to remove the space in consecutive identifiers.
791789
/// Add a camel-cased option if it is different than the first option.
792790
void diagnoseConsecutiveIDs(StringRef First, SourceLoc FirstLoc,

include/swift/Runtime/AtomicWaitQueue.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define SWIFT_RUNTIME_ATOMICWAITQUEUE_H
2121

2222
#include "swift/Runtime/Heap.h"
23+
#include "swift/Runtime/HeapObject.h"
2324
#include "swift/Runtime/Mutex.h"
2425
#include <assert.h>
2526

@@ -84,7 +85,7 @@ class AtomicWaitQueue {
8485
/// global lock and while *not* holding the wait queue lock.
8586
void release_locked() {
8687
if (referenceCount == 1) {
87-
delete &asImpl();
88+
swift_cxx_deleteObject(&asImpl());
8889
} else {
8990
referenceCount--;
9091
}
@@ -211,7 +212,7 @@ class AtomicWaitQueue {
211212
// If we created the queue but never published it, destroy it.
212213
if (CurrentQueue) {
213214
CurrentQueue->WaitQueueLock.unlock();
214-
delete CurrentQueue;
215+
swift_cxx_deleteObject(CurrentQueue);
215216
}
216217
}
217218

@@ -425,12 +426,7 @@ class AtomicWaitQueue {
425426
private:
426427
template <class... Args>
427428
static Impl *createNewQueue(Args &&...args) {
428-
#if !defined(__cpp_aligned_new)
429-
static_assert(!swift::requires_aligned_alloc<std::alignment_of<Impl>::value>::value ||
430-
is_aligned_alloc_aware<Impl>::value,
431-
"type is over-aligned for non-alignment aware operator new");
432-
#endif
433-
auto queue = new Impl(std::forward<Args>(args)...);
429+
auto queue = swift_cxx_newObject<Impl>(std::forward<Args>(args)...);
434430
queue->WaitQueueLock.lock();
435431
return queue;
436432
}

include/swift/Runtime/HeapObject.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include <cstddef>
2121
#include <cstdint>
22+
#include <new>
23+
#include <utility>
2224
#include "swift/Runtime/Config.h"
2325

2426
#if SWIFT_OBJC_INTEROP
@@ -131,6 +133,49 @@ void *swift_slowAlloc(size_t bytes, size_t alignMask);
131133
SWIFT_RUNTIME_EXPORT
132134
void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask);
133135

136+
/// Allocate and construct an instance of type \c T.
137+
///
138+
/// \param args The arguments to pass to the constructor for \c T.
139+
///
140+
/// \returns A pointer to a new, fully constructed instance of \c T. This
141+
/// function never returns \c nullptr. The caller is responsible for
142+
/// eventually destroying the resulting object by passing it to
143+
/// \c swift_cxx_deleteObject().
144+
///
145+
/// This function avoids the use of the global \c operator \c new (which may be
146+
/// overridden by other code in a process) in favor of calling
147+
/// \c swift_slowAlloc() and constructing the new object with placement new.
148+
///
149+
/// This function is capable of returning well-aligned memory even on platforms
150+
/// that do not implement the C++17 "over-aligned new" feature.
151+
template <typename T, typename... Args>
152+
static inline T *swift_cxx_newObject(Args &&... args) {
153+
auto result = reinterpret_cast<T *>(swift_slowAlloc(sizeof(T),
154+
alignof(T) - 1));
155+
::new (result) T(std::forward<Args>(args)...);
156+
return result;
157+
}
158+
159+
/// Destruct and deallocate an instance of type \c T.
160+
///
161+
/// \param ptr A pointer to an instance of type \c T previously created with a
162+
/// call to \c swift_cxx_newObject().
163+
///
164+
/// This function avoids the use of the global \c operator \c delete (which may
165+
/// be overridden by other code in a process) in favor of directly calling the
166+
/// destructor for \a *ptr and then freeing its memory by calling
167+
/// \c swift_slowDealloc().
168+
///
169+
/// The effect of passing a pointer to this function that was \em not returned
170+
/// from \c swift_cxx_newObject() is undefined.
171+
template <typename T>
172+
static inline void swift_cxx_deleteObject(T *ptr) {
173+
if (ptr) {
174+
ptr->~T();
175+
swift_slowDealloc(ptr, sizeof(T), alignof(T) - 1);
176+
}
177+
}
178+
134179
/// Atomically increments the retain count of an object.
135180
///
136181
/// \param object - may be null, in which case this is a no-op

include/swift/Sema/ConstraintSystem.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5296,18 +5296,21 @@ class ConstraintSystem {
52965296
= FreeTypeVariableBinding::Disallow,
52975297
bool allowFixes = false);
52985298

5299-
/// Construct and solve a system of constraints based on the given expression
5300-
/// and its contextual information.
5299+
/// Assuming that constraints have already been generated, solve the
5300+
/// constraint system for code completion, writing all solutions to
5301+
/// \p solutions.
53015302
///
53025303
/// This method is designed to be used for code completion which means that
53035304
/// it doesn't mutate given expression, even if there is a single valid
53045305
/// solution, and constraint solver is allowed to produce partially correct
53055306
/// solutions. Such solutions can have any number of holes in them.
53065307
///
5307-
/// \param target The expression involved in code completion.
5308-
///
53095308
/// \param solutions The solutions produced for the given target without
53105309
/// filtering.
5310+
void solveForCodeCompletion(SmallVectorImpl<Solution> &solutions);
5311+
5312+
/// Generate constraints for \p target and solve the resulting constraint
5313+
/// system for code completion (see overload above).
53115314
///
53125315
/// \returns `false` if this call fails (e.g. pre-check or constraint
53135316
/// generation fails), `true` otherwise.

lib/AST/ASTPrinter.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,8 @@ void PrintAST::printMembers(ArrayRef<Decl *> members, bool needComma,
23112311
bool openBracket, bool closeBracket) {
23122312
if (openBracket) {
23132313
Printer << " {";
2314-
Printer.printNewline();
2314+
if (!Options.PrintEmptyMembersOnSameLine || !members.empty())
2315+
Printer.printNewline();
23152316
}
23162317
{
23172318
IndentRAII indentMore(*this);
@@ -3104,13 +3105,12 @@ static FeatureSet getUniqueFeaturesUsed(Decl *decl) {
31043105
return features;
31053106
}
31063107

3107-
static void printCompatibilityCheckIf(ASTPrinter &printer,
3108-
bool isElsif,
3108+
static void printCompatibilityCheckIf(ASTPrinter &printer, bool isElseIf,
31093109
bool includeCompilerCheck,
31103110
const BasicFeatureSet &features) {
31113111
assert(!features.empty());
31123112

3113-
printer << (isElsif ? "#elsif " : "#if ");
3113+
printer << (isElseIf ? "#elseif " : "#if ");
31143114
if (includeCompilerCheck)
31153115
printer << "compiler(>=5.3) && ";
31163116

@@ -3126,7 +3126,7 @@ static void printCompatibilityCheckIf(ASTPrinter &printer,
31263126
printer.printNewline();
31273127
}
31283128

3129-
/// Generate a #if ... #elsif ... #endif chain for the given
3129+
/// Generate a #if ... #elseif ... #endif chain for the given
31303130
/// suppressible feature checks.
31313131
static void printWithSuppressibleFeatureChecks(ASTPrinter &printer,
31323132
PrintOptions &options,
@@ -3147,18 +3147,17 @@ static void printWithSuppressibleFeatureChecks(ASTPrinter &printer,
31473147
return;
31483148
}
31493149

3150-
// Otherwise, enter a `#if` or `#elsif` for the next feature.
3150+
// Otherwise, enter a `#if` or `#elseif` for the next feature.
31513151
Feature feature = generator.next();
3152-
printCompatibilityCheckIf(printer, /*elsif*/ !firstInChain,
3153-
includeCompilerCheck,
3154-
{feature});
3152+
printCompatibilityCheckIf(printer, /*elseif*/ !firstInChain,
3153+
includeCompilerCheck, {feature});
31553154

31563155
// Print the body.
31573156
printBody();
31583157
printer.printNewline();
31593158

31603159
// Start suppressing the feature and recurse to either generate
3161-
// more `#elsif` clauses or finish off with `#endif`.
3160+
// more `#elseif` clauses or finish off with `#endif`.
31623161
suppressingFeature(options, feature, [&] {
31633162
printWithSuppressibleFeatureChecks(printer, options, /*first*/ false,
31643163
includeCompilerCheck, generator,
@@ -3171,13 +3170,13 @@ static void printWithSuppressibleFeatureChecks(ASTPrinter &printer,
31713170
///
31723171
/// In the most general form, with both required features and multiple
31733172
/// suppressible features in play, the generated code pattern looks like
3174-
/// the following (assuming that feaature $bar implies feature $baz):
3173+
/// the following (assuming that feature $bar implies feature $baz):
31753174
///
31763175
/// ```
31773176
/// #if compiler(>=5.3) && $foo
31783177
/// #if $bar
31793178
/// @foo @bar @baz func @test() {}
3180-
/// #elsif $baz
3179+
/// #elseif $baz
31813180
/// @foo @baz func @test() {}
31823181
/// #else
31833182
/// @foo func @test() {}
@@ -3205,7 +3204,7 @@ void swift::printWithCompatibilityFeatureChecks(ASTPrinter &printer,
32053204
bool hasRequiredFeatures = features.hasAnyRequired();
32063205
if (hasRequiredFeatures) {
32073206
printCompatibilityCheckIf(printer,
3208-
/*elsif*/ false,
3207+
/*elseif*/ false,
32093208
/*compiler check*/ true,
32103209
features.requiredFeatures());
32113210
}

lib/DriverTool/swift_symbolgraph_extract_main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args,
170170
ParsedArgs.hasArg(OPT_v),
171171
ParsedArgs.hasArg(OPT_skip_inherited_docs),
172172
ParsedArgs.hasArg(OPT_include_spi_symbols),
173+
/*IncludeClangDocs=*/false,
173174
};
174175

175176
if (auto *A = ParsedArgs.getLastArg(OPT_minimum_access_level)) {

0 commit comments

Comments
 (0)