mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Requestify the Raw Value Accessor
Make getRawValueExpr() return a checked value. This entails a strange kind of request that effectively acts like a cache warmer. In order to properly check the raw value expression for a single case, we actually need all the other cases for the autoincrementing synthesis logic. The strategy is therefore to have the request act at the level of the parent EnumDecl and check all the values at once. We also cache at the level of the EnumDecl so the cache "warms" for all enum elements simultaneously. The request also abuses TypeResolutionStage to act as an indicator for how much information to compute. In the minimal case, we will return a complete accounting of (auto-incremented) raw values. In the maximal case we will also check and record types and emit diagnostics. The minimal case is uncached to support repeated evaluation. Note that computing the interface type of an @objc enum decl *must* force this request. The enum's raw values are part of the ABI, and we should not get all the way to IRGen before discovering that we cannot possibly lay out the enum. In the future, we might want to consider moving this check earlier or have IRGen tolerate broken cases but for now we will maintain the status quo and not have IRGen emit diagnostics.
This commit is contained in:
@@ -3342,7 +3342,7 @@ public:
|
||||
if (elem->getParentEnum()->isObjC()) {
|
||||
// Currently ObjC enums always have integer raw values.
|
||||
rawValueKind = EnumElementRawValueKind::IntegerLiteral;
|
||||
auto ILE = cast<IntegerLiteralExpr>(elem->getRawValueExpr());
|
||||
auto ILE = cast<IntegerLiteralExpr>(elem->getStructuralRawValueExpr());
|
||||
RawValueText = ILE->getDigitsText();
|
||||
isNegative = ILE->isNegative();
|
||||
isRawValueImplicit = ILE->isImplicit();
|
||||
|
||||
Reference in New Issue
Block a user