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());

lib/AST/ImportCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void ImportSet::Profile(
5757
for (auto import : topLevelImports) {
5858
ID.AddInteger(import.first.size());
5959
for (auto accessPathElt : import.first) {
60-
ID.AddPointer(accessPathElt.item.getAsOpaquePointer());
60+
ID.AddPointer(accessPathElt.Item.getAsOpaquePointer());
6161
}
6262
ID.AddPointer(import.second);
6363
}

lib/AST/Module.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void SourceLookupCache::lookupVisibleDecls(AccessPathTy AccessPath,
303303
assert(AccessPath.size() <= 1 && "can only refer to top-level decls");
304304

305305
if (!AccessPath.empty()) {
306-
auto I = TopLevelValues.find(AccessPath.front().item);
306+
auto I = TopLevelValues.find(AccessPath.front().Item);
307307
if (I == TopLevelValues.end()) return;
308308

309309
for (auto vd : I->second)
@@ -335,7 +335,7 @@ void SourceLookupCache::lookupClassMembers(AccessPathTy accessPath,
335335

336336
for (ValueDecl *vd : member.second) {
337337
auto *nominal = vd->getDeclContext()->getSelfNominalTypeDecl();
338-
if (nominal && nominal->getName() == accessPath.front().item)
338+
if (nominal && nominal->getName() == accessPath.front().Item)
339339
consumer.foundDecl(vd, DeclVisibilityKind::DynamicLookup,
340340
DynamicLookupInfo::AnyObject);
341341
}
@@ -367,7 +367,7 @@ void SourceLookupCache::lookupClassMember(AccessPathTy accessPath,
367367
if (!accessPath.empty()) {
368368
for (ValueDecl *vd : iter->second) {
369369
auto *nominal = vd->getDeclContext()->getSelfNominalTypeDecl();
370-
if (nominal && nominal->getName() == accessPath.front().item)
370+
if (nominal && nominal->getName() == accessPath.front().Item)
371371
results.push_back(vd);
372372
}
373373
return;
@@ -1187,7 +1187,7 @@ bool ModuleDecl::isSameAccessPath(AccessPathTy lhs, AccessPathTy rhs) {
11871187
return std::equal(lhs.begin(), lhs.end(), rhs.begin(),
11881188
[](const AccessPathElem &lElem,
11891189
const AccessPathElem &rElem) {
1190-
return lElem.item == rElem.item;
1190+
return lElem.Item == rElem.Item;
11911191
});
11921192
}
11931193

@@ -1256,7 +1256,7 @@ ModuleDecl::removeDuplicateImports(SmallVectorImpl<ImportedModule> &imports) {
12561256
rhs.first.begin(), rhs.first.end(),
12571257
[](const AccessPathElem &lElem,
12581258
const AccessPathElem &rElem) {
1259-
return lElem.item.str() < rElem.item.str();
1259+
return lElem.Item.str() < rElem.Item.str();
12601260
});
12611261
});
12621262
auto last = std::unique(imports.begin(), imports.end(),

lib/ClangImporter/ClangImporter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,13 +1625,13 @@ void ClangImporter::collectSubModuleNames(
16251625

16261626
// Look up the top-level module first.
16271627
clang::Module *clangModule = clangHeaderSearch.lookupModule(
1628-
path.front().item.str(), /*AllowSearch=*/true,
1628+
path.front().Item.str(), /*AllowSearch=*/true,
16291629
/*AllowExtraModuleMapSearch=*/true);
16301630
if (!clangModule)
16311631
return;
16321632
clang::Module *submodule = clangModule;
16331633
for (auto component : path.slice(1)) {
1634-
submodule = submodule->findSubmodule(component.item.str());
1634+
submodule = submodule->findSubmodule(component.Item.str());
16351635
if (!submodule)
16361636
return;
16371637
}
@@ -1648,7 +1648,7 @@ bool ClangImporter::canImportModule(Located<Identifier> moduleID) {
16481648
// FIXME: This only works with top-level modules.
16491649
auto &clangHeaderSearch = Impl.getClangPreprocessor().getHeaderSearchInfo();
16501650
clang::Module *clangModule =
1651-
clangHeaderSearch.lookupModule(moduleID.item.str(), /*AllowSearch=*/true,
1651+
clangHeaderSearch.lookupModule(moduleID.Item.str(), /*AllowSearch=*/true,
16521652
/*AllowExtraModuleMapSearch=*/true);
16531653
if (!clangModule) {
16541654
return false;
@@ -1668,7 +1668,7 @@ ModuleDecl *ClangImporter::Implementation::loadModuleClang(
16681668

16691669
// Look up the top-level module first, to see if it exists at all.
16701670
clang::Module *clangModule = clangHeaderSearch.lookupModule(
1671-
path.front().item.str(), /*AllowSearch=*/true,
1671+
path.front().Item.str(), /*AllowSearch=*/true,
16721672
/*AllowExtraModuleMapSearch=*/true);
16731673
if (!clangModule)
16741674
return nullptr;
@@ -1677,8 +1677,8 @@ ModuleDecl *ClangImporter::Implementation::loadModuleClang(
16771677
SmallVector<std::pair<clang::IdentifierInfo *, clang::SourceLocation>, 4>
16781678
clangPath;
16791679
for (auto component : path) {
1680-
clangPath.push_back({&clangContext.Idents.get(component.item.str()),
1681-
exportSourceLoc(component.loc)});
1680+
clangPath.push_back({&clangContext.Idents.get(component.Item.str()),
1681+
exportSourceLoc(component.Loc)});
16821682
}
16831683

16841684
auto &rawDiagClient = Instance->getDiagnosticClient();
@@ -1728,13 +1728,13 @@ ModuleDecl *ClangImporter::Implementation::loadModuleClang(
17281728
// Verify that the submodule exists.
17291729
clang::Module *submodule = clangModule;
17301730
for (auto &component : path.slice(1)) {
1731-
submodule = submodule->findSubmodule(component.item.str());
1731+
submodule = submodule->findSubmodule(component.Item.str());
17321732

17331733
// Special case: a submodule named "Foo.Private" can be moved to a top-level
17341734
// module named "Foo_Private". Clang has special support for this.
17351735
// We're limiting this to just submodules named "Private" because this will
17361736
// put the Clang AST in a fatal error state if it /doesn't/ exist.
1737-
if (!submodule && component.item.str() == "Private" &&
1737+
if (!submodule && component.Item.str() == "Private" &&
17381738
(&component) == (&path[1])) {
17391739
submodule = loadModule(llvm::makeArrayRef(clangPath).slice(0, 2), false);
17401740
}

lib/ClangImporter/DWARFImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ ModuleDecl *ClangImporter::Implementation::loadModuleDWARF(
105105
return nullptr;
106106

107107
// FIXME: Implement submodule support!
108-
Identifier name = path[0].item;
108+
Identifier name = path[0].Item;
109109
auto it = DWARFModuleUnits.find(name);
110110
if (it != DWARFModuleUnits.end())
111111
return it->second->getParentModule();

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5457,7 +5457,7 @@ namespace {
54575457
bool anyObject = false;
54585458
for (const auto &found :
54595459
getDirectlyInheritedNominalTypeDecls(decl, anyObject)) {
5460-
if (auto protoDecl = dyn_cast<ProtocolDecl>(found.item))
5460+
if (auto protoDecl = dyn_cast<ProtocolDecl>(found.Item))
54615461
if (protoDecl == proto || protoDecl->inheritsFrom(proto))
54625462
return true;
54635463
}

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,10 +1020,10 @@ std::error_code ModuleInterfaceLoader::findModuleFilesInDirectory(
10201020
}
10211021

10221022
// Create an instance of the Impl to do the heavy lifting.
1023-
auto ModuleName = ModuleID.item.str();
1023+
auto ModuleName = ModuleID.Item.str();
10241024
ModuleInterfaceLoaderImpl Impl(
10251025
Ctx, ModPath, InPath, ModuleName,
1026-
CacheDir, PrebuiltCacheDir, ModuleID.loc,
1026+
CacheDir, PrebuiltCacheDir, ModuleID.Loc,
10271027
RemarkOnRebuildFromInterface, dependencyTracker,
10281028
llvm::is_contained(PreferInterfaceForModules,
10291029
ModuleName) ?

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void diagnoseScopedImports(DiagnosticEngine &diags,
4949
for (const ModuleDecl::ImportedModule &importPair : imports) {
5050
if (importPair.first.empty())
5151
continue;
52-
diags.diagnose(importPair.first.front().loc,
52+
diags.diagnose(importPair.first.front().Loc,
5353
diag::module_interface_scoped_import_unsupported);
5454
}
5555
}
@@ -119,7 +119,7 @@ static void printImports(raw_ostream &out, ModuleDecl *M) {
119119
if (!import.first.empty()) {
120120
out << "/*";
121121
for (const auto &accessPathElem : import.first)
122-
out << "." << accessPathElem.item;
122+
out << "." << accessPathElem.Item;
123123
out << "*/";
124124
}
125125

lib/FrontendTool/ImportedModules.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bool swift::emitImportedModules(ASTContext &Context, ModuleDecl *mainModule,
6868

6969
auto accessPath = ID->getModulePath();
7070
// only the top-level name is needed (i.e. A in A.B.C)
71-
Modules.insert(accessPath[0].item.str());
71+
Modules.insert(accessPath[0].Item.str());
7272
}
7373

7474
// And now look in the C code we're possibly using.
@@ -98,7 +98,8 @@ bool swift::emitImportedModules(ASTContext &Context, ModuleDecl *mainModule,
9898
}
9999

100100
if (opts.ImportUnderlyingModule) {
101-
auto underlyingModule = clangImporter->loadModule(SourceLoc(), { Located<Identifier>(mainModule->getName(), SourceLoc()) });
101+
auto underlyingModule = clangImporter->loadModule(SourceLoc(),
102+
{ Located<Identifier>(mainModule->getName(), SourceLoc()) });
102103
if (!underlyingModule) {
103104
Context.Diags.diagnose(SourceLoc(),
104105
diag::error_underlying_module_not_found,

lib/IDE/CodeCompletion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4727,7 +4727,7 @@ void CodeCompletionCallbacksImpl::completeImportDecl(
47274727
std::vector<Located<Identifier>> &Path) {
47284728
Kind = CompletionKind::Import;
47294729
CurDeclContext = P.CurDeclContext;
4730-
DotLoc = Path.empty() ? SourceLoc() : Path.back().loc;
4730+
DotLoc = Path.empty() ? SourceLoc() : Path.back().Loc;
47314731
if (DotLoc.isInvalid())
47324732
return;
47334733
auto Importer = static_cast<ClangImporter *>(CurDeclContext->getASTContext().
@@ -5573,7 +5573,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
55735573

55745574
std::vector<std::string> AccessPath;
55755575
for (auto Piece : Path) {
5576-
AccessPath.push_back(Piece.item.str());
5576+
AccessPath.push_back(Piece.Item.str());
55775577
}
55785578

55795579
StringRef ModuleFilename = TheModule->getModuleFilename();

lib/IDE/ModuleInterfacePrinting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void swift::ide::printSubmoduleInterface(
448448
auto RHSPath = RHS->getFullAccessPath();
449449
for (unsigned i = 0, e = std::min(LHSPath.size(), RHSPath.size()); i != e;
450450
i++) {
451-
if (int Ret = LHSPath[i].item.str().compare(RHSPath[i].item.str()))
451+
if (int Ret = LHSPath[i].Item.str().compare(RHSPath[i].Item.str()))
452452
return Ret < 0;
453453
}
454454
return false;

0 commit comments

Comments
 (0)