Skip to content

Commit f72b33c

Browse files
authored
Merge pull request #1264 from swiftwasm/master
[pull] swiftwasm from master
2 parents 95529a7 + 7314edd commit f72b33c

25 files changed

+898
-846
lines changed

docs/StandardLibraryProgrammersManual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ On these platforms, the Swift Standard Library ships as an integrated part of th
9898

9999
#### Unwrapping Optionals
100100

101-
Optionals can be unwrapped with `!`, which triggers a trap on nil. Alternatively, they can be `.unsafelyUnwrapped()`, which will check and trap in debug builds of user code. Internal to the standard library is `._unsafelyUnwrappedUnchecked()` which will only check and trap in debug builds of the standard library itself. These correspond directly with `_precondition`, `_debugPrecondition`, and `_sanityCheck`. See [that section](#precondition) for details.
101+
Optionals can be unwrapped with `!`, which triggers a trap on nil. Alternatively, they can be `.unsafelyUnwrapped()`, which will check and trap in debug builds of user code. Internal to the standard library is `._unsafelyUnwrappedUnchecked()` which will only check and trap in debug builds of the standard library itself. These correspond directly with `_precondition`, `_debugPrecondition`, and `_internalInvariant`. See [that section](#precondition) for details.
102102

103103
#### UnsafeBitCast and Casting References
104104

include/swift/AST/CMakeLists.txt

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

include/swift/AST/DiagnosticEngine.h

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ namespace swift {
5858
DiagID ID;
5959
};
6060

61-
struct DiagnosticNode {
62-
DiagID id;
63-
std::string msg;
64-
};
65-
6661
namespace detail {
6762
/// Describes how to pass a diagnostic argument of the given type.
6863
///
@@ -634,26 +629,7 @@ namespace swift {
634629
DiagnosticState(DiagnosticState &&) = default;
635630
DiagnosticState &operator=(DiagnosticState &&) = default;
636631
};
637-
638-
class LocalizationProducer {
639-
public:
640-
/// If the message isn't available/localized in the current `yaml` file,
641-
/// return the fallback default message.
642-
virtual std::string getMessageOr(DiagID id,
643-
std::string defaultMessage) const {
644-
return defaultMessage;
645-
}
646-
647-
virtual ~LocalizationProducer() {}
648-
};
649-
650-
class YAMLLocalizationProducer final : public LocalizationProducer {
651-
public:
652-
std::vector<std::string> diagnostics;
653-
explicit YAMLLocalizationProducer(std::string locale, std::string path);
654-
std::string getMessageOr(DiagID id,
655-
std::string defaultMessage) const override;
656-
};
632+
657633
/// Class responsible for formatting diagnostics and presenting them
658634
/// to the user.
659635
class DiagnosticEngine {
@@ -687,10 +663,6 @@ namespace swift {
687663
/// but rather stored until all transactions complete.
688664
llvm::StringSet<llvm::BumpPtrAllocator &> TransactionStrings;
689665

690-
/// Diagnostic producer to handle the logic behind retriving a localized
691-
/// diagnostic message.
692-
std::unique_ptr<LocalizationProducer> localization;
693-
694666
/// The number of open diagnostic transactions. Diagnostics are only
695667
/// emitted once all transactions have closed.
696668
unsigned TransactionCount = 0;
@@ -762,11 +734,6 @@ namespace swift {
762734
return diagnosticDocumentationPath;
763735
}
764736

765-
void setLocalization(std::string locale, std::string path) {
766-
if (!locale.empty() && !path.empty())
767-
localization = std::make_unique<YAMLLocalizationProducer>(locale, path);
768-
}
769-
770737
void ignoreDiagnostic(DiagID id) {
771738
state.setDiagnosticBehavior(id, DiagnosticState::Behavior::Ignore);
772739
}
@@ -988,7 +955,8 @@ namespace swift {
988955
void emitTentativeDiagnostics();
989956

990957
public:
991-
const char *diagnosticStringFor(const DiagID id, bool printDiagnosticName);
958+
static const char *diagnosticStringFor(const DiagID id,
959+
bool printDiagnosticName);
992960

993961
/// If there is no clear .dia file for a diagnostic, put it in the one
994962
/// corresponding to the SourceLoc given here.

include/swift/AST/DiagnosticMessageFormat.h

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

include/swift/AST/Diagnostics/fr.yaml

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

include/swift/AST/diagnostics/en.yaml

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

include/swift/Frontend/FrontendOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,6 @@ class FrontendOptions {
287287
/// -dump-scope-maps.
288288
SmallVector<std::pair<unsigned, unsigned>, 2> DumpScopeMapLocations;
289289

290-
/// Indicates whether the action will immediately run code.
291-
static bool isActionImmediate(ActionType);
292-
293290
/// \return true if action only parses without doing other compilation steps.
294291
static bool shouldActionOnlyParse(ActionType);
295292

lib/AST/ASTMangler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,10 @@ std::string ASTMangler::mangleAccessorEntityAsUSR(AccessorKind kind,
677677
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
678678
Buffer << USRPrefix;
679679
appendAccessorEntity(getCodeForAccessorKind(kind), decl, isStatic);
680-
// We have a custom prefix, so finalize() won't verify for us. Do it manually.
681-
verify(Storage.str().drop_front(USRPrefix.size()));
680+
// We have a custom prefix, so finalize() won't verify for us. If we're not
681+
// in invalid code (coming from an IDE caller) verify manually.
682+
if (!decl->isInvalid())
683+
verify(Storage.str().drop_front(USRPrefix.size()));
682684
return finalize();
683685
}
684686

lib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "swift/AST/ASTPrinter.h"
2121
#include "swift/AST/Decl.h"
2222
#include "swift/AST/DiagnosticSuppression.h"
23-
#include "swift/AST/DiagnosticMessageFormat.h"
2423
#include "swift/AST/Module.h"
2524
#include "swift/AST/Pattern.h"
2625
#include "swift/AST/PrintOptions.h"
@@ -33,8 +32,6 @@
3332
#include "llvm/ADT/Twine.h"
3433
#include "llvm/Support/CommandLine.h"
3534
#include "llvm/Support/Format.h"
36-
#include "llvm/Support/YAMLParser.h"
37-
#include "llvm/Support/YAMLTraits.h"
3835
#include "llvm/Support/raw_ostream.h"
3936

4037
using namespace swift;
@@ -143,52 +140,6 @@ struct EducationalNotes {
143140
static constexpr EducationalNotes<LocalDiagID::NumDiags> _EducationalNotes = EducationalNotes<LocalDiagID::NumDiags>();
144141
static constexpr auto educationalNotes = _EducationalNotes.value;
145142

146-
class LocalizationInput : public llvm::yaml::Input {
147-
using Input::Input;
148-
149-
/// Read diagnostics in the YAML file iteratively
150-
template <typename T, typename Context>
151-
static typename std::enable_if<llvm::yaml::has_SequenceTraits<T>::value,
152-
void>::type
153-
readYAML(IO &io, T &Seq, bool, Context &Ctx) {
154-
unsigned count = io.beginSequence();
155-
156-
// Resize Diags from YAML file to be the same size
157-
// as diagnosticStrings from def files.
158-
Seq.resize(LocalDiagID::NumDiags);
159-
for (unsigned i = 0; i < count; ++i) {
160-
void *SaveInfo;
161-
if (io.preflightElement(i, SaveInfo)) {
162-
DiagnosticNode current;
163-
yamlize(io, current, true, Ctx);
164-
io.postflightElement(SaveInfo);
165-
// YAML file isn't guaranteed to have diagnostics in order of their
166-
// declaration in `.def` files, to accommodate that we need to leave
167-
// holes in diagnostic array for diagnostics which haven't yet been
168-
// localized and for the ones that have `DiagnosticNode::id`
169-
// indicates their position.
170-
Seq[static_cast<unsigned>(current.id)] = std::move(current.msg);
171-
}
172-
}
173-
io.endSequence();
174-
}
175-
176-
template <typename T>
177-
inline friend
178-
typename std::enable_if<llvm::yaml::has_SequenceTraits<T>::value,
179-
LocalizationInput &>::type
180-
operator>>(LocalizationInput &yin, T &diagnostics) {
181-
llvm::yaml::EmptyContext Ctx;
182-
if (yin.setCurrentDocument()) {
183-
// If YAML file's format doesn't match the current format in
184-
// DiagnosticMessageFormat, will throw an error.
185-
readYAML(yin, diagnostics, true, Ctx);
186-
}
187-
188-
return yin;
189-
}
190-
};
191-
192143
DiagnosticState::DiagnosticState() {
193144
// Initialize our per-diagnostic state to default
194145
perDiagnosticBehavior.resize(LocalDiagID::NumDiags, Behavior::Unspecified);
@@ -360,28 +311,6 @@ void Diagnostic::addChildNote(Diagnostic &&D) {
360311
ChildNotes.push_back(std::move(D));
361312
}
362313

363-
YAMLLocalizationProducer::YAMLLocalizationProducer(std::string locale,
364-
std::string path) {
365-
llvm::SmallString<128> DiagnosticsFilePath(path);
366-
llvm::sys::path::append(DiagnosticsFilePath, locale);
367-
llvm::sys::path::replace_extension(DiagnosticsFilePath, ".yaml");
368-
auto FileBufOrErr = llvm::MemoryBuffer::getFileOrSTDIN(DiagnosticsFilePath);
369-
if (!FileBufOrErr)
370-
llvm_unreachable("Failed to read yaml file");
371-
llvm::MemoryBuffer *document = FileBufOrErr->get();
372-
LocalizationInput yin(document->getBuffer());
373-
yin >> diagnostics;
374-
}
375-
376-
std::string
377-
YAMLLocalizationProducer::getMessageOr(DiagID id,
378-
std::string defaultMessage) const {
379-
std::string diagnosticMessage = diagnostics[(unsigned)id];
380-
if (diagnosticMessage.empty())
381-
return defaultMessage;
382-
return diagnosticMessage;
383-
}
384-
385314
bool DiagnosticEngine::isDiagnosticPointsToFirstBadToken(DiagID ID) const {
386315
return storedDiagnosticInfos[(unsigned) ID].pointsToFirstBadToken;
387316
}
@@ -1082,17 +1011,10 @@ void DiagnosticEngine::emitDiagnostic(const Diagnostic &diagnostic) {
10821011

10831012
const char *DiagnosticEngine::diagnosticStringFor(const DiagID id,
10841013
bool printDiagnosticName) {
1085-
// TODO: Print diagnostic names from `localization`.
10861014
if (printDiagnosticName) {
10871015
return debugDiagnosticStrings[(unsigned)id];
10881016
}
1089-
auto defaultMessage = diagnosticStrings[(unsigned)id];
1090-
if (localization) {
1091-
std::string localizedMessage =
1092-
localization.get()->getMessageOr(id, defaultMessage);
1093-
return localizedMessage.c_str();
1094-
}
1095-
return defaultMessage;
1017+
return diagnosticStrings[(unsigned)id];
10961018
}
10971019

10981020
const char *InFlightDiagnostic::fixItStringFor(const FixItID id) {

lib/AST/Expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
20122012
body = body->getSemanticsProvidingExpr();
20132013

20142014
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(body)) {
2015-
body = openExistential->getSubExpr();
2015+
body = openExistential->getSubExpr()->getSemanticsProvidingExpr();
20162016
}
20172017

20182018
if (auto *outerCall = dyn_cast<ApplyExpr>(body)) {
@@ -2032,7 +2032,7 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
20322032
innerBody = innerBody->getSemanticsProvidingExpr();
20332033

20342034
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(innerBody)) {
2035-
innerBody = openExistential->getSubExpr();
2035+
innerBody = openExistential->getSubExpr()->getSemanticsProvidingExpr();
20362036
if (auto *ICE = dyn_cast<ImplicitConversionExpr>(innerBody))
20372037
innerBody = ICE->getSyntacticSubExpr();
20382038
}

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ bool ArgsToFrontendOptionsConverter::checkUnusedSupplementaryOutputPaths()
539539
return true;
540540
}
541541
if (!FrontendOptions::canActionEmitInterface(Opts.RequestedAction) &&
542-
Opts.InputsAndOutputs.hasModuleInterfaceOutputPath()) {
542+
(Opts.InputsAndOutputs.hasModuleInterfaceOutputPath() ||
543+
Opts.InputsAndOutputs.hasPrivateModuleInterfaceOutputPath())) {
543544
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_interface);
544545
return true;
545546
}

lib/Frontend/FrontendOptions.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -67,45 +67,6 @@ bool FrontendOptions::needsProperModuleName(ActionType action) {
6767
llvm_unreachable("Unknown ActionType");
6868
}
6969

70-
bool FrontendOptions::isActionImmediate(ActionType action) {
71-
switch (action) {
72-
case ActionType::NoneAction:
73-
case ActionType::Parse:
74-
case ActionType::ResolveImports:
75-
case ActionType::Typecheck:
76-
case ActionType::DumpParse:
77-
case ActionType::DumpAST:
78-
case ActionType::EmitSyntax:
79-
case ActionType::DumpInterfaceHash:
80-
case ActionType::PrintAST:
81-
case ActionType::DumpScopeMaps:
82-
case ActionType::DumpTypeRefinementContexts:
83-
case ActionType::EmitPCH:
84-
case ActionType::EmitSILGen:
85-
case ActionType::EmitSIL:
86-
case ActionType::EmitSIBGen:
87-
case ActionType::EmitSIB:
88-
case ActionType::EmitModuleOnly:
89-
case ActionType::MergeModules:
90-
case ActionType::CompileModuleFromInterface:
91-
return false;
92-
case ActionType::Immediate:
93-
case ActionType::REPL:
94-
return true;
95-
case ActionType::EmitAssembly:
96-
case ActionType::EmitIR:
97-
case ActionType::EmitBC:
98-
case ActionType::EmitObject:
99-
case ActionType::EmitImportedModules:
100-
case ActionType::DumpTypeInfo:
101-
case ActionType::EmitPCM:
102-
case ActionType::DumpPCM:
103-
case ActionType::ScanDependencies:
104-
return false;
105-
}
106-
llvm_unreachable("Unknown ActionType");
107-
}
108-
10970
bool FrontendOptions::shouldActionOnlyParse(ActionType action) {
11071
switch (action) {
11172
case FrontendOptions::ActionType::Parse:

0 commit comments

Comments
 (0)