Commit Graph

121 Commits

Author SHA1 Message Date
Erik Eckstein
fa56ba2c3c link SwiftCompilerSources modules to lldb-moduleimport-test and swift-remoteast-test
This is needed once we implement mandatory passes in Swift, because those testing tools might parse swift interface files from the SDK.
2025-06-20 08:15:03 +02:00
Steven Wu
47b3efdb6e [Macro] Add a new macro loading option that do not involve searching
Add flag `-load-resolved-plugin` to load macro plugin, which provides a
pre-resolved entry into PluginLoader so the plugins can be loaded based
on module name without searching the file system. The option is mainly
intended to be used by explicitly module build and the flag is supplied
by dependency scanner.
2024-10-31 10:56:21 -07:00
Alexander Cyon
4a2942bb4e Fix typos in: cmake, tools, utils, unittests, validation-test
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2024-07-12 02:34:00 +03:00
Kavon Farvardin
149c052ec5 use new noncopyable types infrastructure
The infrastructure underpinning the new feature NoncopyableGenerics is
mature enough to be used.
2024-03-14 23:10:44 -07:00
Slava Pestov
0eb146f50a lldb-moduleimport-test: pass correct enableNoncopyableGenerics value to validateSerializedAST() 2024-02-20 18:26:05 -05:00
Adrian Prantl
543a2cd685 Fix caching bug in MemoryBufferSerializedModuleLoader
By populating the memory cache before loading the module, we can avoid a cycle
where a module is imported that is an overlay, which then triggers
ClangImporter, which then (redundantly) triggers the import of the overlay
module, which would reimport the module again, since it's import is still
underway and it hasn't been entered into the cache yet.

rdar://118846313
2024-02-15 14:06:28 -08:00
Kavon Farvardin
483b569bc8 [NCGenerics] trigger module mismatch
A swiftmodule can only be correctly ingested by a compiler
that has a matching state of using or not-using
NoncopyableGenerics.

The reason for this is fundamental: the absence of a Copyable
conformance in the swiftmodule indicates that a type is
noncopyable. Thus, if a compiler with NoncopyableGenerics
reads a swiftmodule that was not compiled with that feature,
it will think every type in that module is noncopyable.

Similarly, if a compiler with NoncopyableGenerics produces a
swiftmodule, there will be Copyable requirements on each
generic parameter that the compiler without the feature will
become confused about.

The solution here is to trigger a module mismatch, so that
the compiler re-generates the swiftmodule file using the
swiftinterface, which has been kept compatible with the compiler
regardless of whether the feature is enabled.
2024-01-23 22:42:37 -08:00
Adrian Prantl
5ef93af269 Revert "Don't require a strict revision match in LLDB."
This reverts commit 3cc2831608.

The compiler's revision check has been relaxed since the feature was introduced
and so it's nos better to reduce the number of special code paths for LLDB in
the compiler to facilitate reasoning about it.

rdar://117824367
2023-12-06 11:14:14 -08:00
Adrian Prantl
5d978b44ca Revert "Revert "Make the DWARF version emitted by the Swift compiler configurable."" 2023-10-26 12:29:18 -07:00
Adrian Prantl
2a32ca5944 Revert "Make the DWARF version emitted by the Swift compiler configurable." 2023-10-25 13:28:28 -07:00
Adrian Prantl
d19fe381fa Use LLVM definitions for Swift section names (NFC) 2023-10-24 10:58:40 -07:00
Hiroshi Yamauchi
24dfc905f5 [lldb] Capture error messages from parseASTSection to log from the caller.
This helps fix a lldb console output mixup between the lldb logging
and the llvm::dbgs() messages from parseASTSection.
2023-08-10 17:08:25 -07:00
Rintaro Ishizaki
6fa0c14dfb [Macros] Make 'PluginSearchOption' a external union
Create a 'Kind' enum so that deserialization can use the kind instead of
a string option name.
2023-06-16 11:59:19 -07:00
Rintaro Ishizaki
706985df82 [Macros] Update plugin search options serialization
Previously plugin search options were serialized for each option kind.
Instead serialize them in the order specified.
2023-06-15 17:32:59 -07:00
Adrian Prantl
a3a43d46c5 [Serialization] Teach ASTSectionImporter to filter by triple.
On macOS it is possible for one application to contain Swift modules compiled
for different triples that are incompatible as far as the Swift compiler is
concerned. Examples include an iOS simulator application hunning on a macOS
host, or a macCatalyst application running on macOS. A debugger might see
.swift_ast sections for all triples at the same time. This patch adds an
interface to let the client provide a triple to filter Swift modules in an
ASTSection.

rdar://107869141
2023-05-08 08:32:00 -07:00
Rintaro Ishizaki
3ef6087d32 [Macros] Serialize plugin search paths for LLDB use
rdar://107030743
2023-05-01 14:04:39 -07:00
Alexis Laferrière
940b7d99d1 [Tools] Explicitly disable deserialization safety in some testing tools 2023-01-06 12:02:47 -08:00
Adrian Prantl
a5e1786a99 Expose Swift search paths in validateSerializedAST
This is for the benefit of LLDB, which currently does an expensive import of all
modules to get to the same information.

rdar://40097459
2022-12-01 13:14:08 -08:00
Adrian Prantl
3cc2831608 Don't require a strict revision match in LLDB.
For release-management purposes during development, LLDB's embedded Swift
compiler's version number can sometimes be off-by-one in the last digit
compared to the Swift compiler.

This patch restores the old behavior from before 17183629e4.

rdar://101299168
2022-10-19 09:03:13 -07:00
Alexis Laferrière
c8059a09e9 [Serialization] Soft-reject swiftmodules built against a different SDK
Change the way swiftmodules built against a different SDK than their
clients are rejected. This makes them silently ignored when the module
can be rebuilt from their swiftinterface, instead of reporting a hard
error.

rdar://93257769
2022-05-16 13:22:35 -07:00
Alex Hoppen
63c31033fc [Frontend] Load standard libarary in CompilerInstance::setup
Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
2021-12-13 15:32:08 +01:00
Michael Gottesman
06cb5c0047 [cmake] Move a bunch of test binaries from install component 'tools' -> 'testsuite-tools'.
All of these are tools that are only meant to be used when testing swift. Thus
it doesn't make sense to include them in the catch all 'tools' install component
that distributions use to build all the tools.

I verified that all of the mac/linux presets in tree that have tools also has
testsuite-tools so this should be NFC. On Windows, I needed to add
testsuite-tools to build-windows.bat so should be NFC there as well.
2021-11-09 12:51:58 -08:00
Meghana Gupta
f458d9b490 Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
2021-10-04 18:46:40 -07:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Adrian Prantl
2cb2760ed9 ASTPrinter: Add an option to qualify ClangImported types.
This part of a series of patches to bring ASTPrinter and Swift Demangler to
feature parity, which is needed by LLDB, which depends on using the strings
produced by either interchangibly.

rdar://problem/63700540
2020-05-29 19:04:22 -07:00
Tony Allevato
5284cb6f99 Add dependencies where targets depend on inclusions from unspecified targets.
A follow-up PR adds a flag to control an inline namespace that allows
symbols in libDemangling to be distinguished between the runtime and
the compiler. These dependencies ensure that the flag is plumbed
through for inclusions of Demangling headers that aren't already
covered by existing `target_link_libraries`.
2020-03-31 09:19:41 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Arnold Schwaighofer
43c24be5cd Merge remote-tracking branch 'upstream/master' into master-next 2020-01-08 06:41:34 -08:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
swift-ci
ef8a0d15a5 Merge remote-tracking branch 'origin/master' into master-next 2019-08-16 08:50:45 -07:00
swift-ci
4aefbcf447 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-16 08:43:42 -07:00
Adrian Prantl
1020d8188a Add back the dummy DWARFImporter test to lldb-moduleimport-test. 2019-08-15 16:35:05 -07:00
Alex Langford
04c5ceb18c Adjust for svn r368826
LLVM svn r368826 changed the SectionRef::getName() interface to return an
Expected<StringRef> instead of filling out one that is passed to it.
Adjust accordingly.
2019-08-15 10:56:06 -07:00
swift-ci
032def3316 Merge remote-tracking branch 'origin/master' into master-next 2019-08-14 11:50:24 -07:00
swift-ci
7245d76875 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-14 11:44:30 -07:00
Adrian Prantl
c08a62764a Move DWARFImporterDelegate into ClangImporter and remove DWARFImporter.
This refactors DWARFImporter to become a part of ClangImporter, since
it needs access to many of its implementation details anyway. The
DWARFImporterDelegate is just another mechanism for deserializing
Clang ASTs and once we have a Clang AST, the processing is effectively
the same.
2019-08-14 10:28:50 -07:00
swift-ci
24d2d5fd7a Merge remote-tracking branch 'origin/master' into master-next 2019-06-14 13:09:28 -07:00
Saleem Abdulrasool
f33fa6b037 lldb-module-test: correct the output pipe
Use the error stream for error messages.
2019-05-22 07:56:12 -07:00
Gwen Mittertreiner
67cfef2d60 SectionRef::getContents() now returns Expected
Updated uses of object::SectionRef::getContents() since it now returns
an Expected<StringRef> instead of modifying the one it's passed.

See also: git-svn-id:
https://llvm.org/svn/llvm-project/llvm/trunk@360892
91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-20 16:02:41 -07:00
Adrian Prantl
807c2cfbe3 Make lldb-moduleimport more rubost when importing object files with multiple AST
blobs.
2019-05-08 11:34:21 -07:00
Adrian Prantl
b244b0928e Factor out the pre-registered MemoryBuffer functionality
form SerializedModuleLoader into its own ModuleLoader class. (NFC-ish)

This gives better control over the order in which the various module
load mechanisms are applied.
2019-04-22 09:17:08 -07:00
Saleem Abdulrasool
1fad3d60e0 lldb-moduleimport-test: handle COFF properly
lldb-moduleimport-test would only check for MachO and ELF object file
formats.  However, Windows uses COFF object files.  Add that to the list
of formats that we check.  This allows us to inspect content built for
Windows.
2019-03-22 13:13:48 -07:00
Slava Pestov
d0d5fbdf39 ASTDemangler: Introduce new getTypeDeclForMangling()
This will replace getDeclFromMangledSymbolName().

Progress on <rdar://problem/47819208>.
2019-02-22 16:13:02 -05:00
Slava Pestov
b2f0327516 IDE: Remove getTypeFromMangledSymbolname()
There was only one remaining usage other than in testing tools.

Note that when a declaration mangling was passed in, the old entry
point would (try to) return the type of the declaration.

The new entry point no longer has this behavior. I changed the
bridging-header-first test to run lldb-moduleimport-test with
-decl-from-mangled instead of -type-from-mangled-old to preserve
the behavior of the test.

Also, I removed test/DebugInfo/DumpTypeFromMangledName.swift
completely. This test only covered a handful of cases, and a bunch
of them were declaration manglings rather than type manglings.
The new tests in test/TypeDecoder/ are much more comprehensive.
2019-02-08 02:56:05 -05:00
Slava Pestov
9c8a5b599e ASTDemangler: Fix demangling of weak/unowned/unowned(unsafe)
The check here was incorrect because we might have an optional of a
reference type as well. Just remove the check to keep things simple.
2019-01-29 21:57:06 -05:00
Slava Pestov
a14f345c82 lldb-moduleimport-test: Add support for testing Demangle::getTypeForMangling()
The -type-from-mangled flag now uses the new API. The -type-from-mangled-old flag
uses the old API, ide::getTypeFromMangledSymbolname().

For now, just change all existing tests to use the -type-from-mangled-old flag;
I'll be adding new tests for the new API shortly.
2019-01-25 21:44:02 -05:00
Innovimax
335fe49b0e fix typo (#21473) 2018-12-20 21:37:55 -05:00
Adrian Prantl
d63debeb60 Experimental: Extend ClangImporter to import clang modules from DWARF
When debugging Objective-C or C++ code on Darwin, the debug info
collected by dsymutil in the .dSYM bundle is entirely
self-contained. It is possible to debug a program, set breakpoints and
print variables even without having the complete original source code
or a matching SDK available. With Swift, this is currently not the
case. Even though .dSYM bundles contain the binary .swiftmodule for
all Swift modules, any Clang modules that the Swift modules depend on,
still need to be imported from source to even get basic LLDB
functionality to work. If ClangImporter fails to import a Clang
module, effectively the entire Swift module depending on it gets
poisoned.

This patch is addressing this issue by introducing a ModuleLoader that
can ask queries about Clang Decls to LLDB, since LLDB knows how to
reconstruct Clang decls from DWARF and clang -gmodules producxes full
debug info for Clang modules that is embedded into the .dSYM budle.

This initial version does not contain any advanced functionality at
all, it merely produces an empty ModuleDecl. Intertestingly, even this
is a considerable improvement over the status quo. LLDB can now print
Swift-only variables in modules with failing Clang depenecies, and
becuase of fallback mechanisms that were implemented earlier, it can
even display the contents of pure Objective-C objects that are
imported into Swift. C structs obviously don't work yet.

rdar://problem/36032653
2018-12-05 13:54:13 -08:00
Saleem Abdulrasool
dd85d79105 tools: use target_link_libraries like clang (NFC)
Rather than using the `LINK_LIBRARIES` option, use target_link_libraries
like clang does.  Because these are all host tools, there is no name
mangling done for the libraries making this a no-op change.
2018-11-16 17:43:06 -08:00
swift-ci
8fb811262f Merge pull request #20577 from adrian-prantl/cl 2018-11-15 13:55:44 -08:00