@@ -419,17 +419,16 @@ class ModuleFile
419
419
// / Whether or not ImportDecls is valid.
420
420
unsigned ComputedImportDecls : 1 ;
421
421
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 ;
424
424
425
425
// Explicitly pad out to the next word boundary.
426
426
unsigned : 0 ;
427
427
} Bits = {};
428
428
static_assert (sizeof (ModuleBits) <= 8 , " The bit set should be small" );
429
429
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 ;
433
432
}
434
433
435
434
void setEntryPointClassID (serialization::DeclID DID) {
@@ -449,25 +448,24 @@ class ModuleFile
449
448
serialization::ExtendedValidationInfo *extInfo);
450
449
451
450
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) {
455
453
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;
465
458
}
466
459
467
460
// / Emits one last diagnostic, logs the error, and then aborts for the stack
468
461
// / trace.
469
462
LLVM_ATTRIBUTE_NORETURN void fatal (llvm::Error error);
470
463
464
+ LLVM_ATTRIBUTE_NORETURN void fatal () {
465
+ fatal (llvm::make_error<llvm::StringError>(
466
+ " (see \" While...\" info below)" , llvm::inconvertibleErrorCode ()));
467
+ }
468
+
471
469
ASTContext &getContext () const {
472
470
assert (FileContext && " no associated context yet" );
473
471
return FileContext->getParentModule ()->getASTContext ();
@@ -620,9 +618,6 @@ class ModuleFile
620
618
theModule.reset (new ModuleFile (std::move (moduleInputBuffer),
621
619
std::move (moduleDocInputBuffer),
622
620
isFramework, info, extInfo));
623
- assert (info.status == Status::Valid ||
624
- info.status == theModule->getStatus ());
625
- info.status = theModule->getStatus ();
626
621
return info;
627
622
}
628
623
@@ -650,16 +645,12 @@ class ModuleFile
650
645
Status associateWithFileContext (FileUnit *file, SourceLoc diagLoc,
651
646
bool treatAsPartialModule);
652
647
653
- // / Checks whether this module can be used.
654
- Status getStatus () const {
655
- return static_cast <Status>(Bits.Status );
656
- }
657
-
658
648
// / Transfers ownership of a buffer that might contain source code where
659
649
// / other parts of the compiler could have emitted diagnostics, to keep them
660
650
// / alive even if the ModuleFile is destroyed.
661
651
// /
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.
663
654
std::unique_ptr<llvm::MemoryBuffer> takeBufferForDiagnostics ();
664
655
665
656
// / Returns the list of modules this module depends on.
0 commit comments