For semantic functionality the API decl is the more useful thing to
mangle, and redeclaration checking ensures we can't end up with
conflicts. This ensures we're able to perform a name lookup for the
decl based on its USR without having to maintain a separate lookup
table for ABI names.
Make sure we avoid adding these to the entity stack entirely, which
avoids hitting the assertion that a top-level entity isn't encountered
with a non-empty stack.
This adds a check in lit.local.cfg for whether the current C++ stdlib
contains the 'span' header. If so, the llvm-lit feature 'std_span' is
set. Also adds 'REQUIRES: std_span' to interop tests that include
'span'. This means we no longer have to choose between blanket disabling
`std::span` tests on all Linux distributions, or listing every Linux
distro with a libstdc++ version without `std::span` support as
unsupported.
I couldn't find any existing path to the MSVC stdlib in lit, and we
don't test versions of MSVC old enought to not support std::span
anyways, so 'std_span' is unconditionally enabled when targeting
windows-msvc.
rdar://161999160
rdar://161999174
rdar://162106580
rdar://162106619
rdar://162106643
rdar://162106653
rdar://162106722
rdar://162106747
This reverts most of 72050c5385, which led to decreased performance of jump-to-definition.
Instead of re-attempting to generate a module interface with C++ interop enabled, Swift should rely on the IDE to pass the correct `-cxx-interoperability-mode=` value to SourceKit.
rdar://149061322
In preparation for removing UnresolvedType in favor of ErrorType,
start printing ErrorType as `_` unless we've enabled debug printing.
`<<error type>>` should never be presented to the user, instead `_`
now just consistently means "unknown type".
This generalization enables curried functions with generic parameters coming from the initial declaration to be printed with the archetype's upperbound rather than '_' unresolved type.
As an added benefit, T.self and T.Type for generic parameters now get shown as the upperbound of the generic parameter provided
We set an original expression on ErrorExpr for cases where we have
something semantically invalid that doesn't fit into the AST, but is
still something that the user has explicitly written. For example
this is how we represent unresolved dots without member names (`x.`).
We still want to type-check the underlying expression though since
it can provide useful diagnostics and allows semantic functionality
such as completion and cursor info to work correctly.
rdar://130771574
With the unqualified fallback we start to hit this assertion for
`return nil` in failable intializers. We ought to be able to just
skip over literal buckets though.
This is unnecessary since the local conformances for a protocol
can only contain self-conformances, which we don't want to visit
anyway. This can just be a straightforward loop over the local
conformances.
Currently, when we jump-to-definition for decls that are macro-expanded
from Clang imported decls (e.g., safe overloads generated by
@_SwiftifyImport), setLocationInfo() emits a bongus location pointing to
a generated buffer, leading the IDE to try to jump to a file that does
not exist.
The root cause here is that setLocationInfo() calls getOriginalRange()
(earlier, getOriginalLocation()), which was not written to account for
such cases where a macro is generated from another generated buffer
whose kind is 'AttributeFromClang'.
This patch fixes setLocationInfo() with some refactoring:
- getOriginalRange() is inlined into setLocationInfo(), so that the
generated buffer-handling logic is localized to that function. This
includes how it handles buffers generated for ReplacedFunctionBody.
- getOriginalLocation() is used in a couple of other places that only
care about macros expanded from the same buffer (so other generated
buffers not not relevant). This "macro-chasing" logic is simplified
and moved from ModuleDecl::getOriginalRange() to a free-standing
function, getMacroUnexpandedRange() (there is no reason for it to be
a method of ModuleDecl).
- GeneratedSourceInfo now carries an extra ClangNode field, which is
populated by getClangSwiftAttrSourceFile() when constructing
a generated buffer for an 'AttributeFromClang'. This could probably
be union'ed with one or more of the other fields in the future.
rdar://151020332
Make `getOriginalLocation` work with source ranges, and adjust the
cursor info logic to map the range into the original buffer. This
fixes the case where we were using bogus range lengths for macro
expansion decls.
rdar://151411756
Previously we would only add @_disfavoredOverload if the only type
changed was the return type, because in any other case it is unambiguous
which overload to call. However it is still ambiguous when storing the
function as a value rather than calling the function, unless explicit
type annotations are used.
To avoid breaking any existing code, this patch adds
@_disfavoredOverload to every overload generated by @_SwiftifyImport.
rdar://151206394
Introduce a new ASTWalker option for walking CustomAttrs and use it
for the placeholder scanner to ensure we can expand placeholders in
attribute arguments.
Swift nodes imported from clang don't have doc comments carried over,
but IDEs are clever enough to fetch the comments from the associated
clang node. The swift node in the macro expansion from _SwiftifyImport
doesn't have a clang node directly associated with it however.
This patch adds the same comment from the clang node to the
_SwiftifyImport macro invocation node. Since the macro has access to
this node, it can easily copy over its leading trivia.
For now the comment is not altered at all, meaning @param still remains
even if the parmeter is removed.
rdar://151346977
The diagnostic group documentation now point to the swift.org URL rather
than the toolchain path, so it no longer needs to be passed all the way
through sourcekitd.
Resolves rdar://151500502.
Previously we would insert StringRefs that reference the keys in the
map, but that breaks if the invocation ever gets copied. Switch to
`std::string`.
rdar://148130166
As SourceKit explicitly disables WMO, silence the diagnostic in this case (but leave it enabled for explicit non-WMO builds otherwise).
rdar://150596807
If a module has the same `public-module-name` as the module being
generated and its import is exported, merge it into the same generated
interface.
Fix various always-imported modules from being printed while here and
update all the tests that checked for them.
Resolves rdar://137887712.
`getType` here can return a null type if the queried expression isn't
part of the solution, which can currently happen for code completion.
I'm working on a more principled fix for this, but until then this is
a low-risk fix that will unblock the stress tester and can be
cherry-picked to 6.2.
rdar://149759542