Skip to content

Commit d783933

Browse files
authored
[clang-scan-deps] Fix check for empty Compilation (#75545)
Closes #64144 Instead of checking for `nullptr` we need to ensure that `JobList` is not empty to proceed
1 parent b91bba8 commit d783933

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/test/ClangScanDeps/empty.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: rm -rf %t
2+
// RUN: not clang-scan-deps --format=p1689 -- %clang this-file-does-not-exist.cpp 2>&1 | FileCheck %s --check-prefix=CHECK
3+
// CHECK: error: no such file or directory: 'this-file-does-not-exist.cpp'
4+
// CHECK: error: no input files

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ getCompilationDataBase(int argc, char **argv, std::string &ErrorMessage) {
727727
*Diags);
728728
std::unique_ptr<driver::Compilation> C(
729729
TheDriver.BuildCompilation(CommandLine));
730-
if (!C)
730+
if (!C || C->getJobs().empty())
731731
return nullptr;
732732

733733
auto Cmd = C->getJobs().begin();

0 commit comments

Comments
 (0)