@@ -659,14 +659,21 @@ void UnboundImport::validateRestrictedImport(ASTContext &ctx) {
659659 DeclAttrKind attrToRemove = conflicts[0 ] == ImportFlags::ImplementationOnly?
660660 DAK_Exported : DAK_ImplementationOnly;
661661
662- auto flagName = [](ImportFlags flag) {
662+ // More dense enum with some cases of ImportFlags,
663+ // used by import_restriction_conflict.
664+ enum class ImportFlagForDiag : uint8_t {
665+ ImplementationOnly,
666+ SPIOnly,
667+ Exported
668+ };
669+ auto flagToDiag = [](ImportFlags flag) {
663670 switch (flag) {
664671 case ImportFlags::ImplementationOnly:
665- return " implementation-only " ;
672+ return ImportFlagForDiag::ImplementationOnly ;
666673 case ImportFlags::SPIOnly:
667- return " SPI only " ;
674+ return ImportFlagForDiag::SPIOnly ;
668675 case ImportFlags::Exported:
669- return " exported " ;
676+ return ImportFlagForDiag::Exported ;
670677 default :
671678 llvm_unreachable (" Unexpected ImportFlag" );
672679 }
@@ -676,8 +683,8 @@ void UnboundImport::validateRestrictedImport(ASTContext &ctx) {
676683 auto diag = ctx.Diags .diagnose (import .module .getModulePath ().front ().Loc ,
677684 diag::import_restriction_conflict,
678685 import .module .getModulePath ().front ().Item ,
679- flagName (conflicts[0 ]),
680- flagName (conflicts[1 ]));
686+ ( uint8_t ) flagToDiag (conflicts[0 ]),
687+ ( uint8_t ) flagToDiag (conflicts[1 ]));
681688
682689 auto *ID = getImportDecl ().getPtrOrNull ();
683690 if (!ID) return ;
0 commit comments