112 lines · c
1// Most likely platform specific sed differences2// UNSUPPORTED: system-windows3 4// This test verifies modules that are entirely comprised from stable directory inputs are captured in5// dependency information.6 7// The first compilation verifies that transitive dependencies on local input are captured.8// The second compilation verifies that external paths are resolved when a 9// vfsoverlay for determining is-in-stable-directories.10 11// RUN: rm -rf %t12// RUN: split-file %s %t13// RUN: sed -e "s|DIR|%/t|g" %t/compile-commands.json.in > %t/compile-commands.json14// RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json15// RUN: clang-scan-deps -compilation-database %t/compile-commands.json \16// RUN: -j 1 -format experimental-full > %t/deps.db17// RUN: cat %t/deps.db | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t18 19// CHECK: "modules": [20// CHECK-NEXT: {21// CHECK: "is-in-stable-directories": true,22// CHECK: "name": "A"23 24// Verify that there are no more occurances of sysroot.25// CHECK-NOT: "is-in-stable-directories"26 27// CHECK: "name": "A"28// CHECK: "USE_VFS"29// CHECK: "name": "B"30// CHECK: "name": "C"31// CHECK: "name": "D"32// CHECK: "name": "NotInSDK"33 34//--- compile-commands.json.in35[36{37 "directory": "DIR",38 "command": "clang -c DIR/client.c -isysroot DIR/Sysroot -IDIR/Sysroot/usr/include -IDIR/BuildDir -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps",39 "file": "DIR/client.c"40},41{42 "directory": "DIR",43 "command": "clang -c DIR/client.c -isysroot DIR/Sysroot -IDIR/Sysroot/usr/include -ivfsoverlay DIR/overlay.json -DUSE_VFS -IDIR/BuildDir -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps",44 "file": "DIR/client.c"45}46]47 48//--- overlay.json.template49{50 "version": 0,51 "case-sensitive": "false",52 "roots": [53 {54 "external-contents": "DIR/SysrootButNotReally/A/A_vfs.h",55 "name": "DIR/Sysroot/usr/include/A/A_vfs.h",56 "type": "file"57 }58 ]59}60 61//--- Sysroot/usr/include/A/module.modulemap62module A {63 umbrella "."64}65 66//--- Sysroot/usr/include/A/A.h67#ifdef USE_VFS68#include <A/A_vfs.h>69#endif 70typedef int A_t;71 72//--- SysrootButNotReally/A/A_vfs.h73typedef int typeFromVFS;74 75//--- Sysroot/usr/include/B/module.modulemap76module B [system] {77 umbrella "."78}79 80//--- Sysroot/usr/include/B/B.h81#include <C/C.h>82typedef int B_t;83 84//--- Sysroot/usr/include/C/module.modulemap85module C [system] {86 umbrella "."87}88 89//--- Sysroot/usr/include/C/C.h90#include <D/D.h>91 92//--- Sysroot/usr/include/D/module.modulemap93module D [system] {94 umbrella "."95}96 97// Simulate a header that will be resolved in a local directory, from a sysroot header.98//--- Sysroot/usr/include/D/D.h99#include <HeaderNotFoundInSDK.h>100 101//--- BuildDir/module.modulemap102module NotInSDK [system] {103 umbrella "."104}105 106//--- BuildDir/HeaderNotFoundInSDK.h107typedef int local_t;108 109//--- client.c110#include <A/A.h>111#include <B/B.h>112