Skip to content

Commit d1cc689

Browse files
committed
[Dependency Scanning] Fix the DependencyScan unit test harness to reflect C API changes.
1 parent 5f49c9f commit d1cc689

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "swift/Frontend/FrontendOptions.h"
3030
#include "swift/Frontend/ModuleInterfaceLoader.h"
3131
#include "swift/Strings.h"
32-
#include "clang-c/CXString.h"
3332
#include "clang/Basic/Module.h"
3433
#include "llvm/ADT/SetVector.h"
3534
#include "llvm/ADT/StringMap.h"
@@ -823,11 +822,15 @@ generateFullDependencyGraph(CompilerInstance &instance,
823822
return details;
824823
};
825824

826-
auto &moduleInfo = *dependencySet->modules[i];
827-
moduleInfo.module_name =
828-
create_dup(createEncodedModuleKindAndName(module).c_str());
829-
moduleInfo.module_path = create_dup(modulePath.c_str());
830-
moduleInfo.source_files = create_set(sourceFiles);
825+
swiftscan_dependency_info_s *moduleInfo = new swiftscan_dependency_info_s;
826+
dependencySet->modules[i] = moduleInfo;
827+
828+
std::string encodedModuleName = createEncodedModuleKindAndName(module);
829+
auto ttt = create_dup(encodedModuleName.c_str());
830+
moduleInfo->module_name = ttt;
831+
moduleInfo->module_path = create_dup(modulePath.c_str());
832+
moduleInfo->source_files = create_set(sourceFiles);
833+
831834
// Create a direct dependencies set according to the output format
832835
std::vector<std::string> bridgedDependencyNames;
833836
for (const auto &dep : directDependencies) {
@@ -850,8 +853,9 @@ generateFullDependencyGraph(CompilerInstance &instance,
850853
dependencyKindAndName += dep.first;
851854
bridgedDependencyNames.push_back(dependencyKindAndName);
852855
}
853-
moduleInfo.direct_dependencies = create_set(bridgedDependencyNames);
854-
moduleInfo.details = getModuleDetails();
856+
857+
moduleInfo->direct_dependencies = create_set(bridgedDependencyNames);
858+
moduleInfo->details = getModuleDetails();
855859
}
856860

857861
swiftscan_dependency_result_s *result = new swiftscan_dependency_result_s;
@@ -1196,7 +1200,6 @@ swift::dependencies::performModuleScan(CompilerInstance &instance,
11961200
allModules.insert({mainModuleName.str(), mainDependencies.getKind()});
11971201

11981202
cache.recordDependencies(mainModuleName, std::move(mainDependencies));
1199-
12001203
auto &ctx = instance.getASTContext();
12011204
auto ModuleCachePath = getModuleCachePathFromClang(
12021205
ctx.getClangModuleLoader()->getClangInstance());
@@ -1229,10 +1232,8 @@ swift::dependencies::performModuleScan(CompilerInstance &instance,
12291232
if (diagnoseCycle(instance, cache, /*MainModule*/ allModules.front(),
12301233
ASTDelegate))
12311234
return std::make_error_code(std::errc::not_supported);
1232-
12331235
auto dependencyGraph = generateFullDependencyGraph(
12341236
instance, cache, ASTDelegate, allModules.getArrayRef());
1235-
12361237
// Update the dependency tracker.
12371238
if (auto depTracker = instance.getDependencyTracker()) {
12381239
for (auto module : allModules) {

unittests/DependencyScan/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ add_swift_unittest(swiftScanTests
44

55
target_link_libraries(swiftScanTests
66
PRIVATE
7-
SwiftScan)
7+
swiftDependencyScan
8+
libSwiftScan)
89

910
target_compile_definitions(swiftScanTests PRIVATE
1011
SWIFTLIB_DIR=\"${SWIFTLIB_DIR}\")

unittests/DependencyScan/ModuleDeps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,5 @@ export *\n\
164164
// TODO: Output/verify dependency graph correctness
165165
// llvm::dbgs() << "Deps: " << Dependencies << "\n";
166166

167-
depscan_dependency_result_dispose(Dependencies);
167+
swiftscan_dependency_result_dispose(Dependencies);
168168
}

0 commit comments

Comments
 (0)