Skip to content

Commit

Permalink
[clang][scan-deps] Stop scanning if any scanning setup emits an error.
Browse files Browse the repository at this point in the history
Without this scanning will continue and later hit an assert that the
number of `RedirectingFileSystem`s matches the number of -ivfsoverlay
arguments.
  • Loading branch information
Bigcheese committed Jan 31, 2024
1 parent 4effff2 commit b21a2f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ class DependencyScanningAction : public tooling::ToolAction {
else
Action = std::make_unique<ReadPCHAndPreprocessAction>();

if (ScanInstance.getDiagnostics().hasErrorOccurred())
return false;

const bool Result = ScanInstance.ExecuteAction(*Action);

if (Result)
Expand Down
18 changes: 18 additions & 0 deletions clang/test/ClangScanDeps/missing-vfs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Check that a missing VFS errors before trying to scan anything.

// RUN: rm -rf %t && split-file %s %t
// RUN: sed -e "s|DIR|%/t|g" %t/build/cdb.json.in > %t/build/cdb.json
// RUN: not clang-scan-deps -compilation-database %t/build/cdb.json \
// RUN: -format experimental-full 2>&1 | FileCheck %s

// CHECK: virtual filesystem overlay file
// CHECK: not found

//--- build/cdb.json.in
[{
"directory": "DIR",
"command": "clang -c DIR/tu.m -ivfsoverlay DIR/vfs.yaml",
"file": "DIR/tu.m"
}]

//--- tu.m

0 comments on commit b21a2f9

Please sign in to comment.