mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: Build the AST for inout address conversions.
Add two new AST node types: - InOutConversionExpr, which represents an '&x' expression that involves inout conversion. This will be a signal to SILGen not to introduce a writeback scope for the nested conversion call. - LValueToPointerExpr, which represents the primitive '@lvalue T' to 'RawPointer' conversion that produces the argument to the inout conversion. Build an InOutConversionExpr AST when an inout expression is resolved by a conversion to an BuiltinInOutAddressConvertible type. Swift SVN r15594
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "swift/Subsystems.h"
|
||||
#include "swift/AST/ArchetypeBuilder.h"
|
||||
#include "swift/AST/AST.h"
|
||||
#include "swift/AST/ASTContext.h"
|
||||
#include "swift/AST/ASTWalker.h"
|
||||
#include "swift/AST/Mangle.h"
|
||||
#include "swift/Basic/SourceManager.h"
|
||||
@@ -945,6 +946,28 @@ struct ASTNodeBase {};
|
||||
|
||||
verifyCheckedBase(E);
|
||||
}
|
||||
|
||||
void verifyChecked(LValueToPointerExpr *E) {
|
||||
if (!E->getSubExpr()->getType()->is<LValueType>()) {
|
||||
Out << "LValueToPointerExpr subexpression must be an lvalue";
|
||||
abort();
|
||||
}
|
||||
if (!E->getType()->isEqual(
|
||||
E->getType()->getASTContext().TheRawPointerType)) {
|
||||
Out << "LValueToPointerExpr result type must be RawPointer";
|
||||
abort();
|
||||
}
|
||||
|
||||
verifyCheckedBase(E);
|
||||
}
|
||||
|
||||
void verifyChecked(InOutConversionExpr *E) {
|
||||
if (!E->getSubExpr()->getType()->isEqual(E->getType())) {
|
||||
Out << "InOutConversionExpr must have the same type as its subexpression";
|
||||
abort();
|
||||
}
|
||||
verifyCheckedBase(E);
|
||||
}
|
||||
|
||||
void verifyChecked(MetatypeExpr *E) {
|
||||
auto metatype = E->getType()->getAs<MetatypeType>();
|
||||
|
||||
Reference in New Issue
Block a user