diff --git a/clang/lib/DependencyScanning/DependencyScannerImpl.cpp b/clang/lib/DependencyScanning/DependencyScannerImpl.cpp index d1aced2592be1..8c7eec6c7b326 100644 --- a/clang/lib/DependencyScanning/DependencyScannerImpl.cpp +++ b/clang/lib/DependencyScanning/DependencyScannerImpl.cpp @@ -412,6 +412,8 @@ void dependencies::initializeScanCompilerInstance( ScanInstance.setBuildingModule(false); ScanInstance.createVirtualFileSystem(FS, DiagConsumer); ScanInstance.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false); + if (Service.getOpts().Format == ScanningOutputFormat::P1689) + ScanInstance.getDiagnostics().setIgnoreAllWarnings(true); ScanInstance.createFileManager(); ScanInstance.createSourceManager(); diff --git a/clang/test/ClangScanDeps/p1689-suppress-warnings.cppm b/clang/test/ClangScanDeps/p1689-suppress-warnings.cppm new file mode 100644 index 0000000000000..c012c520e5304 --- /dev/null +++ b/clang/test/ClangScanDeps/p1689-suppress-warnings.cppm @@ -0,0 +1,23 @@ +// Test that P1689 format suppresses warnings during dependency scanning. +// This addresses https://github.com/llvm/llvm-project/issues/185394 + +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t + +// Test P1689 format - should NOT emit warnings +// RUN: clang-scan-deps -format=p1689 -- %clang++ -std=c++20 -I%t -c %t/mylib.cppm -o %t/mylib.o 2>&1 | FileCheck %s + +// CHECK-NOT: warning: +// CHECK: { +// CHECK: "revision" + +//--- header.h +// Empty header for testing + +//--- mylib.cppm +module; + +export module mylib; + +#include \ No newline at end of file