Commit Graph

39091 Commits

Author SHA1 Message Date
Alexis Laferrière
480e8933d7 [SPI Test] Test @_implementationOnly compatibility with @_spi imports 2020-03-04 16:43:05 -08:00
Alexis Laferrière
412469326d [SPI Test] Extend and update SPI tests 2020-03-04 16:43:05 -08:00
Ashley Garland
f0887fa245 [SymbolGraph] Emit synthesized members
Emit copies of default implementations in protocol extensions and superclass declarations in conforming types and subclasses respectively using a virtual USR, i.e. `${REAL_USR}::SYNTHESIZED::${CONFORMING_OR_SUBCLASS_TYPE_USR}`.

- Add a -skip-synthesized-members option to skip these synthesized members.

- Create a new wrapping `Symbol` type that can also contain a base type declaration as well as the inherited declaration for those synthesized cases. Move some symbol-specific APIs there.

- Doc comments can “cascade” down to protocol extensions or refinements in concrete types. When emitting the doc comment for a symbol, look up through to superclasses or protocol requirements for where a doc comment is actually written.

- Clean up filtering of implicitly private (e.g. “public underscored”) types

rdar://problem/59128787
2020-03-04 16:04:21 -08:00
Xi Ge
6dde0e6abc TBDGen: pass-down target variant when generating textual interface stubs
rdar://60057760
2020-03-04 15:52:29 -08:00
Owen Voorhees
b8a87f651e Merge pull request #30206 from owenv/format-multiline-fixits
[Diag-Experimental-Formatting] Better rendering of multi-line fix-its
2020-03-04 15:34:16 -08:00
Rintaro Ishizaki
cf1ee044ef Disable a flaky test case
rdar://problem/59977439
2020-03-04 15:12:50 -08:00
Mike Ash
c1faaa5267 Merge pull request #30207 from mikeash/fix-objc-name-suffixes
[Runtime] Reject suffixes on ObjC mangled class names.
2020-03-04 17:05:16 -05:00
Joe Groff
61be64a61b Merge pull request #15344 from jckarter/nullable-enum-generalization
IRGen: Generalize the nullable optimization for single-payload enums.
2020-03-04 12:24:41 -08:00
Owen Voorhees
d220ac80f3 [Diag-Experimental-Formatting] Better rendering of multi-line fix-its
- Fix an off-by-one error when a fix-it continues onto a newline
- Don't print multi-line insertions inline due to poor UX
- When printing multi-line fix-its out of line attached to a message,
  replace newlines with the carriage return emoji
- Don't underline a line's leading whitespace unless it's part of an insertion
2020-03-04 11:57:39 -08:00
Robert Widmann
24d86a7ca0 XFAIL a flaky test harder 2020-03-04 10:39:48 -08:00
Kuba (Brecka) Mracek
0d400ca310 Merge branch 'master' into mracek/arm64e 2020-03-04 09:36:25 -08:00
Robert Widmann
7a3b24a6ad XFAIL a flaky test 2020-03-04 09:24:57 -08:00
Mike Ash
614f4becef [Runtime] Reject suffixes on ObjC mangled class names.
The demangler tolerates arbitrary suffixes on mangled names, and parses them as a Suffix node. When looking up a class by an ObjC mangled name, we don't want such demanglings to succeed, because this will result in false positives. It's expected that NSClassFromString(someClassName + "some suffix") will fail, unless something has actually created a class with that suffix.

rdar://problem/60012296
2020-03-04 12:05:35 -05:00
Robert Widmann
f1fa041bd4 Merge pull request #30198 from CodaFi/just-keep-passing-the-open-windows
[DependencyVerifier] Windows Investigation
2020-03-04 08:46:39 -08:00
Michael Gottesman
0392b1820e Merge pull request #30197 from gottesmm/pr-e70e6d7bd61594b156ccf191c4e903753dbd3f83
[ownership] Ban cond_br from having any non-trivial operands.
2020-03-04 07:33:08 -08:00
Holly Borla
516b3e43cd Merge pull request #30195 from hborla/function-builder-crash
[ConstraintSystem] Bail out of applyFunctionBuilderBodyTransform if there is a failure in constraint generation.
2020-03-04 06:52:18 -08:00
fischertony
eb539e62f8 Parse: Diagnose where clauses early on non-generic top-level declarations 2020-03-04 15:04:28 +03:00
Robert Widmann
e7321799d2 [DependencyVerifier] XFAIL the failure test for now
rdar://60030114
2020-03-04 00:40:06 -08:00
Brent Royal-Gordon
b5430607a2 Provide a more useful cross-import submodule test
Removes an unreliable performance-based submodule skipping test and replaces it with a test that checks for a related functional trait instead.
2020-03-03 22:06:59 -08:00
Robert Widmann
ef149d5c86 Merge pull request #30135 from CodaFi/verily-i-depend-on-thee
[Incremental] Introducing: DependencyVerifier
2020-03-03 22:01:38 -08:00
Michael Gottesman
2b0b7f2e30 [ownership] Ban cond_br from having any non-trivial operands.
Previously, we just banned cond_br from having non-trivial operands along
critical edges. This is a stronger condition that beyond simplifying ossa for
passes, also lets me remove the need for BranchPropagatedUser, simplifying the
linear lifetime checker.
2020-03-03 21:42:14 -08:00
swift-ci
db10388b3c Merge pull request #30194 from xwu/floating-point-conversion-oops 2020-03-03 21:35:53 -08:00
Holly Borla
24d8aa148f Merge pull request #30185 from hborla/dependent-type-requirement-failure
[ConstraintSystem] Replace dependent member types with holes when the…
2020-03-03 19:55:07 -08:00
Holly Borla
e3239ba5fc [ConstraintSystem] Bail out of applyFunctionBuilderBodyTransform if
there is a failure in constraint generation.
2020-03-03 19:32:06 -08:00
Doug Gregor
12f8b51921 Merge pull request #30189 from DougGregor/function-builders-switch-exhaustive
[Constraint solver] Check switch exhaustiveness in function builders
2020-03-03 18:48:39 -08:00
Robert Widmann
f85ec3825f Address review feedback 2020-03-03 16:46:04 -08:00
Ben Rimmington
f5fe8e376d [stdlib] StaticString documentation and tests
Co-Authored-By: Nate Cook <natecook@apple.com>
2020-03-04 00:15:07 +00:00
Holly Borla
fce8738ea8 [ConstraintSystem] Replace dependent member types with holes when the base type
doesn't conform to the associatedtype's protocol (only in diagnostic mode).

This allows the solver to find solutions for more cases involving requirement
failures for dependent member types without special cases across the solver
that check for dependent member types with no type variables.
2020-03-03 15:45:24 -08:00
Xiaodi Wu
6e46135965 [stdlib] Update tests for generic floating-point conversion 2020-03-03 18:35:27 -05:00
Joe Groff
950ee3b0de IRGen: Generalize the nullable optimization for single-payload enums.
Augment the `isSingleRetainablePointer` check that allows IRGen to avoid adding branching around retain/release operations on enums that use the null pointer extra inhabitant with a more general "can value witness extra inhabitants" method on TypeInfo, which says whether a type's retain/release operations are safe to invoke on some or all of its extra inhabitants. This lets us generalize the optimization to include things like `String?` or `ClassProtocol?` which are common types with a nullable pointer in them.
2020-03-03 15:00:27 -08:00
Dan Liew
6402778e60 Re-enable asan_recover.swift on Linux.
This depends on a fix (821a4930956c9ab4b0dd9052c4e15680f27b93c0) in
llvm-project.

rdar://problem/58702902
2020-03-03 14:57:26 -08:00
Doug Gregor
7ee33a920d [Constraint solver] Check switch exhaustiveness in function builders 2020-03-03 13:44:36 -08:00
Xi Ge
70977a0fe8 Merge pull request #30175 from nkcsgexi/expand-module-imports
PrintAsObjc: expand module @imports to header #imports if modules are not supported
2020-03-03 13:37:32 -08:00
Hamish Knight
92ba9483b9 Merge pull request #30166 from hamishknight/three-flags
Move parsing flags onto SourceFile
2020-03-03 13:14:21 -08:00
Doug Gregor
8191aa4924 Merge pull request #30174 from DougGregor/function-builder-switch
[Constraint system] Implement switch support for function builders.
2020-03-03 12:34:08 -08: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
Rintaro Ishizaki
12fd864543 Merge pull request #30136 from rintaro/ide-completion-rdar59285399
[CodeCompletion] Primarily use getPossibleCallees() for calling signature completion
2020-03-03 11:10:53 -08:00
Andrew Trick
d47b802950 Merge pull request #30173 from atrick/fix-temp-rvalue-access
Fix MemBehavior and TempRValueOpt to handle access markers
2020-03-03 11:10:16 -08:00
Ben Langmuir
939d618944 Merge pull request #30162 from benlangmuir/assert-less-enumelem
[cursorinfo] Avoid use of null raw value in enum element decl
2020-03-03 10:20:50 -08:00
Pavel Yaskevich
f37c9a7f6f Merge pull request #30165 from xedin/rdar-59703585
[Diagnostics] Don't fix partial mismatch for sub-types associated with…
2020-03-03 09:54:04 -08:00
Visoiu Mistrih Francis
aaab1869af Merge pull request #29650 from francisvm/sil-remark-streamer
[Remarks] Add a specialized RemarkStreamer for SIL remarks
2020-03-03 09:30:17 -08:00
Andrew Trick
880db42e33 Fix TempRValueOpt with access markers.
- consistently operate on the address value of the variable via
  stripAccessMarkers. Never use address of the transient access which
  may not have sufficient lifetime.

- Recognize begin_access [read] as a load.

- delete dead access markers after deleting copies

Fixes <rdar://59345115> Unnecessary copy_addr not eliminated with
exclusivity checking
2020-03-03 09:24:18 -08:00
Andrew Trick
badc5658bb Fix SIL MemBehavior queries with access markers.
This is in prepration for other bug fixes.

Clarify the SIL utilities that return canonical address values for
formal access given the address used by some memory operation:

- stripAccessMarkers
- getAddressAccess
- getAccessedAddress

These are closely related to the code in MemAccessUtils.

Make sure passes use these utilities consistently so that
optimizations aren't defeated by normal variations in SIL patterns.

Create an isLetAddress() utility alongside these basic utilities to
make sure it is used consistently with the address corresponding to
formal access. When this query is used inconsistently, it defeats
optimization. It can also cause correctness bugs because some
optimizations assume that 'let' initialization is only performed on a
unique address value.

Functional changes to Memory Behavior:

- An instruction with side effects now conservatively still has side
  effects even when the queried value is a 'let'. Let values are
  certainly sensitive to side effects, such as the parent object being
  deallocated.

- Return the correct MemBehavior for begin/end_access markers.
2020-03-03 09:24:18 -08:00
Doug Gregor
ea8d143f64 [Constraint system] Introduce a one-way constraint for a switch subject.
The normal type checking of switch statements checks the switch subject
first, without context, then evaluates the cases. Introduce a one-way
constraint into the type checking of switch statements within function
builders to provide this same behavior. The difference can be observed
in code such as:

    enum E {
      case a
      case b(Int, String?)
    }

    enum E2 {
      case b(Int, String?)
    }

    func getSomeEnumOverloaded(_: Double) -> E { return .a }
    func getSomeEnumOverloaded(_: Int) -> E2 { return .b(0, nil) }

    func f() {
      switch getSomeEnumOverloaded(17) {
      case .a:  // error: no member named "a" in E2
        print("a")
      default:
        print("default")
      }
    }

When the subject expression `getSomeEnumOverloaded(17)` is resolved
without consider cases, it will select the second
`getSomeEnumOverloaded(_:)`, because the literal 17 prefers to be
an `Int`. The type checking of the first case would then fail because E2
does not contain a member named "a".

Prior to this change, the same expression within a function
builder would succeed in type checking, because the lack of case named
"a" within "E2" would make the second getSomeEnumOverloaded() unusable.

Making this code work by considering the cases along with the subject
expression is not unreasonable, and may be the right long term
direction for the language. However, it's a feature that should be
discussed separately, and the semantics should agree between function
builders and normal statements.

Big thanks to John McCall for noting the missing one-way constraint!
2020-03-03 08:51:26 -08:00
Owen Voorhees
69b513afaf [Diagnostics] Updated (experimental) diagnostic printing style (#30027)
* [Diagnostics] Experimental diagnostic printing updates

This new style directly annotates small snippets of code with
error messages, highlights and fix-its. It also uses color more
effectively to highlight important segments.

* [Diagnostics] Stage educational notes and experimental formatting behind separate frontend flags

educational notes -> -enable-educational-notes
formatting -> -enable-experimental-diagnostic-formatting

* [Diagnostics] Refactor expensive line lookups in diag formatting

* [Diagnostics] Refactor some PrintingDiagnosticConsumer code into a flush method

* [Diag-Experimental-Formatting] Custom formatting for Xcode editor placeholders

* [Diag-Experimental-Formatting] Better and more consistent textual description of fix its

* [Diags-Experimental-Formatting] Handle lines with tab characters correctly when rendering highlights and messages

Tabs are converted to 2 spaces for display purposes.

* [Diag-Experimental-Formatting] Refactor byte-to-column mapping for efficiency

* [Diag-Experimental-Formatting] Fix line number indent calculation

* [Diag-Experimental-Formatting] Include indicators of insertions and deletions in the highlight line

Inserts are underlined by green '+' chars, deletions by red '-' chars.

* [Diag-Experimental-Formatting] Change color of indicator arrow for non-ASCII anchored messages
* [Diag-experimental-formatting] Make tests less sensitive to line numbering

* [Diag-Experimental-Formatting] Update tests to allow windows path separators

* [Diag-Experimental-Formatting] Bug fixes for the integrated REPL
2020-03-03 08:48:32 -08:00
Kuba (Brecka) Mracek
5d918e5ee1 Merge branch 'master' into mracek/arm64e 2020-03-03 08:28:01 -08:00
Joe Groff
d8e8b3d307 Merge pull request #30105 from jckarter/objc-opt-self
IRGen: Invoke objc_opt_self directly when available.
2020-03-03 07:29:27 -08:00
Suyash Srijan
13487edd09 [Typechecker] Diagnose key paths with contextual type but no leading dot (#30164) 2020-03-03 12:17:32 +00:00
eeckstein
0dd3c7ce79 Merge pull request #30156 from eeckstein/global-opt-fix
GlobalOpt: handle access markers correctly.
2020-03-03 11:23:25 +01:00
Dmitri Gribenko
e83f58ffba Merge pull request #30028 from martinboehme/verify-fix
If `-verify` mode saw unexpected diagnostics, print diagnostics from all files.
2020-03-03 10:09:45 +01:00