@@ -659,14 +659,21 @@ void UnboundImport::validateRestrictedImport(ASTContext &ctx) {
659
659
DeclAttrKind attrToRemove = conflicts[0 ] == ImportFlags::ImplementationOnly?
660
660
DAK_Exported : DAK_ImplementationOnly;
661
661
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) {
663
670
switch (flag) {
664
671
case ImportFlags::ImplementationOnly:
665
- return " implementation-only " ;
672
+ return ImportFlagForDiag::ImplementationOnly ;
666
673
case ImportFlags::SPIOnly:
667
- return " SPI only " ;
674
+ return ImportFlagForDiag::SPIOnly ;
668
675
case ImportFlags::Exported:
669
- return " exported " ;
676
+ return ImportFlagForDiag::Exported ;
670
677
default :
671
678
llvm_unreachable (" Unexpected ImportFlag" );
672
679
}
@@ -676,8 +683,8 @@ void UnboundImport::validateRestrictedImport(ASTContext &ctx) {
676
683
auto diag = ctx.Diags .diagnose (import .module .getModulePath ().front ().Loc ,
677
684
diag::import_restriction_conflict,
678
685
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 ]));
681
688
682
689
auto *ID = getImportDecl ().getPtrOrNull ();
683
690
if (!ID) return ;
0 commit comments