[clang] d783933 - [clang-scan-deps] Fix check for empty `Compilation` (#75545)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 30 17:55:10 PST 2024
Author: Yaraslau
Date: 2024-01-31T09:55:05+08:00
New Revision: d783933bc910ac005e18928d22b6c10c4fe8d6f6
URL: https://github.com/llvm/llvm-project/commit/d783933bc910ac005e18928d22b6c10c4fe8d6f6
DIFF: https://github.com/llvm/llvm-project/commit/d783933bc910ac005e18928d22b6c10c4fe8d6f6.diff
LOG: [clang-scan-deps] Fix check for empty `Compilation` (#75545)
Closes https://github.com/llvm/llvm-project/issues/64144
Instead of checking for `nullptr` we need to ensure that `JobList` is
not empty to proceed
Added:
clang/test/ClangScanDeps/empty.cpp
Modified:
clang/tools/clang-scan-deps/ClangScanDeps.cpp
Removed:
################################################################################
diff --git a/clang/test/ClangScanDeps/empty.cpp b/clang/test/ClangScanDeps/empty.cpp
new file mode 100644
index 0000000000000..807bb5c3fee4b
--- /dev/null
+++ b/clang/test/ClangScanDeps/empty.cpp
@@ -0,0 +1,4 @@
+// RUN: rm -rf %t
+// RUN: not clang-scan-deps --format=p1689 -- %clang this-file-does-not-exist.cpp 2>&1 | FileCheck %s --check-prefix=CHECK
+// CHECK: error: no such file or directory: 'this-file-does-not-exist.cpp'
+// CHECK: error: no input files
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 76337664c45e3..e45ea700d87b9 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -727,7 +727,7 @@ getCompilationDataBase(int argc, char **argv, std::string &ErrorMessage) {
*Diags);
std::unique_ptr<driver::Compilation> C(
TheDriver.BuildCompilation(CommandLine));
- if (!C)
+ if (!C || C->getJobs().empty())
return nullptr;
auto Cmd = C->getJobs().begin();
More information about the cfe-commits
mailing list