File: invalid-pch-bridging-header.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (55 lines) | stat: -rw-r--r-- 2,430 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// REQUIRES: objc_interop

// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/pch %t/pch-dir
// RUN: split-file %s %t
// RUN: sed -e "s|TEST_DIR|%/t|g" %t/hmap.json > %t/inner.json

// Check that the pch is output even though it has errors
// RUN: %target-swift-frontend -emit-pch -o %t/pch/bridging-header.pch -Xcc -Xclang -Xcc -fallow-pcm-with-compiler-errors -Xcc -Xclang -Xcc -fmodule-format=raw %t/bridging-header.h -Xcc -I%t/inner.hmap
// RUN: not %target-swift-frontend -typecheck -import-objc-header %t/pch/bridging-header.pch -Xcc -Xclang -Xcc -fallow-pcm-with-compiler-errors -Xcc -Xclang -Xcc -fmodule-format=raw %t/use.swift -Xcc -I%t/inner.hmap 2>&1 | %FileCheck %s -check-prefix MISSING_HMAP
// RUN: ls %t/pch/*.pch | count 1

// Same but with implicit PCH instead
// RUN: not %target-swift-frontend -typecheck -import-objc-header %t/bridging-header.h -pch-output-dir %t/pch-dir -Xcc -Xclang -Xcc -fallow-pcm-with-compiler-errors -Xcc -Xclang -Xcc -fmodule-format=raw %t/use.swift -Xcc -I%t/inner.hmap 2>&1 | %FileCheck %s -check-prefix MISSING_HMAP
// RUN: ls %t/pch-dir/*.pch | count 1

// Second implicit run since we may go down a different path if the PCH already
// exists
// RUN: not %target-swift-frontend -typecheck -import-objc-header %t/bridging-header.h -pch-output-dir %t/pch-dir -Xcc -Xclang -Xcc -fallow-pcm-with-compiler-errors -Xcc -Xclang -Xcc -fmodule-format=raw %t/use.swift -Xcc -I%t/inner.hmap 2>&1 | %FileCheck %s -check-prefix MISSING_HMAP
// RUN: ls %t/pch-dir/*.pch | count 1

// Create the headermap, should now have no errors
// RUN: %hmaptool write %t/inner.json %t/inner.hmap
// RUN: %target-swift-frontend -typecheck -verify -import-objc-header %t/bridging-header.h -pch-output-dir %t/pch-dir -Xcc -Xclang -Xcc -fallow-pcm-with-compiler-errors -Xcc -Xclang -Xcc -fmodule-format=raw %t/use.swift -Xcc -I%t/inner.hmap
// RUN: ls %t/pch-dir/*.pch | count 1

//--- bridging-header.h
#include "inner.h"

struct SomeTy {
  int a;
};

//--- inner/inner.h
struct InnerTy {
  int b;
};

//--- hmap.json
{
  "mappings": {
    "inner.h": "TEST_DIR/inner/inner.h"
  }
}

//--- use.swift
func use(s: SomeTy, s2: InnerTy) {}

// Note: extra newlines below ensure that context printing doesn't show the
// lines that we shouldn't see.


// MISSING_HMAP-NOT: cannot find type 'SomeTy' in scope
// MISSING_HMAP: cannot find type 'InnerTy' in scope
// MISSING_HMAP-NOT: cannot find type 'SomeTy' in scope