Skip to content

Commit 58e5402

Browse files
committed
[Dependency Scanning] Use size_t for array sizes and re-arrange array struct type fields to be consistent.
1 parent 295e4f4 commit 58e5402

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

include/swift-c/DependencyScan/DependencyScan.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ SWIFTSCAN_BEGIN_DECLS
4141
*/
4242
typedef struct {
4343
const void *data;
44-
unsigned length;
44+
size_t length;
4545
} swiftscan_string_ref_t;
4646

4747
typedef struct {
4848
swiftscan_string_ref_t *strings;
49-
unsigned count;
49+
size_t count;
5050
} swiftscan_string_set_t;
5151

5252
typedef enum {
@@ -70,8 +70,8 @@ typedef struct swiftscan_import_set_s *swiftscan_import_set_t;
7070

7171
/// Full Dependency Graph (Result)
7272
typedef struct {
73-
int count;
7473
swiftscan_dependency_info_t *modules;
74+
size_t count;
7575
} swiftscan_dependency_set_t;
7676

7777
//=== Batch Scan Input Specification --------------------------------------===//
@@ -80,13 +80,13 @@ typedef struct {
8080
typedef struct swiftscan_batch_scan_entry_s *swiftscan_batch_scan_entry_t;
8181

8282
typedef struct {
83-
int count;
8483
swiftscan_batch_scan_entry_t *modules;
84+
size_t count;
8585
} swiftscan_batch_scan_input_t;
8686

8787
typedef struct {
88-
int count;
8988
swiftscan_dependency_graph_t *results;
89+
size_t count;
9090
} swiftscan_batch_scan_result_t;
9191

9292
//=== Scanner Invocation Specification ------------------------------------===//

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static void writeJSON(llvm::raw_ostream &out,
495495
out << " \"modules\": [\n";
496496
SWIFT_DEFER { out << " ]\n"; };
497497
const auto module_set = fullDependencies->dependencies;
498-
for (int mi = 0; mi < module_set->count; ++mi) {
498+
for (size_t mi = 0; mi < module_set->count; ++mi) {
499499
const auto &moduleInfo = *module_set->modules[mi];
500500
auto &directDependencies = moduleInfo.direct_dependencies;
501501
// The module we are describing.
@@ -1186,18 +1186,15 @@ llvm::ErrorOr<swiftscan_dependency_graph_t>
11861186
swift::dependencies::performModuleScan(CompilerInstance &instance,
11871187
ModuleDependenciesCache &cache) {
11881188
ModuleDecl *mainModule = instance.getMainModule();
1189-
11901189
// First, identify the dependencies of the main module
11911190
auto mainDependencies = identifyMainModuleDependencies(instance);
1192-
11931191
// Add the main module.
11941192
StringRef mainModuleName = mainModule->getNameStr();
11951193
llvm::SetVector<ModuleDependencyID, std::vector<ModuleDependencyID>,
11961194
std::set<ModuleDependencyID>>
11971195
allModules;
11981196

11991197
allModules.insert({mainModuleName.str(), mainDependencies.getKind()});
1200-
12011198
cache.recordDependencies(mainModuleName, std::move(mainDependencies));
12021199
auto &ctx = instance.getASTContext();
12031200
auto ModuleCachePath = getModuleCachePathFromClang(

tools/libSwiftScan/libSwiftScan.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void swiftscan_dependency_info_dispose(swiftscan_dependency_info_t info) {
100100
}
101101

102102
void swiftscan_dependency_set_dispose(swiftscan_dependency_set_t *set) {
103-
for (int i = 0; i < set->count; ++i) {
103+
for (size_t i = 0; i < set->count; ++i) {
104104
swiftscan_dependency_info_dispose(set->modules[i]);
105105
}
106106
delete[] set->modules;
@@ -145,7 +145,7 @@ swiftscan_batch_scan_result_create(swiftscan_scanner_t scanner,
145145
Compilation.push_back(swiftscan_get_C_string(invocation->argv->strings[i]));
146146

147147
std::vector<BatchScanInput> BatchInput;
148-
for (int i = 0; i < batch_input->count; ++i) {
148+
for (size_t i = 0; i < batch_input->count; ++i) {
149149
swiftscan_batch_scan_entry_s *Entry = batch_input->modules[i];
150150
BatchInput.push_back({swiftscan_get_C_string(Entry->module_name),
151151
swiftscan_get_C_string(Entry->arguments),
@@ -441,7 +441,7 @@ void swiftscan_batch_scan_entry_dispose(swiftscan_batch_scan_entry_t entry) {
441441
}
442442

443443
void swiftscan_batch_scan_input_dispose(swiftscan_batch_scan_input_t *input) {
444-
for (int i = 0; i < input->count; ++i) {
444+
for (size_t i = 0; i < input->count; ++i) {
445445
swiftscan_batch_scan_entry_dispose(input->modules[i]);
446446
}
447447
delete[] input->modules;
@@ -450,7 +450,7 @@ void swiftscan_batch_scan_input_dispose(swiftscan_batch_scan_input_t *input) {
450450

451451
void swiftscan_batch_scan_result_dispose(
452452
swiftscan_batch_scan_result_t *result) {
453-
for (int i = 0; i < result->count; ++i) {
453+
for (size_t i = 0; i < result->count; ++i) {
454454
swiftscan_dependency_graph_dispose(result->results[i]);
455455
}
456456
delete[] result->results;

0 commit comments

Comments
 (0)