Skip to content

Commit 1fc998a

Browse files
committed
RequirementMachine: Verify protocol requirement signatures even in noassert builds
1 parent 05aeeff commit 1fc998a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,12 +2690,20 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
26902690
llvm::errs() << "\n";
26912691
}
26922692

2693-
2694-
#ifndef NDEBUG
2695-
// In asserts builds, also verify some invariants of the requirement
2696-
// signature.
2697-
PD->getGenericSignature().verify(reqSig);
2698-
#endif
2693+
if (getASTContext().LangOpts.RequirementMachineProtocolSignatures ==
2694+
RequirementMachineMode::Disabled) {
2695+
#ifndef NDEBUG
2696+
// The GenericSignatureBuilder outputs incorrectly-minimized signatures
2697+
// sometimes, so only check invariants in asserts builds.
2698+
PD->getGenericSignature().verify(reqSig);
2699+
#endif
2700+
} else {
2701+
// When using the Requirement Machine, always verify signatures.
2702+
// An incorrect signature indicates a serious problem which can cause
2703+
// miscompiles or inadvertent ABI dependencies on compiler bugs, so
2704+
// we really want to avoid letting one slip by.
2705+
PD->getGenericSignature().verify(reqSig);
2706+
}
26992707

27002708
(void) reqSig;
27012709

0 commit comments

Comments
 (0)