1 // Unsupported on AIX because we don't support the requisite "__clangast" 2 // section in XCOFF yet. 3 // UNSUPPORTED: target={{.*}}-aix{{.*}} 4 5 // RUN: rm -rf %t && mkdir %t 6 // RUN: split-file %s %t 7 8 //--- undeclared/module.modulemap 9 module Undeclared { header "undeclared.h" } 10 11 //--- undeclared/undeclared.h 12 13 //--- module.modulemap 14 module User [no_undeclared_includes] { header "user.h" } 15 16 //--- user.h 17 #if __has_include("undeclared.h") 18 #error Unreachable. Undeclared comes from a module that's not 'use'd, meaning the compiler should pretend it doesn't exist. 19 #endif 20 21 //--- test.c 22 #include "user.h" 23 24 //--- cdb.json.template 25 [{ 26 "directory": "DIR", 27 "command": "clang -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -IDIR/undeclared -c DIR/test.c -o DIR/test.o", 28 "file": "DIR/test.c" 29 }] 30 31 // RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json 32 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \ 33 // RUN: -module-files-dir %t/build > %t/result.json 34 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t 35 36 // CHECK: { 37 // CHECK-NEXT: "modules": [ 38 // CHECK-NEXT: { 39 // CHECK-NEXT: "clang-module-deps": [], 40 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap", 41 // CHECK-NEXT: "command-line": [ 42 // CHECK: "-fmodule-map-file=[[PREFIX]]/undeclared/module.modulemap" 43 // CHECK: ], 44 // CHECK-NEXT: "context-hash": "{{.*}}", 45 // CHECK-NEXT: "file-deps": [ 46 // CHECK-NEXT: "[[PREFIX]]/module.modulemap", 47 // CHECK-NEXT: "[[PREFIX]]/user.h", 48 // CHECK-NEXT: "[[PREFIX]]/undeclared/module.modulemap" 49 // CHECK-NEXT: ], 50 // CHECK-NEXT: "link-libraries": [], 51 // CHECK-NEXT: "name": "User" 52 // CHECK-NEXT: } 53 // CHECK-NEXT: ], 54 // CHECK-NEXT: "translation-units": [ 55 // CHECK-NEXT: { 56 // CHECK: "clang-context-hash": "{{.*}}" 57 // CHECK-NEXT: "clang-module-deps": [ 58 // CHECK-NEXT: { 59 // CHECK-NEXT: "context-hash": "{{.*}}" 60 // CHECK-NEXT: "module-name": "User" 61 // CHECK-NEXT: } 62 // CHECK-NEXT: ], 63 // CHECK-NEXT: "command-line": [ 64 // CHECK: ], 65 // CHECK: "file-deps": [ 66 // CHECK-NEXT: "[[PREFIX]]/test.c" 67 // CHECK-NEXT: ], 68 // CHECK-NEXT: "input-file": "[[PREFIX]]/test.c" 69 // CHECK-NEXT: } 70 71 // RUN: %deps-to-rsp %t/result.json --module-name=User > %t/User.cc1.rsp 72 // RUN: %deps-to-rsp %t/result.json --tu-index=0 > %t/tu.rsp 73 // 74 // RUN: %clang @%t/User.cc1.rsp 75 // RUN: %clang @%t/tu.rsp 76