Skip to content

Commit 54ec600

Browse files
authored
Merge pull request #27605 from CodaFi/penumbra
Put More Faith In Raw Values From Synthesized Enums
2 parents 1cb3d7c + 4bafc77 commit 54ec600

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,6 +2853,7 @@ namespace {
28532853
auto enumDecl = Impl.createDeclWithClangNode<EnumDecl>(
28542854
decl, AccessLevel::Public, loc, enumName,
28552855
Impl.importSourceLoc(decl->getLocation()), None, nullptr, enumDC);
2856+
enumDecl->setHasFixedRawValues();
28562857
enumDecl->computeType();
28572858

28582859
// Annotate as 'frozen' if appropriate.

lib/Sema/TypeCheckDecl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,13 @@ EnumRawValuesRequest::evaluate(Evaluator &eval, EnumDecl *ED,
16541654
continue;
16551655
}
16561656

1657+
// If the raw values of the enum case are fixed, then we trust our callers
1658+
// to have set things up correctly. This comes up with imported enums
1659+
// and deserialized @objc enums which always have their raw values setup
1660+
// beforehand.
1661+
if (ED->LazySemanticInfo.hasFixedRawValues())
1662+
continue;
1663+
16571664
// Check that the raw value is unique.
16581665
RawValueKey key{prevValue};
16591666
RawValueSource source{elt, lastExplicitValueElt};

0 commit comments

Comments
 (0)