Commit Graph

45 Commits

Author SHA1 Message Date
Adrian Prantl
45547be3f8 [Debug Info] Represent type alias existantials in debug info
Previously debug info made not difference between an existential type and a
protocol type. This caused us to loose typealiases such as

typealias Alias = ProtocolType

in the debug info.

rdar://161134092
2025-11-21 15:17:47 -08:00
Slava Pestov
a03b8ee6aa AST: Allow mangling LocatableType in DWARF mode
Fixes rdar://problem/145954323.
2025-03-04 22:00:44 -05:00
Augusto Noronha
72b0120b43 [DebugInfo] Fix handling of @_originallyDefinedIn types
Emit an imported declaration for @_originallyDefinedIn under the
real module that these types live in.

This patch also changes the mangling for the debugger to respect
@_originallyDefinedIn, and fixes a bug where @_originallyDefinedIn
that should be ignored was still being used when mangling.

rdar://137146961
2024-12-16 10:28:18 -08: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
Adrian Prantl
238c73e0d4 Update test to be more robust. 2023-08-23 17:07:12 -07:00
Slava Pestov
ac5b1df5aa ASTMangler: Don't consider @_originallyDefinedIn when mangling local type discriminators
Local types are not ABI, and the only time we care about the mangling here is
when we look them up using the DWARF mangling in debug info, which doesn't
respect @_originallyDefinedIn either.

Fixes https://github.com/apple/swift/issues/59773.
2022-07-19 12:22:29 -04:00
Richard Howell
95ea3dd261 DebugTypeExtRefs=false when DisableClangModuleSkeletonCUs=true 2021-06-08 14:39:42 -07:00
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -07:00
David Zarzycki
b1ac68b3b1 [test] Clang is now more strict about underlying type enums
As of c90e198107431f64b73686bdce31c293e3380ac7, clang is now more strict
about parsing of enum-base in order to follow C++11 rules.
2020-06-04 08:54:36 -04:00
Slava Pestov
ffd92f97d2 Add test case for <rdar://problem/63191951> 2020-05-26 22:59:08 -04:00
Erik Eckstein
f1ae1dc40e Fix some debugging on SIL level (-gsil) problems
* Fix multi-threaded IRGen: store the DeclContext in a SILFunction explicitly instead of deriving it from the debug location. It's used in IRGen to decide into which module a function is emitted. With -gsil the debug location is changed and that should not change the module decision.

* Erase debug_value/debug_value_addr instructions when using -gsil. Those instructions are not needed anymore. They can also trigger a verifier error.
2019-09-06 09:58:16 +02:00
Adrian Prantl
ce37ddf332 Debug Info: Record -gmodules breadcrumbs for PCH debug info.
Produce a DWO-style skeleton CU pointing to the PCH containing the
Clang debug info for types imported from a PCH. This allows
DWARFIMporterDelegate to find the type definitions there.

<rdar://problem/49233932>
2019-08-27 09:16:53 -07:00
Adrian Prantl
6a412bd2f5 Debug Info: Fix a bug when decoding the source file for a Clang Decl
that was defined using a Macro: Use the file of the presumed location,
not of the SourceBuffer.

rdar://problem/49181568
2019-03-26 14:16:11 -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
Adrian Prantl
711e1f3d14 Debug Info: Emit Clang-imported typedef declarations in the correct scope. 2019-02-07 14:30:07 -08:00
Davide Italiano
56e3da97cd Revert "[TypeRecontruction] Remove handling of InOutTypes."
This reverts commit 751550be1a.
2018-12-07 09:13:09 -08:00
Davide Italiano
751550be1a [TypeRecontruction] Remove handling of InOutTypes. 2018-12-06 17:31:43 -08:00
Robert Widmann
0e58b7fd14 Plumbing for a Virtual File System
Adds the -vfsoverlay frontend option that enables the user to pass
VFS overlay YAML files to Swift. These files define a (potentially
many-layered) virtual mapping on which we predicate a VFS.

Switch all input-based memory buffer reads in the Frontend to the new
FileSystem-based approach.
2018-07-31 13:16:14 -07:00
Doug Gregor
5350d45d6e [Mangler] Mangle generic typealiases in extensions of nested generics. 2018-06-26 16:54:57 -07:00
Doug Gregor
b3e536b333 [Type Reconstruction] Guard against wrong # of generic args for a typealias.
When we are attempting to reconstruct a type node for a generic typealias,
make sure that we get the right number of generic arguments. If not,
fail gracefully rather than crashing.

Eventually, we should be able to handle this nested case.
2018-06-26 13:48:13 -07:00
Davide Italiano
f657cfb49a [TypeReconstruction] Don't crash on null genericSignatureMap.
<rdar://problem/41343572>
2018-06-22 16:18:27 -07:00
Davide Italiano
0a6c3e3dc5 [TypeReconstruction] Dependent types can't have existential as bases.
This basically means the mangling isn't really quite valid, and
given we don't have a full compiler testcase to see what generates
this, we're going to reject this for now.

<rdar://problem/38931073>
2018-06-20 10:04:47 -07:00
Davide Italiano
6c5206dd69 [TypeReconstruction] Fix reconstruction for associated types.
<rdar://problem/38931073>
2018-06-19 16:22:12 -07:00
Davide Italiano
6e627b5bb1 [TypeReconstruction] Don't choke on slightly invalid mangled names.
This was taken from a real project, but I don't have it anymore
and I can't reproduce it on newer versions of swift (probably
something changed in the DWARF type mangling). In any case, as
this can be triggered by user input, we shouldn't assert, and
error out instead.

<rdar://problem/39283717>
2018-06-19 11:37:03 -07:00
Davide Italiano
ec40a5414c [TypeReconstruction] Fix reconstruction for existential metatypes.
Without this, we wouldn't be able to show an array of `Any.Type`
in the debugger.

Fixes <rdar://problem/40940701>.
2018-06-14 10:30:02 -06:00
Adrian Prantl
bab3000069 Use depth and index to lookup type metadata artificial variables
instead of using name and decl context.

The advantages of this approach are three-fold:
- This is necessary to support inlined generic functions.
- We can retire the debugger-specific type name manfgling mode for archetypes.
- This saves 270kb of debug information in the x86_64 libSwiftCore.dylib alone.

<rdar://problem/38306256>
2018-06-12 12:48:15 -07:00
Davide Italiano
dd65d69ed5 [TypeReconstruction] Fix reconstruction for VarDecls.
We were previously asserting on the following tree:
kind=Global
  kind=Variable
    kind=Module, text="EyeCandySwift"
    kind=PrivateDeclName
      kind=Identifier, text="_ADC08935D64EA4F796440E7335798735"
      kind=Identifier, text="_previousUniqueNumber"
    kind=Type
      kind=Structure
        kind=Module, text="Swift"
        kind=Identifier, text="UInt64"

<rdar://problem/39283527>
2018-05-21 14:39:50 -07:00
Davide Italiano
2a91041ea0 [TypeReconstruction] Add support for generic typealiases.
This fixes the compiler side of the problem.
An lldb test will be added to make sure this doesn't regress
in the future (or, if it does, at least we know).

<rdar://problem/40261592>.
2018-05-17 14:19:20 -07:00
Davide Italiano
8d3045dcb8 [TypeReconstruction] Handle InOutType when reconstructing elements.
Before, we were just ignoring it, and this resulted in the type
being reconstructed incorrectly when assertion were disabled, and
in an assertion firing otherwise (AST invariants being broken).

<rdar://problem/39248252>
2018-05-14 15:01:33 -07:00
Davide Italiano
ec18f4030b [TypeReconstruction] Don't silently swallow invalid mangled names.
The mangler had a bug when mangling associated types so we got
an invalid input. Instead of ignoring the fact it's invalid,
throw an error.

Eventually we'll refactor the visitor to fail at any point in
time, as suggested by Slava, but for now, at least, stop pretending
this is a valid mangling.
2018-03-29 10:27:42 -07:00
Davide Italiano
5587b39fcb [TypeReconstruction] Fix a crash when reconstructing protocols.
<rdar://problem/38849279>
2018-03-25 18:46:36 -07:00
Davide Italiano
5831fc9ec1 [TypeReconstruction] Fix reconstructions for allocator.
Adrian reported this bug he discovered as part of his
work on improving generics in swift/lldb.
Allocators were treated as `function`, when the demangle
tree suggests they're much more akin to constructors. On
top of that, the code for handling them was commented out,
so type reconstruction was always failing. I'm not entirely
sure this is always correct, but it seems to be an improvement
on what currently type reconstruction does. At least now
we have tests so if something will break, we're going to
notice.

<rdar://problem/38720742>
2018-03-22 11:51:11 -07:00
Davide Italiano
9dbd966e73 [lldb-moduleimport] Add the logic for testing getDeclBySymbolName().
Adrian already found and reported a bug, which I'm going to fix
in a later commit. Eventually this will go away, but in the meanwhile,
we should add test for this codepath.

<rdar://problem/38720742>
2018-03-22 10:47:24 -07:00
Davide Italiano
06ae7eeff5 [lldb-moduleimport-test] Add a way to test getTypeFromMangledSymbolName.
The only way we had to test this path was through swift-ide-test,
which takes an input a source file, instead of a serialized module.

This is not the scenario that lldb tests, hence this patch.

<rdar://problem/38323564>
2018-03-15 14:39:44 -07:00
Adrian Prantl
17496f3012 Simplify IRGenDebugInfo submodule creation and support homonymous submodules. 2017-05-24 14:00:07 -07:00
Adrian Prantl
c2b14dccd3 Debug info: Represent clang-imported submodules.
Previously an import of a submodule would emit debug info for
importing the root module.

<rdar://problem/17260802>
2017-05-03 08:33:55 -07:00
Adrian Prantl
9545af6fdf Rename testcase module.map to module.modulemap (NFC) 2017-05-01 09:53:33 -07:00
Adrian Prantl
3356f7ac59 Pass the debug info settings through to Clang and ensure that compile units
created by Swift and Clang set the CU's compilation dir similarly.

rdar://problem/22692266

Swift SVN r32637
2015-10-12 22:20:58 +00:00
Adrian Prantl
19017a287f Even more testcase tweaking: Make this a C module so it can be imported on
Linux.

Swift SVN r28632
2015-05-15 18:03:12 +00:00
Adrian Prantl
da2ad487d7 Cleanup: Remove the dependency on SwiftShims from this testcase and
relax the prerequisites.

Thanks Dmitri for noticing!

Swift SVN r28628
2015-05-15 17:19:36 +00:00
Jordan Rose
367160793b [test] Drop -enable-source-import from almost all tests that use IRGen.
-enable-source-import doesn't play nice with debug info, and we want to be
able to run all tests with -g added. The last few tests that require
-enable-source-import could be built with --no-debug-info, or however we
end up spelling that.

rdar://problem/18140021 (most of it)

Swift SVN r22742
2014-10-15 01:22:43 +00:00
Jordan Rose
fce31decdc Serialize bridging headers into the merged module file.
We do this so that the swiftmodule file contains all info necessary to
reconstruct the AST for debugging purposes. If the swiftmodule file is copied
into a dSYM bundle, it can (in theory) be used to debug a built app months
later. The header is processed with -frewrite-includes so that it includes
any non-modular content; the user will not have to recreate their project
structure and header maps to reload the AST.

There is some extra complexity here: a target with a bridging header
(such as a unit test target) may depend on another target with a bridging
header (such as an app target). This is a rare case, but one we'd like to
still keep working. However, if both bridging headers import some common.h,
we have a problem, because -frewrite-includes will lose the once-ness
of #import. Therefore, we /also/ store the path, size, and mtime of a
bridging header in the swiftmodule, and prefer to use a regular parse from
the original file if it can be located and hasn't been changed.

<rdar://problem/17688408>

Swift SVN r20128
2014-07-18 00:22:53 +00:00
Jordan Rose
9163bc3233 [test] Put a single empty.swift in test/Inputs.
Swift SVN r13666
2014-02-08 00:13:49 +00:00
Jordan Rose
cb83bb02a8 Provide the correct primary file name to IRGenOpts.
Previously, we were always using the first file name as the main source
file name in the debug info, which was completely wrong and led to only
that file having debug info.

<rdar://problem/15786017>, again.

Swift SVN r13665
2014-02-08 00:13:45 +00:00