[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / ClangScanDeps / modules-implementation-private.m
blobb376073f4b9ee969d4dfdc12c041ff1a6c4c2bea
1 // This test checks that we don't crash or report spurious dependencies on
2 // FW_Private when compiling the implementation of framework module FW.
4 // RUN: rm -rf %t
5 // RUN: split-file %s %t
7 //--- cdb.json.template
8 [{
9   "directory": "DIR",
10   "file": "DIR/tu.m",
11   "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=FW -F DIR/frameworks -c DIR/tu.m -o DIR/tu.o"
14 //--- frameworks/FW.framework/Modules/module.modulemap
15 framework module FW { umbrella header "FW.h" }
16 //--- frameworks/FW.framework/Modules/module.private.modulemap
17 framework module FW_Private { umbrella header "FW_Private.h" }
18 //--- frameworks/FW.framework/Headers/FW.h
19 //--- frameworks/FW.framework/PrivateHeaders/FW_Private.h
20 //--- frameworks/FW.framework/PrivateHeaders/Missed.h
21 #import <FW/FW.h> // When included from tu.m, this ends up adding (spurious) dependency on FW for FW_Private.
23 //--- tu.m
24 @import FW_Private; // This is a direct dependency.
25 #import <FW/Missed.h>
27 // RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
28 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
29 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
31 // CHECK:      {
32 // CHECK-NEXT:   "modules": [
33 // CHECK-NEXT:     {
34 // CHECK-NEXT:       "clang-module-deps": [],
35 // CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
36 // CHECK-NEXT:       "command-line": [
37 // CHECK:            ],
38 // CHECK-NEXT:       "context-hash": "{{.*}}",
39 // CHECK-NEXT:       "file-deps": [
40 // CHECK-NEXT:         "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
41 // CHECK-NEXT:         "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/FW_Private.h"
42 // CHECK-NEXT:       ],
43 // CHECK-NEXT:       "link-libraries": [
44 // CHECK-NEXT:         {
45 // CHECK-NEXT:           "isFramework": true,
46 // CHECK-NEXT:           "link-name": "FW"
47 // CHECK-NEXT:         }
48 // CHECK-NEXT:       ],
49 // CHECK-NEXT:       "name": "FW_Private"
50 // CHECK-NEXT:     }
51 // CHECK-NEXT:   ],
52 // CHECK-NEXT:   "translation-units": [
53 // CHECK-NEXT:     {
54 // CHECK-NEXT:       "commands": [
55 // CHECK-NEXT:         {
56 // CHECK-NEXT:           "clang-context-hash": "{{.*}}",
57 // CHECK-NEXT:           "clang-module-deps": [
58 // CHECK-NEXT:             {
59 // CHECK-NEXT:               "context-hash": "{{.*}}",
60 // CHECK-NEXT:               "module-name": "FW_Private"
61 // CHECK-NEXT:             }
62 // CHECK-NEXT:           ],
63 // CHECK-NEXT:           "command-line": [
64 // CHECK:                ],
65 // CHECK:                "file-deps": [
66 // CHECK-NEXT:             "[[PREFIX]]/tu.m",
67 // CHECK-NEXT:             "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Missed.h",
68 // CHECK-NEXT:             "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
69 // CHECK-NEXT:           ],
70 // CHECK-NEXT:           "input-file": "[[PREFIX]]/tu.m"
71 // CHECK-NEXT:         }
72 // CHECK:            ]
73 // CHECK:          }
74 // CHECK:        ]
75 // CHECK:      }