Skip to content

Commit ea6a2dc

Browse files
committed
SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case 2. Updated Located constuctor 3. Formatted lines with more than 80 symbols
1 parent 5fdea64 commit ea6a2dc

33 files changed

+129
-128
lines changed

include/swift/AST/Decl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,9 +1578,9 @@ class ImportDecl final : public Decl,
15781578
}
15791579

15801580
SourceLoc getStartLoc() const { return ImportLoc; }
1581-
SourceLoc getLocFromSource() const { return getFullAccessPath().front().loc; }
1581+
SourceLoc getLocFromSource() const { return getFullAccessPath().front().Loc; }
15821582
SourceRange getSourceRange() const {
1583-
return SourceRange(ImportLoc, getFullAccessPath().back().loc);
1583+
return SourceRange(ImportLoc, getFullAccessPath().back().Loc);
15841584
}
15851585
SourceLoc getKindLoc() const { return KindLoc; }
15861586

include/swift/AST/Module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class ModuleDecl : public DeclContext, public TypeDecl {
139139
assert(AccessPath.size() <= 1 && "can only refer to top-level decls");
140140

141141
return AccessPath.empty()
142-
|| DeclName(AccessPath.front().item).matchesRef(Name);
142+
|| DeclName(AccessPath.front().Item).matchesRef(Name);
143143
}
144144

145145
/// Arbitrarily orders ImportedModule records, for inclusion in sets and such.

include/swift/AST/TypeRepr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,12 +746,12 @@ class TupleTypeRepr final : public TypeRepr,
746746

747747
SourceLoc getEllipsisLoc() const {
748748
return hasEllipsis() ?
749-
getTrailingObjects<SourceLocAndIdx>()[0].loc : SourceLoc();
749+
getTrailingObjects<SourceLocAndIdx>()[0].Loc : SourceLoc();
750750
}
751751

752752
unsigned getEllipsisIndex() const {
753753
return hasEllipsis() ?
754-
getTrailingObjects<SourceLocAndIdx>()[0].item :
754+
getTrailingObjects<SourceLocAndIdx>()[0].Item :
755755
Bits.TupleTypeRepr.NumElements;
756756
}
757757

include/swift/Basic/Located.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ template<typename T>
3232
struct Located {
3333

3434
/// The main item whose source location is being tracked.
35-
T item;
35+
T Item;
3636

3737
/// The original source location from which the item was parsed.
38-
SourceLoc loc;
38+
SourceLoc Loc;
3939

40-
Located() {}
40+
Located(): Item(), Loc() {}
4141

42-
Located(T item, SourceLoc loc): item(item), loc(loc) {}
42+
Located(T Item, SourceLoc loc): Item(Item), Loc(loc) {}
4343

4444
template<typename U>
4545
friend bool operator ==(const Located<U>& lhs, const Located<U>& rhs) {
46-
return lhs.item == rhs.item && lhs.loc == rhs.loc;
46+
return lhs.Item == rhs.Item && lhs.Loc == rhs.Loc;
4747
}
4848
};
4949
}

lib/AST/ASTContext.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ ModuleDecl *ASTContext::getLoadedModule(
14731473

14741474
// TODO: Swift submodules.
14751475
if (ModulePath.size() == 1) {
1476-
return getLoadedModule(ModulePath[0].item);
1476+
return getLoadedModule(ModulePath[0].Item);
14771477
}
14781478
return nullptr;
14791479
}
@@ -1729,7 +1729,7 @@ bool ASTContext::canImportModule(Located<Identifier> ModulePath) {
17291729
return true;
17301730

17311731
// If we've failed loading this module before, don't look for it again.
1732-
if (FailedModuleImportNames.count(ModulePath.item))
1732+
if (FailedModuleImportNames.count(ModulePath.Item))
17331733
return false;
17341734

17351735
// Otherwise, ask the module loaders.
@@ -1739,7 +1739,7 @@ bool ASTContext::canImportModule(Located<Identifier> ModulePath) {
17391739
}
17401740
}
17411741

1742-
FailedModuleImportNames.insert(ModulePath.item);
1742+
FailedModuleImportNames.insert(ModulePath.Item);
17431743
return false;
17441744
}
17451745

@@ -1752,7 +1752,7 @@ ASTContext::getModule(ArrayRef<Located<Identifier>> ModulePath) {
17521752

17531753
auto moduleID = ModulePath[0];
17541754
for (auto &importer : getImpl().ModuleLoaders) {
1755-
if (ModuleDecl *M = importer->loadModule(moduleID.loc, ModulePath)) {
1755+
if (ModuleDecl *M = importer->loadModule(moduleID.Loc, ModulePath)) {
17561756
return M;
17571757
}
17581758
}

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ namespace {
589589
OS << " '";
590590
interleave(ID->getFullAccessPath(),
591591
[&](const ImportDecl::AccessPathElement &Elem) {
592-
OS << Elem.item;
592+
OS << Elem.Item;
593593
},
594594
[&] { OS << '.'; });
595595
OS << "')";

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,10 +2097,10 @@ void PrintAST::visitImportDecl(ImportDecl *decl) {
20972097
interleave(decl->getFullAccessPath(),
20982098
[&](const ImportDecl::AccessPathElement &Elem) {
20992099
if (!Mods.empty()) {
2100-
Printer.printModuleRef(Mods.front(), Elem.item);
2100+
Printer.printModuleRef(Mods.front(), Elem.Item);
21012101
Mods = Mods.slice(1);
21022102
} else {
2103-
Printer << Elem.item.str();
2103+
Printer << Elem.Item.str();
21042104
}
21052105
},
21062106
[&] { Printer << "."; });

lib/AST/ConformanceLookupTable.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
200200
bool anyObject = false;
201201
for (const auto &found :
202202
getDirectlyInheritedNominalTypeDecls(next, anyObject)) {
203-
if (auto proto = dyn_cast<ProtocolDecl>(found.item))
204-
protocols.push_back({proto, found.loc});
203+
if (auto proto = dyn_cast<ProtocolDecl>(found.Item))
204+
protocols.push_back({proto, found.Loc});
205205
}
206206
}
207207

@@ -281,7 +281,7 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
281281
// its inherited protocols directly.
282282
auto source = ConformanceSource::forExplicit(ext);
283283
for (auto locAndProto : protos)
284-
addProtocol(locAndProto.item, locAndProto.loc, source);
284+
addProtocol(locAndProto.Item, locAndProto.Loc, source);
285285
});
286286
break;
287287

@@ -470,8 +470,8 @@ void ConformanceLookupTable::addInheritedProtocols(
470470
bool anyObject = false;
471471
for (const auto &found :
472472
getDirectlyInheritedNominalTypeDecls(decl, anyObject)) {
473-
if (auto proto = dyn_cast<ProtocolDecl>(found.item))
474-
addProtocol(proto, found.loc, source);
473+
if (auto proto = dyn_cast<ProtocolDecl>(found.Item))
474+
addProtocol(proto, found.Loc, source);
475475
}
476476
}
477477

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4538,7 +4538,7 @@ ProtocolDecl::getInheritedProtocolsSlow() {
45384538
for (const auto found :
45394539
getDirectlyInheritedNominalTypeDecls(
45404540
const_cast<ProtocolDecl *>(this), anyObject)) {
4541-
if (auto proto = dyn_cast<ProtocolDecl>(found.item)) {
4541+
if (auto proto = dyn_cast<ProtocolDecl>(found.Item)) {
45424542
if (known.insert(proto).second)
45434543
result.push_back(proto);
45444544
}

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4060,8 +4060,8 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
40604060
assocTypeDecl->getFullName(),
40614061
inheritedFromProto->getDeclaredInterfaceType())
40624062
.fixItInsertAfter(
4063-
fixItWhere.loc,
4064-
getAssociatedTypeReqs(assocTypeDecl, fixItWhere.item))
4063+
fixItWhere.Loc,
4064+
getAssociatedTypeReqs(assocTypeDecl, fixItWhere.Item))
40654065
.fixItRemove(assocTypeDecl->getSourceRange());
40664066

40674067
Diags.diagnose(inheritedAssocTypeDecl, diag::decl_declared_here,
@@ -4136,8 +4136,8 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
41364136
diag::typealias_override_associated_type,
41374137
name,
41384138
inheritedFromProto->getDeclaredInterfaceType())
4139-
.fixItInsertAfter(fixItWhere.loc,
4140-
getConcreteTypeReq(type, fixItWhere.item))
4139+
.fixItInsertAfter(fixItWhere.Loc,
4140+
getConcreteTypeReq(type, fixItWhere.Item))
41414141
.fixItRemove(type->getSourceRange());
41424142
Diags.diagnose(inheritedAssocTypeDecl, diag::decl_declared_here,
41434143
inheritedAssocTypeDecl->getFullName());

0 commit comments

Comments
 (0)