* [Python3] Fix "undefined symbol 'unicode'" from python_lint
This is a little tricky.
Python 2 "unicode" was renamed to "str" in Python 3.
For Python 2 compatibility, we need to use "unicode" in a couple
of places, but that's not defined on Python 3, which causes
python_lint errors (even if the reference is never actually executed).
To workaround this, when running in Python 3, define "unicode"
as a synonym for "str". This defines the symbol (avoiding the
"undefined symbol" error from python lint) while preserving
the correct functionality on both Python 2 and Python 3.
When we drop Python 2 support (which we should do as soon as
possible), we can drop this workaround and globally replace
"unicode" with "str" to get the right Python 3-only functionality.
Instead on depending on repr to be a function, let's only check
whether type resolved for `@autoclosure` points to a function type
because it's allowed for `@autoclosure` parameters to be to
wrapped into parens or be represented by a typealias.
Resolves: rdar://problem/65704049
Hacking sys.modules here was added unconditionally to fix an import problem on
Windows (with Python 2.7???).
This script works fine on Python 2.7 on macOS either with or without this hack.
This script breaks badly on Python 3.8 on macOS with this hack, so I've disabled
it here for all Python 3.
Do not gate the coroutine extension points on the LLVM passes. Without
running this pass, the generated IR cannot be used by the LLVM tooling.
This allows generating the LLVM IR to debug issues in the LLVM backend.
I encountered this when trying to isolate a debug info generation bug
which seems to be caused by the SRoA pass in LLVM. By allowing to emit
the LLVM IR without the LLVM optimizations, it is possible to isolate
the LLVM pass operation via `opt` from LLVM.
* [Parser] Update 'Confusables.def' file to include confusable and base character names
* [Parser] Add a new utility method to return the names of the confusable and base characters for a given confusable codepoint
* [Parser] Update diagnostic for confusable character during lexing to mention confusable and base character names
* [Sema] If there is just a single confusable character, emit a tailored diagnostic that also mentions the character names
* [Diagnostics] Add new diagnostic messages to the localization file
* [Test] Update confusables test
* [Utils] Update unicode confusables txt file and update script to regenerate confusables def file
* [Parse] Regenerate 'Confusables.def' using updated script
* [Utils] Adjust generate_confusables script based on review feedback
Fix a mistake with name mapping. Updated header comment. Fix a couple of linting issues.
* [Parse] Regenerate 'Confusables.def' file once again after script changes
* [Parse] Add the newline after end of 'getConfusableAndBaseCodepointNames' method
* [Test] Update diagnostic message in 'Syntax/Parser/diags.swift'
Clang's driver started linking with libclang_rt.<os>sim.a when building for simulator.
Swift's build need to adapt to this clang change, by ensuring that the libclang_rt.<os>sim.a libraries are created during the build
This ensures that we are able to properly look through struct_extract,
tuple_extract in cases where we have an aggregate with multiple non-trivial
subtypes (implying it is not-rc identical with those sub-types).
The end result is that we now emit good diagnostics for things like this:
```
func returnStructWithOwnerOwner(x: StructWithOwner) -> Klass {
return x.owner // expected-remark {{retain}}
// expected-note @-7:33 {{of 'x.owner'}}
}
```
Optimizes String operations with constant operands.
Specifically:
* Replaces x.append(y) with x = y if x is empty.
* Removes x.append("")
* Replaces x.append(y) with x = x + y if x and y are constant strings.
* Replaces _typeName(T.self) with a constant string if T is statically known.
With this optimization it's possible to constant fold string interpolations, like "the \(Int.self) type" -> "the Int type"
This new pass runs on high-level SIL, where semantic calls are still in place.
rdar://problem/65642843
To be able to constant fold string interpolation, the right semantic attributes must be in place.
Also, the interpolation's write function must be inlinable.
For the _typeName constant folding, a semantic attribute is required.
* [Diagnostics] Update 'does not override' diagnostic message to include protocol context as well
* [Sema] Check whether the override context is a class or a protocol for diagnostic purposes
* [Test] Update tests with new diagnostic message for overrides in protocol context
* [Sema] Adjust diagnostic for overrides in structs and enums to use the existing 'override_nonclass_decl' diagnostic
More specifically, if one wants to force emit /all/ opt-remarks on a function, mark it with:
```
@_semantics("optremark")
```
If one wants to emit opt-remarks only for a specific SIL pass (like lets say
sil-opt-remark-gen), one can write:
```
@_semantics("optremark.sil-opt-remark-gen")
```
I made the pattern matching strict so if you just put in a '.' or add additional
suffixes, it will not pattern match. I think that this is sufficient for a
prototyping tool.
This is useful if one wants to play around with opt-remarks when optimizing code
in Xcode or any IDE that can use serialized diagnostics.