1// This test verifies that system module variants are mergable despite having 2// different warning flags, as most warnings are disabled in system modules. 3// This checks for system modules marked as such both via `-isystem` and 4// `[system]`. 5 6// RUN: rm -rf %t 7// RUN: split-file %s %t 8// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands.json.in > %t/build/compile-commands.json 9// RUN: clang-scan-deps -compilation-database %t/build/compile-commands.json \ 10// RUN: -j 1 -format experimental-full -optimize-args=system-warnings > %t/deps.db 11// RUN: cat %t/deps.db | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t 12 13// CHECK: { 14// CHECK-NEXT: "modules": [ 15// CHECK-NEXT: { 16// CHECK-NEXT: "clang-module-deps": [], 17// CHECK-NEXT: "clang-modulemap-file": 18// CHECK-NEXT: "command-line": [ 19// CHECK-NOT: "-W 20// CHECK: ], 21// CHECK-NEXT: "context-hash": "{{.*}}", 22// CHECK-NEXT: "file-deps": [ 23// CHECK: ], 24// CHECK-NEXT: "link-libraries": [], 25// CHECK-NEXT: "name": "A" 26// CHECK-NEXT: }, 27// CHECK-NEXT: { 28// CHECK-NEXT: "clang-module-deps": [], 29// CHECK-NEXT: "clang-modulemap-file": 30// CHECK-NEXT: "command-line": [ 31// CHECK-NOT: "-W 32// CHECK: ], 33// CHECK-NEXT: "context-hash": "{{.*}}", 34// CHECK-NEXT: "file-deps": [ 35// CHECK: ], 36// CHECK-NEXT: "link-libraries": [], 37// CHECK-NEXT: "name": "B" 38// CHECK-NEXT: }, 39// CHECK-NEXT: { 40// CHECK-NEXT: "clang-module-deps": [], 41// CHECK-NEXT: "clang-modulemap-file": 42// CHECK-NEXT: "command-line": [ 43// CHECK: "-Wmaybe-unused 44// CHECK: ], 45// CHECK-NEXT: "context-hash": "{{.*}}", 46// CHECK-NEXT: "file-deps": [ 47// CHECK: ], 48// CHECK-NEXT: "link-libraries": [], 49// CHECK-NEXT: "name": "C" 50// CHECK-NEXT: } 51// CHECK-NEXT: ], 52// CHECK-NEXT: "translation-units": [ 53// CHECK: ] 54// CHECK: } 55 56// A.m and B.m verify that system modules with different warning flags get 57// merged. C.m verifies that -Wsystem-headers disables the optimization. 58//--- build/compile-commands.json.in 59 60[ 61{ 62 "directory": "DIR", 63 "command": "clang -c DIR/A.m -isystem modules/A -I modules/B -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps", 64 "file": "DIR/A.m" 65}, 66{ 67 "directory": "DIR", 68 "command": "clang -c DIR/B.m -isystem modules/A -I modules/B -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -Wmaybe-unused", 69 "file": "DIR/B.m" 70}, 71{ 72 "directory": "DIR", 73 "command": "clang -c DIR/C.m -isystem modules/C -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -Wmaybe-unused -Wsystem-headers", 74 "file": "DIR/C.m" 75} 76] 77 78//--- modules/A/module.modulemap 79 80module A { 81 umbrella header "A.h" 82} 83 84//--- modules/A/A.h 85 86typedef int A_t; 87 88//--- modules/B/module.modulemap 89 90module B [system] { 91 umbrella header "B.h" 92} 93 94//--- modules/B/B.h 95 96typedef int B_t; 97 98//--- modules/C/module.modulemap 99 100module C [system] { 101 umbrella header "C.h" 102} 103 104//--- modules/C/C.h 105 106typedef int C_t; 107 108//--- A.m 109 110#include <A.h> 111#include <B.h> 112 113A_t a = 0; 114 115//--- B.m 116 117#include <A.h> 118#include <B.h> 119 120A_t b = 0; 121 122//--- C.m 123 124#include <C.h> 125 126C_t c = 0; 127