Skip to content

LValueToPointerExpr is dead code. RIP LValueToPointerExpr. #8995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2778,26 +2778,6 @@ class InjectIntoOptionalExpr : public ImplicitConversionExpr {
}
};

/// Convert the address of an lvalue to a raw pointer.
class LValueToPointerExpr : public ImplicitConversionExpr {
Type AbstractionPattern;
public:
LValueToPointerExpr(Expr *subExpr, Type ty, Type abstractionTy)
: ImplicitConversionExpr(ExprKind::LValueToPointer, subExpr, ty),
AbstractionPattern(abstractionTy) {}

/// Get the declared type of the type for which we are performing this
/// conversion. This defines the abstraction level at which the lvalue should
/// be emitted before taking its address.
Type getAbstractionPatternType() const {
return AbstractionPattern;
}

static bool classof(const Expr *E) {
return E->getKind() == ExprKind::LValueToPointer;
}
};

/// Convert the address of an inout property to a pointer.
class InOutToPointerExpr : public ImplicitConversionExpr {
public:
Expand Down
1 change: 0 additions & 1 deletion include/swift/AST/ExprNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ ABSTRACT_EXPR(ImplicitConversion, Expr)
EXPR(ArrayToPointer, ImplicitConversionExpr)
EXPR(StringToPointer, ImplicitConversionExpr)
EXPR(PointerToPointer, ImplicitConversionExpr)
EXPR(LValueToPointer, ImplicitConversionExpr)
EXPR(ForeignObjectConversion, ImplicitConversionExpr)
EXPR(UnevaluatedInstance, ImplicitConversionExpr)
EXPR_RANGE(ImplicitConversion, Load, UnevaluatedInstance)
Expand Down
5 changes: 0 additions & 5 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2083,11 +2083,6 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
printRec(E->getSubExpr());
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}
void visitLValueToPointerExpr(LValueToPointerExpr *E) {
printCommon(E, "lvalue_to_pointer") << '\n';
printRec(E->getSubExpr());
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}
void visitInjectIntoOptionalExpr(InjectIntoOptionalExpr *E) {
printCommon(E, "inject_into_optional") << '\n';
printRec(E->getSubExpr());
Expand Down
16 changes: 0 additions & 16 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1711,22 +1711,6 @@ class Verifier : public ASTWalker {
verifyCheckedBase(E);
}

void verifyChecked(LValueToPointerExpr *E) {
PrettyStackTraceExpr debugStack(Ctx, "verifying LValueToPointerExpr", E);

if (!E->getSubExpr()->getType()->is<LValueType>()) {
Out << "LValueToPointerExpr subexpression must be an lvalue\n";
abort();
}
if (!E->getType()->isEqual(
E->getType()->getASTContext().TheRawPointerType)) {
Out << "LValueToPointerExpr result type must be RawPointer\n";
abort();
}

verifyCheckedBase(E);
}

void verifyChecked(DynamicTypeExpr *E) {
PrettyStackTraceExpr debugStack(Ctx, "verifying DynamicTypeExpr", E);

Expand Down
2 changes: 0 additions & 2 deletions lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ ConcreteDeclRef Expr::getReferencedDecl() const {
PASS_THROUGH_REFERENCE(ArrayToPointer, getSubExpr);
PASS_THROUGH_REFERENCE(StringToPointer, getSubExpr);
PASS_THROUGH_REFERENCE(PointerToPointer, getSubExpr);
PASS_THROUGH_REFERENCE(LValueToPointer, getSubExpr);
PASS_THROUGH_REFERENCE(ForeignObjectConversion, getSubExpr);
PASS_THROUGH_REFERENCE(UnevaluatedInstance, getSubExpr);
NO_REFERENCE(Coerce);
Expand Down Expand Up @@ -778,7 +777,6 @@ bool Expr::canAppendCallParentheses() const {
case ExprKind::ArrayToPointer:
case ExprKind::StringToPointer:
case ExprKind::PointerToPointer:
case ExprKind::LValueToPointer:
case ExprKind::ForeignObjectConversion:
case ExprKind::UnevaluatedInstance:
case ExprKind::EnumIsCase:
Expand Down
23 changes: 0 additions & 23 deletions lib/SILGen/SILGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ namespace {
RValue visitRebindSelfInConstructorExpr(RebindSelfInConstructorExpr *E,
SGFContext C);
RValue visitInjectIntoOptionalExpr(InjectIntoOptionalExpr *E, SGFContext C);
RValue visitLValueToPointerExpr(LValueToPointerExpr *E, SGFContext C);
RValue visitClassMetatypeToObjectExpr(ClassMetatypeToObjectExpr *E,
SGFContext C);
RValue visitExistentialMetatypeToObjectExpr(ExistentialMetatypeToObjectExpr *E,
Expand Down Expand Up @@ -3352,28 +3351,6 @@ RValue RValueEmitter::visitInjectIntoOptionalExpr(InjectIntoOptionalExpr *E,
return RValue(SGF, E, result);
}

RValue RValueEmitter::visitLValueToPointerExpr(LValueToPointerExpr *E,
SGFContext C) {
LValue lv = SGF.emitLValue(E->getSubExpr(), AccessKind::ReadWrite);
SILValue address = SGF.emitAddressOfLValue(E->getSubExpr(),
std::move(lv),
AccessKind::ReadWrite)
.getUnmanagedValue();
// TODO: Reabstract the lvalue to match the abstraction level expected by
// the inout address conversion's InOutType. For now, just report cases where
// we would need a reabstraction as unsupported.
SILType abstractedTy
= SGF.getLoweredType(AbstractionPattern(E->getAbstractionPatternType()),
E->getSubExpr()->getType()->getLValueOrInOutObjectType());
if (address->getType().getObjectType() != abstractedTy)
SGF.SGM.diagnose(E, diag::not_implemented,
"abstraction difference in inout conversion");

SILValue ptr = SGF.B.createAddressToPointer(E, address,
SILType::getRawPointerType(SGF.getASTContext()));
return RValue(SGF, E, ManagedValue::forUnmanaged(ptr));
}

RValue RValueEmitter::visitClassMetatypeToObjectExpr(
ClassMetatypeToObjectExpr *E,
SGFContext C) {
Expand Down
8 changes: 0 additions & 8 deletions lib/Syntax/LegacyASTTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,14 +1147,6 @@ LegacyASTTransformer::visitPointerToPointerExpr(
return getUnknownExpr(E);
}

RC<SyntaxData>
LegacyASTTransformer::visitLValueToPointerExpr(
LValueToPointerExpr *E,
const SyntaxData *Parent,
const CursorIndex IndexInParent) {
return getUnknownExpr(E);
}

RC<SyntaxData> LegacyASTTransformer::visitForeignObjectConversionExpr(
ForeignObjectConversionExpr *E,
const SyntaxData *Parent,
Expand Down