Several changes:
- shorten the warning at the call-site of unannotated functions that
return FRTS
- place the call to action ("annotate 'X' with 'Y'") at the diagnostic
note attached to the unannotated callee, where the annotation should
be made
- re-word the foreign-reference-type.md documentation to (1) reflect the
diagnostic wording change, (2) give a little bit more background about
why the annotations are needed, and (3) not be specific to C++ (since
we can import FRTs from C as well)
This change makes the warning for unannotated C++ functions returning foreign
reference types (FRT) enabled by default, improving memory safety for Swift/C++
interop users. Also added CxxForeignReferenceType diagnostic group for better control
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.
PredictableMemoryAccessOptimizations has become unmaintainable as-is.
RedundantLoadElimination does (almost) the same thing as PredictableMemoryAccessOptimizations.
It's not as powerful but good enough because PredictableMemoryAccessOptimizations is actually only needed for promoting integer values for mandatory constant propagation.
And most importantly: RedundantLoadElimination does not insert additional copies which was a big problem in PredictableMemoryAccessOptimizations.
Fixes rdar://142814676
This feature worked prior 5.10 but the semantics was undefined. This PR
restores the behavior with the old semantics, and a separate PR will
update the documentation to describe the behavior.