@@ -3591,8 +3591,10 @@ namespace {
3591
3591
if (name.empty ())
3592
3592
return nullptr ;
3593
3593
3594
- switch (Impl.getEnumKind (clangEnum)) {
3595
- case EnumKind::Constants: {
3594
+ auto enumKind = Impl.getEnumKind (clangEnum);
3595
+ switch (enumKind) {
3596
+ case EnumKind::Constants:
3597
+ case EnumKind::Unknown: {
3596
3598
// The enumeration was simply mapped to an integral type. Create a
3597
3599
// constant with that integral type.
3598
3600
@@ -3609,54 +3611,14 @@ namespace {
3609
3611
isInSystemModule (dc), Bridgeability::None);
3610
3612
if (!type)
3611
3613
return nullptr ;
3612
- // FIXME: Importing the type will recursively revisit this same
3613
- // EnumConstantDecl. Short-circuit out if we already emitted the import
3614
- // for this decl.
3615
- if (auto Known = Impl.importDeclCached (decl, getVersion ()))
3616
- return Known;
3617
3614
3618
3615
// Create the global constant.
3619
- auto result = Impl.createConstant (name, dc, type,
3620
- clang::APValue (decl->getInitVal ()),
3621
- ConstantConvertKind::None,
3622
- /* static*/ dc->isTypeContext (), decl);
3623
- Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}] = result;
3624
-
3625
- // If this is a compatibility stub, mark it as such.
3626
- if (correctSwiftName)
3627
- markAsVariant (result, *correctSwiftName);
3628
-
3629
- return result;
3630
- }
3631
-
3632
- case EnumKind::Unknown: {
3633
- // The enumeration was mapped to a struct containing the integral
3634
- // type. Create a constant with that struct type.
3635
-
3636
- // The context where the constant will be introduced.
3637
- auto dc =
3638
- Impl.importDeclContextOf (decl, importedName.getEffectiveContext ());
3639
- if (!dc)
3640
- return nullptr ;
3641
-
3642
- // Import the enumeration type.
3643
- auto enumType = Impl.importTypeIgnoreIUO (
3644
- Impl.getClangASTContext ().getTagDeclType (clangEnum),
3645
- ImportTypeKind::Value, isInSystemModule (dc), Bridgeability::None);
3646
- if (!enumType)
3647
- return nullptr ;
3648
-
3649
- // FIXME: Importing the type will can recursively revisit this same
3650
- // EnumConstantDecl. Short-circuit out if we already emitted the import
3651
- // for this decl.
3652
- if (auto Known = Impl.importDeclCached (decl, getVersion ()))
3653
- return Known;
3654
-
3655
- // Create the global constant.
3656
- auto result = Impl.createConstant (name, dc, enumType,
3657
- clang::APValue (decl->getInitVal ()),
3658
- ConstantConvertKind::Construction,
3659
- /* static*/ false , decl);
3616
+ bool isStatic = enumKind != EnumKind::Unknown && dc->isTypeContext ();
3617
+ auto result = Impl.createConstant (
3618
+ name, dc, type, clang::APValue (decl->getInitVal ()),
3619
+ enumKind == EnumKind::Unknown ? ConstantConvertKind::Construction
3620
+ : ConstantConvertKind::None,
3621
+ isStatic, decl);
3660
3622
Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}] = result;
3661
3623
3662
3624
// If this is a compatibility stub, mark it as such.
@@ -3678,7 +3640,7 @@ namespace {
3678
3640
return nullptr ;
3679
3641
}
3680
3642
}
3681
-
3643
+
3682
3644
llvm_unreachable (" Invalid EnumKind." );
3683
3645
}
3684
3646
0 commit comments