Commit Graph

31 Commits

Author SHA1 Message Date
Becca Royal-Gordon
da07ff577c [PrintAsClang] Warn about unstable decl order
PrintAsClang is supposed to emit declarations in the same order regardless of the compiler’s internal state, but we have repeatedly found that our current criteria are inadequate, resulting in non-functionality-affecting changes to generated header content. Add a diagnostic that’s emitted when this happens soliciting a bug report.

Since there *should* be no cases where the compiler fails to order declarations, this diagnostic is never actually emitted. Instead, we test this change by enabling `-verify` on nearly all PrintAsClang tests to make sure they are unaffected.

This did demonstrate a missing criterion that only mattered in C++ mode: extensions that varied only in their generic signature were not sorted stably. Add a sort criterion for this.
2025-02-14 21:41:36 -08:00
Alex Lorenz
de1e67d054 [interop][SwiftToCxx] include the swiftToCxx shim header only when actually needed for reverse interop 2022-10-17 13:12:20 -07:00
Alex Lorenz
b4d7a0c208 [interop][SwiftToCxx] bridge returned C++ record types back to C++ from Swift 2022-09-11 18:42:41 -07:00
Tongjie Wang
22d686b933 update test cases 2022-07-26 11:25:30 -07:00
Alex Lorenz
71d95b88cc [interop] fix the test/PrintAsObjC/empty.swift for C++ interop 2022-03-29 16:58:38 -07:00
Alex Lorenz
60902cbfa0 [interop] restructure Swift -> C++ interop tests
We will place tests that test the semantics and runtime of the generated
C++ code into Interop/SwiftToCxx. PrintCxx test directory will only be
used to test high level flow without concerning itself about the C++ semantics.
2022-01-24 10:51:52 -08:00
Doug Gregor
bf99f31d75 Revert "PrintAsObjc: expand module @imports to header #imports if modules are not supported"
This reverts commit a2534fa234.
2020-03-27 21:02:44 -07:00
Xi Ge
a2534fa234 PrintAsObjc: expand module @imports to header #imports if modules are not supported
rdar://58284119
2020-03-03 11:54:14 -08:00
Brent Royal-Gordon
746fb2864e [PrintAsObjC] Disable -Watimport-in-framework-header warning in generated headers (#20086)
This is a new warning in clang when you use @import in a framework header. That’s often a mistake, but it isn’t in our generated -Swift.h headers. If we’re building with a clang that supports this warning, we’ll now emit a pragma to disable it.
2018-11-02 19:02:17 -07:00
Mani Ramezan
3c824ddaa5 Include Foundation framework instead of minimal NSObject.h
This change is for preventing scenarios like https://bugs.swift.org/projects/SR/issues/SR-2250
2018-06-28 19:27:24 -04:00
Jordan Rose
34e602b93a [PrintAsObjC] Don't define char{16,32}_t in C++-pre-11 (#12537)
Turns out libc++ already defines compatibility typedefs in this case,
and we don't care about any other C++ stdlibs on Apple platforms at
the moment.

rdar://problem/34861807
2017-10-23 10:46:01 -07:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Argyrios Kyrtzidis
0efba5f0e9 [PrintAsObjC] Make sure the preprocessor checks work in a compiler different than clang
The C preprocessor rules don't short-circuit so "#if defined(__has_feature) && __has_feature(modules)" will always fail if '__has_feature' is not defined.
2017-04-21 12:00:21 -07:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Saleem Abdulrasool
89d37bc694 test: ignore unused options in some tests
These tests explicitly disable the use of modules.  However, the lit
configuration is such that the module cache path will be passed unconditionally
to the clang invocation.  Squelch the unused option warning (error).
2016-04-05 10:00:37 -07:00
Jordan Rose
fc2cdeeb31 [PrintAsObjC] Only define Swift-provided typedefs once.
Avoids a C99 warning.

Rest of rdar://problem/22702104

Swift SVN r32232
2015-09-25 17:53:48 +00:00
Jordan Rose
fdc927e8d7 [PrintAsObjC] Add missing SWIFT_COMPILE_NAME for classes renamed with @objc.
This could prevent mixed-source frameworks from being properly imported
into Swift.

rdar://problem/21930630

Swift SVN r30541
2015-07-23 17:28:20 +00:00
Doug Gregor
75617df37d PrintAsObjC: Stop printing SWIFT_NULLABILITY(keyword).
Everyone's Clang should support nullability qualifiers now.

Swift SVN r28649
2015-05-15 23:46:46 +00:00
Dmitri Hrybenko
f43843f25c tests: use the new substitution for the mock SDK
This is required to correctly use the mock SDK when the SDK overlay is
built and tested separately.  (Otherwise, the mock SDK might not get
used, because the overlay SDK options would expand from the
%-substitution, appear first on the command line, and shadow the mock
SDK in the search path).

Swift SVN r25185
2015-02-11 18:57:29 +00:00
Doug Gregor
883911c767 Define __null_unspecified to nothing when the underlying Clang doesn't support nullability.
Fixes rdar://problem/19730896.

Swift SVN r25000
2015-02-05 17:35:45 +00:00
Graham Batty
83b4384fac Update test flags for linux failures and support.
Also removed the sdk 'feature' in favour of the more specific
objc_interop.

Swift SVN r24856
2015-01-30 21:31:48 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Dmitri Hrybenko
1eea220932 Use one module cache directory for all the lit tests to speed them up
Doing so is safe even though we have mock SDK.  The include paths for
modules with the same name in the real and mock SDKs are different, and
the module files will be distinct (because they will have a different
hash).

This reduces test runtime on OS X by 30% and brings it under a minute on
a 16-core machine.

This also uncovered some problems with some tests -- even when run for
iOS configurations, some tests would still run with macosx triple.  I
fixed the tests where I noticed this issue.

rdar://problem/19125022

Swift SVN r23683
2014-12-04 11:21:48 +00:00
Graham Batty
83f27a8af7 Revert "Mark tests that don't pass on linux as XFAIL."
This reverts commit 2711ca86de7bf6a7885ccea24219a48a590b1e95.

Swift SVN r23577
2014-11-24 17:42:13 +00:00
Graham Batty
198402dcfe Mark tests that don't pass on linux as XFAIL.
Swift SVN r23573
2014-11-24 17:40:37 +00:00
Jordan Rose
1b7a384252 Fix a multitude of issues with extensions exposed to Objective-C (r19116).
- Category names weren't unique.
- We were using an attribute to detect if something was a Swift category,
  but attributes can't be used on categories.
- The test that this was all working was failing in a way that wasn't caught.

To solve these problems:

- We're using a macro to generate category names based on __LINE__ in addition
  to the current module.
- The importer uses the macro to detect that the category comes from Swift
  (no attribute needed).
- The test now has a deliberate error for -verify to catch.

<rdar://problem/17342287&17538553>

Swift SVN r19479
2014-07-02 20:35:25 +00:00
Jordan Rose
74bc750c43 [PrintAsObjC] Use #import for the underlying module (instead of @import).
When generating a header for the Swift half of a mixed-source framework,
we can't import the framework using @import, because that means a submodule
is trying to import a parent module before the module is done being built.
This currently isn't supported in Clang, though it only recently became an
error instead of being ignored.

Instead, we now assume that the framework will have an umbrella header with
the same name as the framework module, which is the same assumption Xcode
makes when you don't provide your own module map. I'm not too concerned about
people trying to build mixed-source frameworks who /don't/ have umbrella
headers.

This doesn't affect app targets at all, which use -import-objc-header instead
of a standalone underlying module.

<rdar://problem/16879704>

Swift SVN r17984
2014-05-13 00:38:49 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Jordan Rose
8b9dfb017a Move test/Swift2ObjC to test/PrintAsObjC to match the library name.
Swift SVN r13799
2014-02-12 01:19:12 +00:00