Skip to content

Commit 39a0735

Browse files
committed
[NFC] Fix formatting issues in dependency scanning code
Apply clang-format to code in 'ModuleDependencies.h', 'ModuleDependencies.cpp', 'ModuleDependencyScanner.cpp'
1 parent 1b1d91d commit 39a0735

File tree

3 files changed

+191
-182
lines changed

3 files changed

+191
-182
lines changed

include/swift/AST/ModuleDependencies.h

Lines changed: 59 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class JoinedArrayRefView {
104104
using iterator_category = std::forward_iterator_tag;
105105
using value_type = T;
106106
using difference_type = std::ptrdiff_t;
107-
using pointer = const T*;
108-
using reference = const T&;
107+
using pointer = const T *;
108+
using reference = const T &;
109109
Iterator(const JoinedArrayRefView *parent, size_t memberIndex,
110110
size_t elementIndex)
111111
: parentView(parent), collectionIndex(memberIndex),
@@ -136,7 +136,8 @@ class JoinedArrayRefView {
136136

137137
void checkAdvance() {
138138
while (collectionIndex < parentView->memberCollections.size() &&
139-
elementIndex >= parentView->memberCollections[collectionIndex].size()) {
139+
elementIndex >=
140+
parentView->memberCollections[collectionIndex].size()) {
140141
++collectionIndex;
141142
elementIndex = 0;
142143
}
@@ -147,7 +148,7 @@ class JoinedArrayRefView {
147148
Iterator end() const { return Iterator(this, memberCollections.size(), 0); }
148149

149150
template <typename... Arrays>
150-
JoinedArrayRefView(Arrays ...arrs) {
151+
JoinedArrayRefView(Arrays... arrs) {
151152
memberCollections.reserve(sizeof...(arrs));
152153
(memberCollections.push_back(arrs), ...);
153154
}
@@ -203,9 +204,9 @@ struct ScannerImportStatementInfo {
203204
: importIdentifier(importIdentifier), importLocations({location}),
204205
isExported(isExported), accessLevel(accessLevel) {}
205206

206-
ScannerImportStatementInfo(std::string importIdentifier, bool isExported,
207-
AccessLevel accessLevel,
208-
SmallVector<ImportDiagnosticLocationInfo, 4> locations)
207+
ScannerImportStatementInfo(
208+
std::string importIdentifier, bool isExported, AccessLevel accessLevel,
209+
SmallVector<ImportDiagnosticLocationInfo, 4> locations)
209210
: importIdentifier(importIdentifier), importLocations(locations),
210211
isExported(isExported), accessLevel(accessLevel) {}
211212

@@ -288,10 +289,9 @@ class ModuleDependencyInfoStorageBase {
288289

289290
struct CommonSwiftTextualModuleDependencyDetails {
290291
CommonSwiftTextualModuleDependencyDetails(
291-
ArrayRef<StringRef> buildCommandLine,
292-
StringRef CASFileSystemRootID)
293-
: bridgingHeaderFile(std::nullopt),
294-
bridgingSourceFiles(), bridgingModuleDependencies(),
292+
ArrayRef<StringRef> buildCommandLine, StringRef CASFileSystemRootID)
293+
: bridgingHeaderFile(std::nullopt), bridgingSourceFiles(),
294+
bridgingModuleDependencies(),
295295
buildCommandLine(buildCommandLine.begin(), buildCommandLine.end()),
296296
CASFileSystemRootID(CASFileSystemRootID) {}
297297

@@ -407,7 +407,8 @@ class SwiftSourceModuleDependenciesStorage
407407
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
408408
ArrayRef<StringRef> bridgingHeaderBuildCommandLine)
409409
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftSource,
410-
moduleImports, optionalModuleImports, {}),
410+
moduleImports, optionalModuleImports,
411+
{}),
411412
textualModuleDetails(buildCommandLine, RootID),
412413
testableImports(llvm::StringSet<>()),
413414
bridgingHeaderBuildCommandLine(bridgingHeaderBuildCommandLine.begin(),
@@ -417,7 +418,6 @@ class SwiftSourceModuleDependenciesStorage
417418
return new SwiftSourceModuleDependenciesStorage(*this);
418419
}
419420

420-
421421
static bool classof(const ModuleDependencyInfoStorageBase *base) {
422422
return base->dependencyKind == ModuleDependencyKind::SwiftSource;
423423
}
@@ -464,9 +464,8 @@ class SwiftBinaryModuleDependencyStorage
464464
compiledModulePath(compiledModulePath), moduleDocPath(moduleDocPath),
465465
sourceInfoPath(sourceInfoPath), headerImport(headerImport),
466466
definingModuleInterfacePath(definingModuleInterface),
467-
serializedSearchPaths(serializedSearchPaths),
468-
isFramework(isFramework), isStatic(isStatic),
469-
userModuleVersion(userModuleVersion) {}
467+
serializedSearchPaths(serializedSearchPaths), isFramework(isFramework),
468+
isStatic(isStatic), userModuleVersion(userModuleVersion) {}
470469

471470
ModuleDependencyInfoStorageBase *clone() const override {
472471
return new SwiftBinaryModuleDependencyStorage(*this);
@@ -561,8 +560,7 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
561560
StringRef CASFileSystemRootID,
562561
StringRef clangIncludeTreeRoot,
563562
StringRef moduleCacheKey, bool IsSystem)
564-
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::Clang,
565-
{}, {},
563+
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::Clang, {}, {},
566564
linkLibraries, moduleCacheKey),
567565
pcmOutputPath(pcmOutputPath), mappedPCMPath(mappedPCMPath),
568566
moduleMapFile(moduleMapFile), contextHash(contextHash),
@@ -642,31 +640,28 @@ class ModuleDependencyInfo {
642640
std::make_unique<SwiftBinaryModuleDependencyStorage>(
643641
compiledModulePath, moduleDocPath, sourceInfoPath, moduleImports,
644642
optionalModuleImports, linkLibraries, serializedSearchPaths,
645-
headerImport, definingModuleInterface,isFramework, isStatic,
643+
headerImport, definingModuleInterface, isFramework, isStatic,
646644
moduleCacheKey, userModuleVer));
647645
}
648646

649647
/// Describe the main Swift module.
650-
static ModuleDependencyInfo
651-
forSwiftSourceModule(const std::string &CASFileSystemRootID,
652-
ArrayRef<StringRef> buildCommands,
653-
ArrayRef<ScannerImportStatementInfo> moduleImports,
654-
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
655-
ArrayRef<StringRef> bridgingHeaderBuildCommands) {
648+
static ModuleDependencyInfo forSwiftSourceModule(
649+
const std::string &CASFileSystemRootID, ArrayRef<StringRef> buildCommands,
650+
ArrayRef<ScannerImportStatementInfo> moduleImports,
651+
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
652+
ArrayRef<StringRef> bridgingHeaderBuildCommands) {
656653
return ModuleDependencyInfo(
657654
std::make_unique<SwiftSourceModuleDependenciesStorage>(
658655
CASFileSystemRootID, buildCommands, moduleImports,
659656
optionalModuleImports, bridgingHeaderBuildCommands));
660657
}
661658

662-
static ModuleDependencyInfo
663-
forSwiftSourceModule() {
659+
static ModuleDependencyInfo forSwiftSourceModule() {
664660
return ModuleDependencyInfo(
665661
std::make_unique<SwiftSourceModuleDependenciesStorage>(
666-
StringRef(), ArrayRef<StringRef>(),
667-
ArrayRef<ScannerImportStatementInfo>(),
668-
ArrayRef<ScannerImportStatementInfo>(),
669-
ArrayRef<StringRef>()));
662+
StringRef(), ArrayRef<StringRef>(),
663+
ArrayRef<ScannerImportStatementInfo>(),
664+
ArrayRef<ScannerImportStatementInfo>(), ArrayRef<StringRef>()));
670665
}
671666

672667
/// Describe the module dependencies for a Clang module that can be
@@ -693,16 +688,14 @@ class ModuleDependencyInfo {
693688
return storage->optionalModuleImports;
694689
}
695690

696-
std::string getModuleCacheKey() const {
697-
return storage->moduleCacheKey;
698-
}
691+
std::string getModuleCacheKey() const { return storage->moduleCacheKey; }
699692

700693
void updateModuleCacheKey(const std::string &key) {
701694
storage->moduleCacheKey = key;
702695
}
703696

704-
void
705-
setImportedSwiftDependencies(const ArrayRef<ModuleDependencyID> dependencyIDs) {
697+
void setImportedSwiftDependencies(
698+
const ArrayRef<ModuleDependencyID> dependencyIDs) {
706699
assert(isSwiftModule());
707700
storage->importedSwiftModules.assign(dependencyIDs.begin(),
708701
dependencyIDs.end());
@@ -711,8 +704,8 @@ class ModuleDependencyInfo {
711704
return storage->importedSwiftModules;
712705
}
713706

714-
void
715-
setImportedClangDependencies(const ArrayRef<ModuleDependencyID> dependencyIDs) {
707+
void setImportedClangDependencies(
708+
const ArrayRef<ModuleDependencyID> dependencyIDs) {
716709
storage->importedClangModules.assign(dependencyIDs.begin(),
717710
dependencyIDs.end());
718711
}
@@ -727,15 +720,15 @@ class ModuleDependencyInfo {
727720
case swift::ModuleDependencyKind::SwiftInterface: {
728721
auto swiftInterfaceStorage =
729722
cast<SwiftInterfaceModuleDependenciesStorage>(storage.get());
730-
swiftInterfaceStorage->textualModuleDetails.bridgingModuleDependencies.assign(dependencyIDs.begin(),
731-
dependencyIDs.end());
723+
swiftInterfaceStorage->textualModuleDetails.bridgingModuleDependencies
724+
.assign(dependencyIDs.begin(), dependencyIDs.end());
732725
break;
733726
}
734727
case swift::ModuleDependencyKind::SwiftSource: {
735728
auto swiftSourceStorage =
736729
cast<SwiftSourceModuleDependenciesStorage>(storage.get());
737-
swiftSourceStorage->textualModuleDetails.bridgingModuleDependencies.assign(dependencyIDs.begin(),
738-
dependencyIDs.end());
730+
swiftSourceStorage->textualModuleDetails.bridgingModuleDependencies
731+
.assign(dependencyIDs.begin(), dependencyIDs.end());
739732
break;
740733
}
741734
case swift::ModuleDependencyKind::SwiftBinary: {
@@ -755,12 +748,14 @@ class ModuleDependencyInfo {
755748
case swift::ModuleDependencyKind::SwiftInterface: {
756749
auto swiftInterfaceStorage =
757750
cast<SwiftInterfaceModuleDependenciesStorage>(storage.get());
758-
return swiftInterfaceStorage->textualModuleDetails.bridgingModuleDependencies;
751+
return swiftInterfaceStorage->textualModuleDetails
752+
.bridgingModuleDependencies;
759753
}
760754
case swift::ModuleDependencyKind::SwiftSource: {
761755
auto swiftSourceStorage =
762756
cast<SwiftSourceModuleDependenciesStorage>(storage.get());
763-
return swiftSourceStorage->textualModuleDetails.bridgingModuleDependencies;
757+
return swiftSourceStorage->textualModuleDetails
758+
.bridgingModuleDependencies;
764759
}
765760
case swift::ModuleDependencyKind::SwiftBinary: {
766761
auto swiftBinaryStorage =
@@ -772,8 +767,8 @@ class ModuleDependencyInfo {
772767
}
773768
}
774769

775-
void
776-
setSwiftOverlayDependencies(const ArrayRef<ModuleDependencyID> dependencyIDs) {
770+
void setSwiftOverlayDependencies(
771+
const ArrayRef<ModuleDependencyID> dependencyIDs) {
777772
assert(isSwiftModule());
778773
storage->swiftOverlayDependencies.assign(dependencyIDs.begin(),
779774
dependencyIDs.end());
@@ -796,8 +791,7 @@ class ModuleDependencyInfo {
796791
return storage->linkLibraries;
797792
}
798793

799-
void
800-
setLinkLibraries(const ArrayRef<LinkLibrary> linkLibraries) {
794+
void setLinkLibraries(const ArrayRef<LinkLibrary> linkLibraries) {
801795
storage->linkLibraries.assign(linkLibraries.begin(), linkLibraries.end());
802796
}
803797

@@ -894,8 +888,7 @@ class ModuleDependencyInfo {
894888

895889
void
896890
addVisibleClangModules(const std::vector<std::string> &moduleNames) const {
897-
storage->visibleClangModules.insert(moduleNames.begin(),
898-
moduleNames.end());
891+
storage->visibleClangModules.insert(moduleNames.begin(), moduleNames.end());
899892
}
900893

901894
/// Whether explicit input paths of all the module dependencies
@@ -1067,7 +1060,8 @@ class ModuleDependenciesCache {
10671060
/// Discovered dependencies
10681061
ModuleDependenciesKindMap ModuleDependenciesMap;
10691062
/// Set containing all of the Clang modules that have already been seen.
1070-
llvm::DenseSet<clang::tooling::dependencies::ModuleID> alreadySeenClangModules;
1063+
llvm::DenseSet<clang::tooling::dependencies::ModuleID>
1064+
alreadySeenClangModules;
10711065
/// Name of the module under scan
10721066
std::string mainScanModuleName;
10731067
/// The context hash of the current scanning invocation
@@ -1093,7 +1087,8 @@ class ModuleDependenciesCache {
10931087
/// Retrieve the dependencies map that corresponds to the given dependency
10941088
/// kind.
10951089
ModuleNameToDependencyMap &getDependenciesMap(ModuleDependencyKind kind);
1096-
const ModuleNameToDependencyMap &getDependenciesMap(ModuleDependencyKind kind) const;
1090+
const ModuleNameToDependencyMap &
1091+
getDependenciesMap(ModuleDependencyKind kind) const;
10971092

10981093
/// Whether we have cached dependency information for the given module.
10991094
bool hasDependency(const ModuleDependencyID &moduleID) const;
@@ -1131,7 +1126,8 @@ class ModuleDependenciesCache {
11311126
/// Query all directly-imported Clang dependencies
11321127
llvm::ArrayRef<ModuleDependencyID>
11331128
getImportedClangDependencies(const ModuleDependencyID &moduleID) const;
1134-
/// Query all Clang module dependencies of this module's imported (bridging) header
1129+
/// Query all Clang module dependencies of this module's imported (bridging)
1130+
/// header
11351131
llvm::ArrayRef<ModuleDependencyID>
11361132
getHeaderClangDependencies(const ModuleDependencyID &moduleID) const;
11371133
/// Query Swift overlay dependencies
@@ -1141,8 +1137,7 @@ class ModuleDependenciesCache {
11411137
llvm::ArrayRef<ModuleDependencyID>
11421138
getCrossImportOverlayDependencies(const ModuleDependencyID &moduleID) const;
11431139
/// Query all visible Clang modules for a given Swift dependency
1144-
llvm::StringSet<>&
1145-
getVisibleClangModules(ModuleDependencyID moduleID) const;
1140+
llvm::StringSet<> &getVisibleClangModules(ModuleDependencyID moduleID) const;
11461141

11471142
/// Look for module dependencies for a module with the given ID
11481143
///
@@ -1180,20 +1175,20 @@ class ModuleDependenciesCache {
11801175
/// Update stored dependencies for the given module.
11811176
void updateDependency(ModuleDependencyID moduleID,
11821177
ModuleDependencyInfo dependencyInfo);
1183-
1178+
11841179
/// Remove a given dependency info from the cache.
11851180
void removeDependency(ModuleDependencyID moduleID);
11861181

11871182
/// Resolve this module's set of directly-imported Swift module
11881183
/// dependencies
1189-
void
1190-
setImportedSwiftDependencies(ModuleDependencyID moduleID,
1191-
const ArrayRef<ModuleDependencyID> dependencyIDs);
1184+
void setImportedSwiftDependencies(
1185+
ModuleDependencyID moduleID,
1186+
const ArrayRef<ModuleDependencyID> dependencyIDs);
11921187
/// Resolve this module's set of directly-imported Clang module
11931188
/// dependencies
1194-
void
1195-
setImportedClangDependencies(ModuleDependencyID moduleID,
1196-
const ArrayRef<ModuleDependencyID> dependencyIDs);
1189+
void setImportedClangDependencies(
1190+
ModuleDependencyID moduleID,
1191+
const ArrayRef<ModuleDependencyID> dependencyIDs);
11971192
/// Resolve this module's set of Swift module dependencies
11981193
/// that are Swift overlays of Clang module dependencies.
11991194
void
@@ -1209,9 +1204,8 @@ class ModuleDependenciesCache {
12091204
ModuleDependencyID moduleID,
12101205
const ModuleDependencyIDCollectionView dependencyIDs);
12111206
/// Add to this module's set of visible Clang modules
1212-
void
1213-
addVisibleClangModules(ModuleDependencyID moduleID,
1214-
const std::vector<std::string> &moduleNames);
1207+
void addVisibleClangModules(ModuleDependencyID moduleID,
1208+
const std::vector<std::string> &moduleNames);
12151209

12161210
StringRef getMainModuleName() const { return mainScanModuleName; }
12171211

0 commit comments

Comments
 (0)