brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 022c59c Raw
76 lines · c
1// This test checks that __has_include(<FW/PrivateHeader.h>) in a module does2// not clobber #include <FW/PrivateHeader.h> in importers of said module.3 4// RUN: rm -rf %t5// RUN: split-file %s %t6 7//--- cdb.json.template8[{9  "file": "DIR/tu.c",10  "directory": "DIR",11  "command": "clang DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -I DIR/modules -F DIR/frameworks -o DIR/tu.o"12}]13 14//--- frameworks/FW.framework/Modules/module.private.modulemap15framework module FW_Private {16  umbrella header "A.h"17  module * { export * }18}19//--- frameworks/FW.framework/PrivateHeaders/A.h20#include <FW/B.h>21//--- frameworks/FW.framework/PrivateHeaders/B.h22#include "dependency.h"23 24//--- modules/module.modulemap25module Poison { header "poison.h" }26module Import { header "import.h" }27module Dependency { header "dependency.h" }28//--- modules/poison.h29#if __has_include(<FW/B.h>)30#define HAS_B 131#else32#define HAS_B 033#endif34//--- modules/import.h35#include <FW/B.h>36//--- modules/dependency.h37 38//--- tu.c39#include "poison.h"40 41#if __has_include(<FW/B.h>)42#endif43 44#include "import.h"45 46#include <FW/B.h>47 48// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json49// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/deps.json50// RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t51 52// Let's check that the TU actually depends on `FW_Private` (and does not treat FW/B.h as textual).53// CHECK:      {54// CHECK:        "translation-units": [55// CHECK-NEXT:     {56// CHECK-NEXT:       "commands": [57// CHECK-NEXT:         {58// CHECK-NEXT:           "clang-context-hash": "{{.*}}",59// CHECK-NEXT:           "clang-module-deps": [60// CHECK-NEXT:             {61// CHECK-NEXT:               "context-hash": "{{.*}}",62// CHECK-NEXT:               "module-name": "FW_Private"63// CHECK-NEXT:             }64// CHECK:                ],65// CHECK-NEXT:           "command-line": [66// CHECK:                ],67// CHECK:                "file-deps": [68// CHECK-NEXT:             "[[PREFIX]]/tu.c"69// CHECK-NEXT:           ],70// CHECK-NEXT:           "input-file": "[[PREFIX]]/tu.c"71// CHECK-NEXT:         }72// CHECK:            ]73// CHECK:          }74// CHECK:        ]75// CHECK:      }76