Skip to content

Commit 02b8104

Browse files
committed
---
yaml --- r: 349480 b: refs/heads/master-next c: 6081bcf h: refs/heads/master
1 parent 7b4aa92 commit 02b8104

File tree

5 files changed

+188
-336
lines changed

5 files changed

+188
-336
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 217265aa51cdefbfab219336848af7e7ec8631de
3+
refs/heads/master-next: 6081bcf191ccff8a18408118dc9e17c95c5ee033
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/include/swift/Serialization/ModuleFile.h

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -419,17 +419,16 @@ class ModuleFile
419419
/// Whether or not ImportDecls is valid.
420420
unsigned ComputedImportDecls : 1;
421421

422-
/// Whether this module file can be used, and what's wrong if not.
423-
unsigned Status : 4;
422+
/// Whether an error has been detected setting up this module file.
423+
unsigned HasError : 1;
424424

425425
// Explicitly pad out to the next word boundary.
426426
unsigned : 0;
427427
} Bits = {};
428428
static_assert(sizeof(ModuleBits) <= 8, "The bit set should be small");
429429

430-
void setStatus(Status status) {
431-
Bits.Status = static_cast<unsigned>(status);
432-
assert(status == getStatus() && "not enough bits for status");
430+
bool hasError() const {
431+
return Bits.HasError;
433432
}
434433

435434
void setEntryPointClassID(serialization::DeclID DID) {
@@ -449,25 +448,24 @@ class ModuleFile
449448
serialization::ExtendedValidationInfo *extInfo);
450449

451450
public:
452-
/// Change the status of the current module. Default argument marks the module
453-
/// as being malformed.
454-
Status error(Status issue = Status::Malformed) {
451+
/// Change the status of the current module.
452+
Status error(Status issue) {
455453
assert(issue != Status::Valid);
456-
if (FileContext && issue == Status::Malformed) {
457-
// This would normally be an assertion but it's more useful to print the
458-
// PrettyStackTrace here even in no-asserts builds. Malformed modules are
459-
// generally unrecoverable.
460-
fatal(llvm::make_error<llvm::StringError>(
461-
"(see \"While...\" info below)", llvm::inconvertibleErrorCode()));
462-
}
463-
setStatus(issue);
464-
return getStatus();
454+
assert((issue != Status::Malformed || !FileContext) &&
455+
"too late to complain about the well-formedness of the module");
456+
Bits.HasError = true;
457+
return issue;
465458
}
466459

467460
/// Emits one last diagnostic, logs the error, and then aborts for the stack
468461
/// trace.
469462
LLVM_ATTRIBUTE_NORETURN void fatal(llvm::Error error);
470463

464+
LLVM_ATTRIBUTE_NORETURN void fatal() {
465+
fatal(llvm::make_error<llvm::StringError>(
466+
"(see \"While...\" info below)", llvm::inconvertibleErrorCode()));
467+
}
468+
471469
ASTContext &getContext() const {
472470
assert(FileContext && "no associated context yet");
473471
return FileContext->getParentModule()->getASTContext();
@@ -620,9 +618,6 @@ class ModuleFile
620618
theModule.reset(new ModuleFile(std::move(moduleInputBuffer),
621619
std::move(moduleDocInputBuffer),
622620
isFramework, info, extInfo));
623-
assert(info.status == Status::Valid ||
624-
info.status == theModule->getStatus());
625-
info.status = theModule->getStatus();
626621
return info;
627622
}
628623

@@ -650,16 +645,12 @@ class ModuleFile
650645
Status associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
651646
bool treatAsPartialModule);
652647

653-
/// Checks whether this module can be used.
654-
Status getStatus() const {
655-
return static_cast<Status>(Bits.Status);
656-
}
657-
658648
/// Transfers ownership of a buffer that might contain source code where
659649
/// other parts of the compiler could have emitted diagnostics, to keep them
660650
/// alive even if the ModuleFile is destroyed.
661651
///
662-
/// Should only be called when getStatus() indicates a failure.
652+
/// Should only be called when a failure has been reported from
653+
/// ModuleFile::load or ModuleFile::associateWithFileContext.
663654
std::unique_ptr<llvm::MemoryBuffer> takeBufferForDiagnostics();
664655

665656
/// Returns the list of modules this module depends on.

0 commit comments

Comments
 (0)