Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,14 @@ 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 to avoid unnecessary variants in the scanner and in the resulting
// explicit command lines.
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
Expand Down
3 changes: 3 additions & 0 deletions clang/test/ClangScanDeps/optimize-canonicalize-macros.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down