https://github.com/qiongsiwu updated https://github.com/llvm/llvm-project/pull/159620
>From 250d52ddcafee193a987b9dde639ab2cd5aa81e7 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu <[email protected]> Date: Thu, 18 Sep 2025 11:04:37 -0700 Subject: [PATCH 1/2] Making sure the scanning `CompilerInvocation`'s `-D`s are canonicalized. --- .../DependencyScanning/DependencyScanningWorker.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp index 0855e6dec6158..f2bd5a0c767a1 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -391,10 +391,13 @@ class DependencyScanningAction { IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS, std::shared_ptr<PCHContainerOperations> PCHContainerOps, DiagnosticConsumer *DiagConsumer) { + // Making sure that we canonicalize the defines before we create the deep + // copy. + if (any(Service.getOptimizeArgs() & ScanningOptimizations::Macros)) + canonicalizeDefines(Invocation->getPreprocessorOpts()); + // Make a deep copy of the original Clang invocation. CompilerInvocation OriginalInvocation(*Invocation); - if (any(Service.getOptimizeArgs() & ScanningOptimizations::Macros)) - canonicalizeDefines(OriginalInvocation.getPreprocessorOpts()); if (Scanned) { // Scanning runs once for the first -cc1 invocation in a chain of driver >From 6520631cfe748b9d9125cd67d25ead04b59842ce Mon Sep 17 00:00:00 2001 From: Qiongsi Wu <[email protected]> Date: Thu, 18 Sep 2025 14:55:39 -0700 Subject: [PATCH 2/2] Adding a test to check number of scanning module variants. --- clang/test/ClangScanDeps/optimize-canonicalize-macros.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/test/ClangScanDeps/optimize-canonicalize-macros.m b/clang/test/ClangScanDeps/optimize-canonicalize-macros.m index 46ae1c84ec7ba..bc434b516f942 100644 --- a/clang/test/ClangScanDeps/optimize-canonicalize-macros.m +++ b/clang/test/ClangScanDeps/optimize-canonicalize-macros.m @@ -8,6 +8,9 @@ // RUN: -j 1 -format experimental-full -optimize-args=canonicalize-macros > %t/deps.db // RUN: cat %t/deps.db | FileCheck %s -DPREFIX=%/t +// This tests that we have two scanning module variants. +// RUN: find %t/module-cache -name "*.pcm" | wc -l | grep 2 + // Verify that there are only two variants and that the expected merges have // happened. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
