Skip to content

Commit f816923

Browse files
committed
Renaming clang-scan-deps' module-name option to module-names.
1 parent 7f29cb0 commit f816923

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,19 @@ bool DependencyScanningWorker::computeDependencies(
751751
InMemoryFS->setCurrentWorkingDirectory(WorkingDirectory);
752752
SmallString<128> FakeInputPath;
753753
// TODO: We should retry the creation if the path already exists.
754-
// FIXME: should we create files for multiple modules? I think so?
754+
// FIXME: Using ModuleNames[0] should be sufficient to create a unique
755+
// input file name. The diagnostic information is specifc enough about
756+
// in which exact module an error occurs. That said any error reporting
757+
// that relies on the path below could be confusing.We may want to
758+
// find better ways (e.g. by concatenating the module names) to make
759+
// the temporary file name more precise.
755760
llvm::sys::fs::createUniquePath(ModuleNames[0] + "-%%%%%%%%.input",
756761
FakeInputPath,
757762
/*MakeAbsolute=*/false);
763+
764+
// The fake file must contain at least ModuleNames.size() characters,
765+
// since we are simulating lexing it, and we are assuming each module name
766+
// takes the space of one character.
758767
std::string FakeString(ModuleNames.size(), ' ');
759768
InMemoryFS->addFile(FakeInputPath, 0,
760769
llvm::MemoryBuffer::getMemBuffer(FakeString));

clang/test/ClangScanDeps/link-libraries.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module transitive {
3232
}]
3333

3434
// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
35-
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-name=root > %t/result.json
35+
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-names=root > %t/result.json
3636
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
3737

3838
// CHECK: {

clang/test/ClangScanDeps/modules-full-by-mod-name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module transitive { header "transitive.h" }
2525
}]
2626

2727
// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
28-
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-name=root > %t/result.json
28+
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-names=root > %t/result.json
2929
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
3030

3131
// CHECK: {

clang/tools/clang-scan-deps/ClangScanDeps.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static void ParseArgs(int argc, char **argv) {
203203
if (const llvm::opt::Arg *A = Args.getLastArg(OPT_compilation_database_EQ))
204204
CompilationDB = A->getValue();
205205

206-
if (const llvm::opt::Arg *A = Args.getLastArg(OPT_module_name_EQ))
206+
if (const llvm::opt::Arg *A = Args.getLastArg(OPT_module_names_EQ))
207207
ModuleName = A->getValue();
208208

209209
for (const llvm::opt::Arg *A : Args.filtered(OPT_dependency_target_EQ))
@@ -1024,11 +1024,17 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
10241024
HadErrors = true;
10251025
}
10261026
} else if (ModuleName) {
1027+
StringRef NamesRef(*ModuleName);
1028+
SmallVector<StringRef, 16> NameList;
1029+
NamesRef.split(NameList, ",");
10271030
auto MaybeModuleDepsGraph = WorkerTool.getModuleDependencies(
1028-
ArrayRef<StringRef>({*ModuleName}), Input->CommandLine, CWD,
1031+
NameList, Input->CommandLine, CWD,
10291032
AlreadySeenModules, LookupOutput);
1030-
if (handleModuleResult(*ModuleName, MaybeModuleDepsGraph, *FD,
1031-
LocalIndex, DependencyOS, Errs))
1033+
// FIXME: Need to have better error handling logic for a list
1034+
// of modules. Probably through some call back.
1035+
if (handleModuleResult(/* *ModuleName*/ NameList[0],
1036+
MaybeModuleDepsGraph, *FD, LocalIndex,
1037+
DependencyOS, Errs))
10321038
HadErrors = true;
10331039
} else {
10341040
std::unique_ptr<llvm::MemoryBuffer> TU;

clang/tools/clang-scan-deps/Opts.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def eager_load_pcm : F<"eager-load-pcm", "Load PCM files eagerly (instead of laz
2626
def j : Arg<"j", "Number of worker threads to use (default: use all concurrent threads)">;
2727

2828
defm compilation_database : Eq<"compilation-database", "Compilation database">;
29-
defm module_name : Eq<"module-name", "the module of which the dependencies are to be computed">;
29+
defm module_names : Eq<"module-names", "the module of which the dependencies are to be computed">;
3030
defm dependency_target : Eq<"dependency-target", "The names of dependency targets for the dependency file">;
3131

3232
defm tu_buffer_path: Eq<"tu-buffer-path", "The path to the translation unit for depscan. Not compatible with -module-name">;

0 commit comments

Comments
 (0)