Commit Graph

1132 Commits

Author SHA1 Message Date
swift-ci
463b04648e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-18 15:03:46 -07:00
Robert Widmann
5e34169aca Separate computing interface types and underlying types
Computing the interface type of a typealias used to push validation forward and recompute the interface type on the fly.  This was fragile and inconsistent with the way interface types are computed in the rest of the decls.  Separate these two notions, and plumb through explicit interface type computations with the same "computeType" idiom.  This will better allow us to identify the places where we have to force an interface type computation.

Also remove access to the underlying type loc.  It's now just a cache location the underlying type request will use.  Push a type repr accessor to the places that need it, and push the underlying type accessor for everywhere else.  Getting the structural type is still preferred for pre-validated computations.

This required the resetting of a number of places where we were - in many cases tacitly - asking the question "does the interface type exist".  This enables the removal of validateDeclForNameLookup
2019-09-17 08:20:55 -07:00
swift-ci
232757a0e8 Merge remote-tracking branch 'origin/master' into master-next 2019-08-27 12:49:52 -07:00
swift-ci
ffb338e8b1 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-27 12:44:34 -07:00
swift-ci
e61c1cc32c Merge pull request #26871 from adrian-prantl/49233932-pch 2019-08-27 12:36:10 -07: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
swift-ci
2943eb940c Merge remote-tracking branch 'origin/master' into master-next 2019-08-20 07:50:31 -07:00
swift-ci
b025c3099d Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-20 07:43:58 -07:00
Davide Italiano
4fd07ef20c [IRGenDebugInfo] Enable an assertion. 2019-08-19 14:48:52 -07:00
Jonas Devlieghere
b4d268e9e1 Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances in the swift repo.
2019-08-15 11:32:39 -07:00
Brent Royal-Gordon
fb20b503ba Merge branch 'master' into master-rebranch
# Conflicts:
#	lib/ClangImporter/ClangImporter.cpp
#	test/IRGen/builtins.swift
#	test/IRGen/enum.sil
#	tools/driver/autolink_extract_main.cpp
#	utils/build-presets.ini
2019-08-08 17:07:59 -07:00
Joe Groff
d38a72c4ad Merge branch 'master' into master-next 2019-07-18 13:14:39 -07:00
Erik Eckstein
ffd7f75de3 IRGen: debug info generation for cond_fail messages.
To display a failure message in the debugger, create a function in the debug info which has the name of the failure message.
The debug location of the trap/cond_fail is then wrapped into this function and the function is declared as "inlined".
In case the debugger stops at the trap instruction, it displays the inline function, which looks like the failure message.
For example:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x0000000100000cbf a.out`testit3(_:) [inlined] Unexpectedly found nil while unwrapping an Optional value at test.swift:14:11 [opt]
   11
   12   @inline(never)
   13   func testit(_ a: Int?) -> Int {
-> 14     return a!
   15   }
   16

This change is currently not enabled by default, but can be enabled with the option "-Xllvm -enable-trap-debug-info".
Enabling this feature needs some changes in lldb. When the lldb part is done, this option can be removed and the feature enabled by default.
2019-07-16 14:51:18 +02:00
Brent Royal-Gordon
d5a2912a26 Revert "Better runtime failure messages (not yet enabled by default)" 2019-07-15 13:42:40 -07:00
Erik Eckstein
e915300e96 IRGen: debug info generation for cond_fail messages.
To display a failure message in the debugger, create a function in the debug info which has the name of the failure message.
The debug location of the trap/cond_fail is then wrapped into this function and the function is declared as "inlined".
In case the debugger stops at the trap instruction, it displays the inline function, which looks like the failure message.
For example:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x0000000100000cbf a.out`testit3(_:) [inlined] Unexpectedly found nil while unwrapping an Optional value at test.swift:14:11 [opt]
   11
   12   @inline(never)
   13   func testit(_ a: Int?) -> Int {
-> 14     return a!
   15   }
   16

This change is currently not enabled by default, but can be enabled with the option "-Xllvm -enable-trap-debug-info".
Enabling this feature needs some changes in lldb. When the lldb part is done, this option can be removed and the feature enabled by default.
2019-07-12 14:03:13 +02:00
swift-ci
1bf7d48111 Merge remote-tracking branch 'origin/master' into master-next 2019-06-14 08:29:18 -07:00
adrian-prantl
caabba56c7 Merge pull request #25435 from adrian-prantl/51343998
Remove a workaround in the debug info handling of zero-sized types.
2019-06-14 08:20:56 -07:00
swift-ci
41616e4a46 Merge remote-tracking branch 'origin/master' into master-next 2019-06-12 21:09:29 -07:00
Slava Pestov
198e8d1a1f AST: Introduce a new debug-only mangling for @escaping @convention(block) functions
Our mangling did not encode if an Objective-C block was escaping or
not. This is not a huge problem in practice, but for debug info we
want type reconstruction to round-trip exactly. There was a previous
workaround to paper over this specific problem.

Remove the workaround, and add a new 'XL' mangling for escaping
blocks. Since we don't actually want to break ABI compatibility,
only use the new mangling in DWARF debug info.
2019-06-12 19:10:19 -07:00
Adrian Prantl
a0463a83f1 Remove a workaround in the debug info handling of zero-sized types.
This fixes potential LLVM verifier errors in exploded variables with undefined
elments, because a few lines below the size of fragments is derived from the
size of the LLVM SSA value and the constant used in the deleted workaround is
always an i64.

rdar://problem/51343998
2019-06-12 16:48:01 -07:00
Saleem Abdulrasool
1749f3e869 IRGen: adjust for SVN r360108
`DINodeRef` no longer need `resolveType()`.
2019-05-07 12:51:13 -07:00
Joe Groff
6c779bb487 Merge pull request #24445 from jckarter/opaque-type-remote
Debugger support for opaque types.
2019-05-03 08:18:59 -07:00
Adrian Prantl
e63caa4d45 Debug Info: Mark variables without source location as artificial.
rdar://problem/50349713
2019-05-01 15:18:15 -07:00
Joe Groff
7f76ed6d62 IRGen: Render opaque types like other archetypes in debug info. 2019-04-30 13:44:59 -07:00
Nathan Lanza
f837a9eeef Fix bug where inlined scopes where being inlined twice for codeview
A workaround in codeview debuginfo generation was to declare a condfail
instruction as inlined to avoid using 0 as an artificial line location.

However, this was done without accounting for scopes that were already
legitimately inlined. So we'd end up with a condfail inlined from
function B into function A and then the IRGen for the condfail was
being given a debugloc claiming to have been inlined again. This was
causing a sitaution where we'd have debug info forfunctionA owning an
instruction which claimed it was owned by a different function.

Fix this by first checking if the `LastScope` was already inlined and,
if so, just used that scope instead.
2019-04-23 12:40:48 -07:00
adrian-prantl
f75dea49df Merge pull request #23910 from adrian-prantl/49751363
Record parseable interface imports in the debug info.
2019-04-19 14:23:57 -07:00
Joe Groff
f363a10b3b runtime interface fixup irgen 2019-04-17 14:44:40 -07:00
Joe Groff
dd2b51d6dc Add an OpaqueTypeArchetypeType subclass. 2019-04-17 14:43:32 -07:00
Adrian Prantl
8d03cb7a61 Record parseable interface imports in the debug info.
When a Swift module built with debug info imports a library without
debug info from a textual interface, the textual interface is
necessary to reconstruct types defined in the library's interface.  By
recording the Swift interface files in DWARF dsymutil can collect them
and LLDB can find them.

rdar://problem/49751363
2019-04-11 14:50:07 -07:00
Adrian Prantl
4a23512068 Add an option to disable DWARF skeleton CU breadcrumbs for Clang
module imports. This is useful when building redistributable static
archives, since any pointers into the CLang module cache won't be
portable.

When using this option the Clang type fallback path in LLDB will be
less useful since DWARF type information from those modules will not
be available unless another object file compiled without the option
imported the same modules.

rdar://problem/48827784
2019-04-03 15:45:11 -07:00
swift-ci
a533081226 Merge pull request #23628 from DavidGoldman/master 2019-04-03 11:07:39 -07:00
Jordan Rose
0ba6c495ba Add @_implementationOnly
This is an attribute that gets put on an import in library FooKit to
keep it from being a requirement to import FooKit. It's not checked at
all, meaning that in this form it is up to the author of FooKit to
make sure nothing in its API or ABI depends on the implementation-only
dependency. There's also no debugging support here (debugging FooKit
/should/ import the implementation-only dependency if it's present).

The goal is to get to a point where it /can/ be checked, i.e. FooKit
developers are prevented from writing code that would rely on FooKit's
implementation-only dependency being present when compiling clients of
FooKit. But right now it's not.

rdar://problem/48985979
2019-03-28 15:57:53 -07:00
Jordan Rose
9ed3fe061d Change ModuleDecl::getImportedModules to take an option set
...in preparation for me adding a third kind of import, making the
existing "All" kind a problem. NFC, except that I did rewrite the
ClangModuleUnit implementation of getImportedModules to be simpler!
2019-03-28 14:44:41 -07:00
David Goldman
2801c2f230 Add DebugPrefixMap remapping back to module creation
This was accidentally removed in commit 10004e.
2019-03-28 15:32:50 -04:00
Adrian Prantl
0b8fc3d405 Remove Resilience workarounds and describe fixed-size global resilient
variables in DWARF.

rdar://problem/48409386
2019-03-27 10:51:16 -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
adrian-prantl
7035047868 Revert " Stop producing line and file debug information for clang::Decls." 2019-03-05 08:28:17 -08:00
Adrian Prantl
b63ab4534b Stop producing line and file debug information for clang::Decls.
It would be nice to query the clang::SourceManager for the source
location of the clang::Decl in IRGenDebugInfo, but module out-of-date
rebuilds may unload previously loaded clang::Modules and thus also
invalidate source locations pointed to, leading to a use-after-free
here. If this functionality is desired, the source location must be
captured by ClangImporter and stored on the side.

LLDB does not actually make use of this information for non-C++ types
(it is really helpful with debugging the debug info itself, though),
so we can avoid the potential use-after-free and crash by not doing it.

<rdar://problem/48509051>
2019-03-04 14:36:29 -08:00
Slava Pestov
135ce781e2 IRGen: Don't emit debug info for dependent member types
Fixes rdar://40706055
2019-03-02 00:17:15 -05:00
Adrian Prantl
3b7353a2a7 Minor code cleanups (NFC) 2019-02-20 16:04:16 -08:00
Adrian Prantl
54af8e461f Debug Info: Encode Archetype names in DWARF
Currently LLDB calls into ide::getDeclFromMangledSymbolName() to get
to this information and we would like to get rid of this call.

rdar://problem/47798056
2019-02-20 16:04:16 -08:00
Bob Wilson
213efe089c Merge commit '06120c9d9d1a28275a0ecd7466775b1d71716be7' into stable-update-5.1 2019-02-17 10:20:59 -08:00
adrian-prantl
70140a2d0a Merge pull request #22392 from adrian-prantl/DIFiles
Bring the Swift frontend's handling of DIFiles in synch with CFE.
2019-02-14 19:34:40 -08:00
Slava Pestov
c8622538ca IRGen: DebugTypeInfo doesn't need a DeclContext or GenericEnvironment 2019-02-13 21:51:28 -05:00
Slava Pestov
d0c7b1547e ASTMangler: Mangle sugared types for the debugger
Fixes <rdar://problem/48004306>.
2019-02-13 19:17:25 -05:00
Saleem Abdulrasool
0dda7662e6 IRGen: adjust for SVN r347239
DW_TAG_subprogram has its own flag word now.  Adjust building the debug info.
2019-02-08 14:22:56 -08:00
Bob Wilson
b0dd41b8ab [master-next] Use the new AST getBeginLoc API instead of getLocStart
The getLocStart API is deprecated and slated for removal from LLVM
very soon. Switch to use getBeginLoc instead. I did not see any uses
of the corresponding getLocEnd API.
2019-02-07 16:53:03 -08:00
Adrian Prantl
711e1f3d14 Debug Info: Emit Clang-imported typedef declarations in the correct scope. 2019-02-07 14:30:07 -08:00
Adrian Prantl
21f2c3d35b Bring the Swift frontend's handling of DIFiles in synch with CFE.
This applies the same changes from Clang CFE r349065 to the Swift
frontend to unify how filenames, cmpilation directories and absolute
paths in filenames and path remappings are handled.
2019-02-06 09:00:32 -08:00
Slava Pestov
cc8236f7d0 AST: ASTMangler should not depend on ASTDemangler
ASTDemangler depends on ClangImporter, etc.
2019-02-05 21:03:33 -05:00