Commit Graph

15 Commits

Author SHA1 Message Date
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Egor Zhdan
3c82042633 [cxx-interop] Import complex macros consistently in C++ language mode
This is similar to ced4cb06.

Clang stores macro information for each identifier inside of `IdentifierInfo`, which can sometimes get outdated. Clang solves this by updating the identifier info if necessary in `getLeafModuleMacros`. Let's do the same in Swift.

This makes sure that macros that reference other macros are correctly imported with C++ interop enabled.

rdar://145584369
rdar://110071334
2025-09-12 17:43:42 +01:00
zoecarver
7216be13fa [cxx-interop] A little macros fix; breadcrumbs for future fixes. 2023-06-22 12:21:10 -07:00
Becca Royal-Gordon
4bd532ab9a Don't import string macros with invalid UTF-8
Swift string literals are only permitted to contain well-formed UTF-8, but C does not share this restriction, and ClangImporter wasn't checking for that before it created `StringLiteralExpr`s for imported macros; this could cause crashes when importing a header. This commit makes us drop these macros instead.

Although invalid UTF-8 always *did* cause a segfault in my testing, I'm not convinced that there isn't a way to cause a miscompile with a bug like this. If we somehow did generate code that fed ill-formed UTF-8 to the builtin literal init for Swift.String, the resulting string could cause undefined behavior at runtime. So I have additionally added a defensive assertion to StringLiteralInst that any UTF-8 string represented in SIL is well-formed. Hopefully that will catch any non-crashing compiler bugs like this one.

Fixes rdar://67840900.
2022-01-26 20:57:13 -08:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Pavel Yaskevich
58329e0c27 Revert "[Diagnostics][Qol] SR-11295 Emit diagnostics for same type coercion. " 2019-10-25 01:05:07 -07:00
Luciano Almeida
86ca3454d6 Fixing warning UnnecessaryCoercion tests 2019-10-21 23:11:21 -03:00
Varun Gandhi
cca2872e02 Fix issue SR-9482.
Solution based on the outline in the issue description.

Also fixes the corresponding rdar://problem/46644027.
2019-07-15 14:57:04 -07:00
Varun Gandhi
58304137d4 Adds an expected-error test characterizing the issue in SR-9482. 2019-07-15 13:36:38 -07:00
Saleem Abdulrasool
88003cfed8 tests: enable a few tests on Linux, u-opt
Avoid a temporary file and executing FileCheck multiple types and prefer
multiple check prefixes and streaming.  Additionally, enable some of
previously XFAIL'ed tests on Linux as well as tests that were marked as
requiring Objective-C interop.
2018-04-25 14:09:11 -07:00
Jordan Rose
413e7db918 [ClangImporter] Handle diagnostics about cast types in macros
The importer handles these by first trying to look up the type by name
using Clang's Sema, but that lookup can cause diagnostics to be
emitted (usually availability diagnostics). We could try to figure out
how to propagate that to the macro when we import it, but for now just
drop the macro instead if there are any diagnostics emitted when
looking up the type.

This will be a small source compatibility break if anyone was using a
macro defined in terms of a type that's deprecated or that has partial
availability; the macro will now silently not be imported instead of
producing an unsilenceable warning.

rdar://problem/36528212
2018-01-16 13:44:22 -08:00
Jordan Rose
5edbefcc69 [ClangImporter] Break circularity when importing macros (#13099)
Rather than being smart about this, just record an import failure when
we start importing a particular macro and update it at the end. Also
add a PrettyStackTrace to make this a little easier to track down in
the future.

The old logic for importing macros that just aliased other macros
managed to handle this in a clever way, but that was never tested for
the newer logic that evaluates expressions (fa834e2f80). Macro
importing in general probably deserves some cleanup, but meanwhile we
should make sure not to crash!

rdar://problem/34986930
2017-12-01 11:42:49 -08:00
SpringsUp
fa834e2f80 [ClangImporter] Teach the importer about more infix operators between
integer constants, and to always look through macro definitions for them.

Also, logical comparisons now return a Boolean.

New operations: +, -, *, /, ^, >>, ==, >, >=, <, <=
2017-01-23 21:02:47 +01: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
Jordan Rose
61798ff6ec [test] Rename test/ClangModules to test/ClangImporter. (#5618)
...to match the component in include/ and lib/. No content change.
2016-11-02 18:00:53 -07:00