mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[move-only] Ensure that if we have an allocation that isn't fully initialized (and DI errors on it as such), the move checkers do not run on the allocation.
Previously we would crash. Since we are relatively late in 5.9, my solution is to just turn off the move checker on functions whenever DI would emit an error. If we were earlier in the development cycle, then I would make the error be a per allocation change. rdar://108993297
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define DEBUG_TYPE "definite-init"
|
||||
|
||||
#include "DIMemoryUseCollector.h"
|
||||
#include "swift/AST/DiagnosticEngine.h"
|
||||
#include "swift/AST/DiagnosticsSIL.h"
|
||||
@@ -18,6 +19,7 @@
|
||||
#include "swift/AST/Stmt.h"
|
||||
#include "swift/ClangImporter/ClangModule.h"
|
||||
#include "swift/SIL/BasicBlockBits.h"
|
||||
#include "swift/AST/SemanticAttrs.h"
|
||||
#include "swift/SIL/BasicBlockData.h"
|
||||
#include "swift/SIL/InstructionUtils.h"
|
||||
#include "swift/SIL/MemAccessUtils.h"
|
||||
@@ -1140,7 +1142,15 @@ void LifetimeChecker::doIt() {
|
||||
}
|
||||
|
||||
// If we emitted an error, there is no reason to proceed with load promotion.
|
||||
if (!EmittedErrorLocs.empty()) return;
|
||||
if (!EmittedErrorLocs.empty()) {
|
||||
// Since we failed DI, for now, turn off the move checker on the entire
|
||||
// function. With time, we should be able to allow for move checker checks
|
||||
// to be emitted on unrelated allocations, but given where we are this is a
|
||||
// good enough fix.
|
||||
TheMemory.getFunction().addSemanticsAttr(
|
||||
semantics::NO_MOVEONLY_DIAGNOSTICS);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the memory object has nontrivial type, then any destroy/release of the
|
||||
// memory object will destruct the memory. If the memory (or some element
|
||||
|
||||
Reference in New Issue
Block a user