Skip to content

Commit 4bafc77

Browse files
committed
Put More Faith In Raw Values From Synthesized Enums
By requestifying the raw value accessor and pushing the semantic check into IRGen, we are now partially validating enums that are synthesized by the clang importer and deserialization - something that we were not doing before. The previous check would only skip the auto-incrementer step when this was the case. We now also skip the uniqueness check. Resolves rdar://56037318
1 parent cdfd1ab commit 4bafc77

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)