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