[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / ClangScanDeps / modules-no-undeclared-includes.c
blobae84979710cce41fce7c21bb45340273b225d2e4
1 // Unsupported on AIX because we don't support the requisite "__clangast"
2 // section in XCOFF yet.
3 // UNSUPPORTED: target={{.*}}-aix{{.*}}
5 // RUN: rm -rf %t && mkdir %t
6 // RUN: split-file %s %t
8 //--- undeclared/module.modulemap
9 module Undeclared { header "undeclared.h" }
11 //--- undeclared/undeclared.h
13 //--- module.modulemap
14 module User [no_undeclared_includes] { header "user.h" }
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
21 //--- test.c
22 #include "user.h"
24 //--- cdb.json.template
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"
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
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]]/undeclared/module.modulemap",
48 // CHECK-NEXT: "[[PREFIX]]/user.h"
49 // CHECK-NEXT: ],
50 // CHECK-NEXT: "name": "User"
51 // CHECK-NEXT: }
52 // CHECK-NEXT: ],
53 // CHECK-NEXT: "translation-units": [
54 // CHECK-NEXT: {
55 // CHECK: "clang-context-hash": "{{.*}}"
56 // CHECK-NEXT: "clang-module-deps": [
57 // CHECK-NEXT: {
58 // CHECK-NEXT: "context-hash": "{{.*}}"
59 // CHECK-NEXT: "module-name": "User"
60 // CHECK-NEXT: }
61 // CHECK-NEXT: ],
62 // CHECK-NEXT: "command-line": [
63 // CHECK: ],
64 // CHECK: "file-deps": [
65 // CHECK-NEXT: "[[PREFIX]]/test.c"
66 // CHECK-NEXT: ],
67 // CHECK-NEXT: "input-file": "[[PREFIX]]/test.c"
68 // CHECK-NEXT: }
70 // RUN: %deps-to-rsp %t/result.json --module-name=User > %t/User.cc1.rsp
71 // RUN: %deps-to-rsp %t/result.json --tu-index=0 > %t/tu.rsp
73 // RUN: %clang @%t/User.cc1.rsp
74 // RUN: %clang @%t/tu.rsp