[clang] [clang][DependencyScanning] Add a Clang Driver Option to Enable Dependency Scanning Logging (PR #211966)
Cyndy Ishida via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 3 14:56:23 PDT 2026
================
@@ -0,0 +1,64 @@
+// Diagnostics for the -fdepscan-log-path driver flag during dependency scanning:
+// an empty value is rejected, an inconsistent value across commands in one scan
+// is rejected, and a consistent value is accepted (and aggregated).
+
+// UNSUPPORTED: system-windows
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/empty.json.template > %t/empty.json
+// RUN: sed -e "s|DIR|%/t|g" %t/inconsistent.json.template > %t/inconsistent.json
+// RUN: sed -e "s|DIR|%/t|g" %t/consistent.json.template > %t/consistent.json
+
+// An explicitly empty value is rejected.
+// RUN: not clang-scan-deps -compilation-database %t/empty.json \
+// RUN: -format experimental-full -j 1 2>&1 | FileCheck %s --check-prefix=EMPTY
+// EMPTY: error: '-fdepscan-log-path=' requires a non-empty file path
+
+// Different log paths across commands in one scan are rejected.
+// RUN: not clang-scan-deps -compilation-database %t/inconsistent.json \
+// RUN: -format experimental-full -j 1 2>&1 | FileCheck %s --check-prefix=CONFLICT
+// CONFLICT: error: '-fdepscan-log-path' set inconsistently within a dependency scan
+
+// The same log path across commands is fine; both are aggregated into one log.
+// RUN: clang-scan-deps -compilation-database %t/consistent.json \
+// RUN: -format experimental-full -j 1 -o %t/deps.json
+// RUN: FileCheck %s --check-prefix=OK --input-file %t/scan.log
+// OK: logging_start
+// OK: starting scanning command:{{.*}}tu.c
+// OK: starting scanning command:{{.*}}tu2.c
+// OK: logging_end
+
+// One command with a valid flag, the other does not have a flag in effect.
+// RUN: not clang-scan-deps -compilation-database %t/inconsistent.json \
+// RUN: -format experimental-full -j 1 2>&1 | FileCheck %s --check-prefix=CONFLICT2
+// CONFLICT2: error: '-fdepscan-log-path' set inconsistently within a dependency scan
----------------
cyndyishida wrote:
Not sure if `CONFLICT2` was intended to be the same line as `CONFLICT` but if so, you don't need to repeat it, instead reuse the same prefix label.
https://github.com/llvm/llvm-project/pull/211966
More information about the cfe-commits
mailing list