[llvm-branch-commits] [clang] [clang][DependencyScanning] Adding a Multiarch clang-scan-deps Test (PR #211404)

Qiongsi Wu via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jul 22 15:46:29 PDT 2026


https://github.com/qiongsiwu created https://github.com/llvm/llvm-project/pull/211404

This test adds coverage of multiarch scanning command macro canonicalization. 

---

<sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>

>From cf54e3496328cb33936c4e8eab9d1153cf819e1d Mon Sep 17 00:00:00 2001
From: Qiongsi Wu <qiongsi_wu at apple.com>
Date: Tue, 21 Jul 2026 14:44:34 -0700
Subject: [PATCH] Adding a multiarch clang-scan-deps test

---
 .../canonicalize-macros-multiarch.c           | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 clang/test/ClangScanDeps/canonicalize-macros-multiarch.c

diff --git a/clang/test/ClangScanDeps/canonicalize-macros-multiarch.c b/clang/test/ClangScanDeps/canonicalize-macros-multiarch.c
new file mode 100644
index 0000000000000..24a55c19c090f
--- /dev/null
+++ b/clang/test/ClangScanDeps/canonicalize-macros-multiarch.c
@@ -0,0 +1,27 @@
+// A multi-arch driver command lowers to two -cc1 jobs for one TU. With macro
+// canonicalization enabled, BOTH emitted -cc1 command lines must be
+// canonicalized identically: for `-DB=2 -DA=1 -UB -DC=3` the trailing `-UB`
+// wins, so the redundant `B=2` define is dropped.
+//
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json \
+// RUN:   -format experimental-full -optimize-args=canonicalize-macros -j 1 \
+// RUN:   > %t/result.json
+
+// RUN: FileCheck %s < %t/result.json
+
+// No emitted -cc1 command line may retain the redundant B=2 define.
+// CHECK-NOT: B=2
+
+//--- cdb.json.in
+[{
+  "directory": "DIR",
+  "command": "clang -c DIR/main.c -o DIR/main.o -arch x86_64 -arch arm64 -DB=2 -DA=1 -UB -DC=3",
+  "file": "DIR/main.c"
+}]
+
+//--- main.c
+int main(void) { return 0; }



More information about the llvm-branch-commits mailing list