Skip to content

Split off StorageImplInfo from AccessorRecord #26235

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 2 commits into from
Jul 23, 2019
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
265 changes: 115 additions & 150 deletions include/swift/AST/Decl.h

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -4367,16 +4367,15 @@ WARNING(variable_never_used, none,
"consider replacing with '_' or removing it",
(Identifier, unsigned))
WARNING(immutable_value_never_used_but_assigned, none,
"immutable value %0 was never used; "
"consider removing it",
"immutable value %0 was never used; consider removing it",
(Identifier))
WARNING(variable_never_mutated, none,
"%select{variable|parameter}1 %0 was never mutated; "
"consider %select{removing 'var' to make it|changing to 'let'}2 constant",
(Identifier, unsigned, bool))
"variable %0 was never mutated; "
"consider %select{removing 'var' to make it|changing to 'let'}1 constant",
(Identifier, bool))
WARNING(variable_never_read, none,
"%select{variable|parameter}1 %0 was written to, but never read",
(Identifier, unsigned))
"variable %0 was written to, but never read",
(Identifier))

//------------------------------------------------------------------------------
// MARK: Debug diagnostics
Expand Down
10 changes: 5 additions & 5 deletions include/swift/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ class Parser {
bool parseVersionTuple(llvm::VersionTuple &Version, SourceRange &Range,
const Diagnostic &D);

bool parseTypeAttributeList(VarDecl::Specifier &Specifier,
bool parseTypeAttributeList(ParamDecl::Specifier &Specifier,
SourceLoc &SpecifierLoc,
TypeAttributes &Attributes) {
if (Tok.isAny(tok::at_sign, tok::kw_inout) ||
Expand All @@ -961,7 +961,7 @@ class Parser {
return parseTypeAttributeListPresent(Specifier, SpecifierLoc, Attributes);
return false;
}
bool parseTypeAttributeListPresent(VarDecl::Specifier &Specifier,
bool parseTypeAttributeListPresent(ParamDecl::Specifier &Specifier,
SourceLoc &SpecifierLoc,
TypeAttributes &Attributes);
bool parseTypeAttribute(TypeAttributes &Attributes,
Expand Down Expand Up @@ -1103,7 +1103,7 @@ class Parser {
SourceLoc consumeImplicitlyUnwrappedOptionalToken();

TypeRepr *applyAttributeToType(TypeRepr *Ty, const TypeAttributes &Attr,
VarDecl::Specifier Specifier,
ParamDecl::Specifier Specifier,
SourceLoc SpecifierLoc);

//===--------------------------------------------------------------------===//
Expand Down Expand Up @@ -1142,7 +1142,7 @@ class Parser {
SourceLoc SpecifierLoc;

/// The parsed specifier kind, if present.
VarDecl::Specifier SpecifierKind = VarDecl::Specifier::Default;
ParamDecl::Specifier SpecifierKind = ParamDecl::Specifier::Default;

/// The location of the first name.
///
Expand Down Expand Up @@ -1260,7 +1260,7 @@ class Parser {


Pattern *createBindingFromPattern(SourceLoc loc, Identifier name,
VarDecl::Specifier specifier);
VarDecl::Introducer introducer);


/// Determine whether this token can only start a matching pattern
Expand Down
41 changes: 24 additions & 17 deletions include/swift/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 501; // cond_fail messages
const uint16_t SWIFTMODULE_VERSION_MINOR = 502; // move specifier down to ParamDecl

using DeclIDField = BCFixed<31>;

Expand Down Expand Up @@ -247,14 +247,21 @@ using CtorInitializerKindField = BCFixed<2>;

// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class VarDeclSpecifier : uint8_t {
enum class ParamDeclSpecifier : uint8_t {
Default = 0,
InOut = 1,
Shared = 2,
Owned = 3,
};
using ParamDeclSpecifierField = BCFixed<2>;

// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
enum class VarDeclIntroducer : uint8_t {
Let = 0,
Var,
InOut,
Shared,
Owned,
Var = 1
};
using VarDeclSpecifierField = BCFixed<3>;
using VarDeclIntroducerField = BCFixed<1>;

// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
Expand Down Expand Up @@ -1041,7 +1048,7 @@ namespace decls_block {
BCFixed<1>, // implicit?
BCFixed<1>, // explicitly objc?
BCFixed<1>, // static?
VarDeclSpecifierField, // specifier
VarDeclIntroducerField, // introducer
BCFixed<1>, // HasNonPatternBindingInit?
BCFixed<1>, // is getter mutating?
BCFixed<1>, // is setter mutating?
Expand All @@ -1063,15 +1070,15 @@ namespace decls_block {

using ParamLayout = BCRecordLayout<
PARAM_DECL,
IdentifierIDField, // argument name
IdentifierIDField, // parameter name
DeclContextIDField, // context decl
VarDeclSpecifierField, // specifier
TypeIDField, // interface type
BCFixed<1>, // isVariadic?
BCFixed<1>, // isAutoClosure?
DefaultArgumentField, // default argument kind
BCBlob // default argument text
IdentifierIDField, // argument name
IdentifierIDField, // parameter name
DeclContextIDField, // context decl
ParamDeclSpecifierField, // specifier
TypeIDField, // interface type
BCFixed<1>, // isVariadic?
BCFixed<1>, // isAutoClosure?
DefaultArgumentField, // default argument kind
BCBlob // default argument text
>;

using FuncLayout = BCRecordLayout<
Expand Down
11 changes: 4 additions & 7 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,19 +968,16 @@ namespace {
}

switch (P->getSpecifier()) {
case VarDecl::Specifier::Let:
case ParamDecl::Specifier::Default:
/* nothing */
break;
case VarDecl::Specifier::Var:
OS << " mutable";
break;
case VarDecl::Specifier::InOut:
case ParamDecl::Specifier::InOut:
OS << " inout";
break;
case VarDecl::Specifier::Shared:
case ParamDecl::Specifier::Shared:
OS << " shared";
break;
case VarDecl::Specifier::Owned:
case ParamDecl::Specifier::Owned:
OS << " owned";
break;
}
Expand Down
12 changes: 3 additions & 9 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2500,17 +2500,11 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
|| Options.PrintParameterSpecifiers) {
// Map all non-let specifiers to 'var'. This is not correct, but
// SourceKit relies on this for info about parameter decls.
switch (decl->getSpecifier()) {
case VarDecl::Specifier::Let:
if (decl->isLet())
Printer << tok::kw_let;
break;
case VarDecl::Specifier::Var:
case VarDecl::Specifier::InOut:
case VarDecl::Specifier::Shared:
case VarDecl::Specifier::Owned:
else
Printer << tok::kw_var;
break;
}

Printer << " ";
}
}
Expand Down
21 changes: 5 additions & 16 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2448,23 +2448,12 @@ class Verifier : public ASTWalker {
void verifyChecked(VarDecl *var) {
PrettyStackTraceDecl debugStack("verifying VarDecl", var);

// Variables must have materializable type, unless they are parameters,
// in which case they must either have l-value type or be anonymous.
// Variables must have materializable type.
if (!var->getInterfaceType()->isMaterializable()) {
if (!isa<ParamDecl>(var)) {
Out << "VarDecl has non-materializable type: ";
var->getType().print(Out);
Out << "\n";
abort();
}

if (!var->isInOut() && var->hasName()) {
Out << "ParamDecl may only have non-materializable tuple type "
"when it is anonymous: ";
var->getType().print(Out);
Out << "\n";
abort();
}
Out << "VarDecl has non-materializable type: ";
var->getInterfaceType().print(Out);
Out << "\n";
abort();
}

// The fact that this is *directly* be a reference storage type
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/Builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ getBuiltinFunction(Identifier Id, ArrayRef<Type> argTypes, Type ResType,
SmallVector<ParamDecl*, 4> params;
for (Type argType : argTypes) {
auto PD = new (Context)
ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
ParamDecl(ParamDecl::Specifier::Default, SourceLoc(), SourceLoc(),
Identifier(), SourceLoc(), Identifier(), DC);
PD->setInterfaceType(argType);
PD->setValidationToChecked();
Expand Down Expand Up @@ -203,7 +203,7 @@ getBuiltinGenericFunction(Identifier Id,
for (unsigned i = 0, e = ArgParamTypes.size(); i < e; i++) {
auto paramIfaceType = ArgParamTypes[i].getPlainType();
auto specifier =
VarDecl::getParameterSpecifierForValueOwnership(
ParamDecl::getParameterSpecifierForValueOwnership(
ArgParamTypes[i].getParameterFlags().getValueOwnership());
auto PD = new (Context) ParamDecl(specifier,
SourceLoc(), SourceLoc(),
Expand Down
Loading