Merge pull request #14299 from rudkx/iuo-remove-the-type

IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>
This commit is contained in:
Mark Lacey
2018-02-01 21:58:37 -08:00
committed by GitHub
102 changed files with 664 additions and 657 deletions

View File

@@ -303,6 +303,10 @@ protected:
NumVariadicArgs : 16
);
SWIFT_INLINE_BITFIELD(ForceValueExpr, Expr, 1,
ForcedIUO : 1
);
SWIFT_INLINE_BITFIELD(InOutToPointerExpr, ImplicitConversionExpr, 1,
IsNonAccessing : 1
);
@@ -2507,9 +2511,11 @@ class ForceValueExpr : public Expr {
SourceLoc ExclaimLoc;
public:
ForceValueExpr(Expr *subExpr, SourceLoc exclaimLoc)
ForceValueExpr(Expr *subExpr, SourceLoc exclaimLoc, bool forcedIUO = false)
: Expr(ExprKind::ForceValue, /*Implicit=*/exclaimLoc.isInvalid(), Type()),
SubExpr(subExpr), ExclaimLoc(exclaimLoc) {}
SubExpr(subExpr), ExclaimLoc(exclaimLoc) {
Bits.ForceValueExpr.ForcedIUO = forcedIUO;
}
SourceRange getSourceRange() const {
if (ExclaimLoc.isInvalid())
@@ -2534,6 +2540,10 @@ public:
Expr *getSubExpr() const { return SubExpr; }
void setSubExpr(Expr *expr) { SubExpr = expr; }
bool isForceOfImplicitlyUnwrappedOptional() const {
return Bits.ForceValueExpr.ForcedIUO;
}
static bool classof(const Expr *E) {
return E->getKind() == ExprKind::ForceValue;
}

View File

@@ -4114,7 +4114,9 @@ class ImplicitlyUnwrappedOptionalType : public UnarySyntaxSugarType {
ImplicitlyUnwrappedOptionalType(const ASTContext &ctx, Type base,
RecursiveTypeProperties properties)
: UnarySyntaxSugarType(TypeKind::ImplicitlyUnwrappedOptional, ctx, base,
properties) {}
properties) {
//llvm_unreachable("ImplicitlyUnwrappedOptionalType::ImplicitlyUnwrappedOptionalType");
}
public:
/// Return a uniqued optional type with the specified base type.