Commit Graph

711 Commits

Author SHA1 Message Date
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
Slava Pestov c2029db223 ASTMangler: Verify that debug manglings round-trip
Add an IRGen flag to disable this verification, since it doesn't work from within
lldb itself for some reason, and I don't want to investigate it right now.
2019-02-05 00:07:53 -05:00
adrian-prantl 7e3357a39b Merge pull request #22313 from adrian-prantl/47600180
Cache clang ASTFile information in swift::Module (NFC from the outside).
2019-02-03 10:06:11 -08:00
Adrian Prantl 761e9a0fb2 Cache clang ASTFile information in swift::Module (NFC from the outside).
The loading of additional modules by Sema may trigger an out-of-date
PCM rebuild in the Clang module dependencies of the additional
module. A PCM rebuild causes the ModuleManager to unload previously
loaded ASTFiles. For this reason we must use the cached ASTFile
information here instead of the potentially dangling pointer to the
ASTFile that is stored in the clang::Module object.

This fixes a crash in IRGenDebugInfo when generation DIModule context
chains.

rdar://problem/47600180
2019-02-01 17:34:10 -08:00
Adrian Prantl 070101493d Remove unnecessary memory allocation 2019-02-01 09:57:40 -08:00
Robert Widmann c5b7230d22 [NFC] Upgrade EnumElementDecl to a DeclContext
Pure plumbing for the sake of default arguments.
2019-01-16 18:39:30 -05:00
Parker Schuh f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Adrian Prantl 10004edf49 Leave skeleton CU breadcrumbs fo imported Clang modules in the debug info.
This allows the debugger to look up Clang-imported type definitions in
the correct module.
2019-01-08 16:57:14 -08:00
Joe Groff 89979137fc Push ArchetypeType's API down to subclasses.
And clean up code that conditionally works only with certain kinds of archetype along the way.
2018-12-12 19:45:40 -08:00
Joe Groff f1648a1b3e Split subclasses out of ArchetypeType.
Context archetypes and opened existential archetypes differ in a number of details, and this simplifies the overlapping storage of the kind-specific fields. This should be NFC; for now, this doesn't change the interface of ArchetypeType, but should allow some refinements of how the special handling of certain archetypes are handled.
2018-12-12 08:55:56 -08:00
Davide Italiano 854dffb200 [DebugInfo] Stop handling InOut types, they'll be gone soon.
<rdar://problem/46043909>
2018-12-06 13:38:34 -08:00
Slava Pestov f49e0ba330 AST: Remove unused DeclContext and GenericEnvironment from mangling 2018-11-09 00:44:29 -05:00
John McCall cf511445e2 Basic support for Builtin.IntegerLiteral. 2018-10-31 18:42:34 -04:00
Adrian Prantl 0b32799972 Debug Info: Normalize paths when creating DIFile objects.
For a yet-to-be-determined reason the Clang SourceManager returns
source file paths with a ./ component before the filename if the
module cache is cold.

<rdar://problem/43439465>
2018-10-04 17:45:01 -07:00
Jordan Rose d412f4b4ba [IRGen] Adopt std::unique_ptr for IRGenDebugInfo (#19369) 2018-09-18 11:10:10 -07:00
Adrian Prantl 25cb6f61a6 Fix nonasserts compilation 2018-09-11 08:31:00 -07:00
Adrian Prantl 1ed922bfcf Add a -verify-linetable LLVM option.
While stepping through Swift programs in LLDB I noticed that sometimes
the line table entries go like this:

  foo(bar(baz)) // Some auxiliary code for the entire expression.
  ^

  foo(bar(baz))
      ^

  foo(bar(baz)) // And then back again for that actual call to foo.
  ^

This verification step is aimed at identifying situations like this so
they can be fixed.
2018-09-10 14:20:22 -07:00
Adrian Prantl 909f95cc5f Use <compiler-generated> as the filename for SILLocation-less functions
to avoid misleading source locations in backtraces.

rdar://problem/39116765
2018-09-05 08:49:46 -07:00
John McCall b80618fc80 Replace materializeForSet with the modify coroutine.
Most of this patch is just removing special cases for materializeForSet
or other fairly mechanical replacements.  Unfortunately, the rest is
still a fairly big change, and not one that can be easily split apart
because of the quite reasonable reliance on metaprogramming throughout
the compiler.  And, of course, there are a bunch of test updates that
have to be sync'ed with the actual change to code-generation.

This is SR-7134.
2018-08-27 03:24:43 -04:00
Slava Pestov 527ff375dc AST: Rename old form of {Generic,}FunctionType::get() to getOld()
This makes it easier to grep for and eventually remove the
remaining usages.

It also allows you to write FunctionType::get({}, ...) to call the
ArrayRef overload empty parameter list, instead of picking the Type
overload and calling it with an empty Type() value.

While I"m at it, in a few places instead of renaming just clean up
usages where it was completely mechanical to do so.
2018-08-17 19:28:17 -04:00
Jordan Rose 537954fb93 [AST] Rename several DeclContext methods to be clearer and shorter (#18798)
- getAsDeclOrDeclExtensionContext -> getAsDecl

This is basically the same as a dyn_cast, so it should use a 'getAs'
name like TypeBase does.

- getAsNominalTypeOrNominalTypeExtensionContext -> getSelfNominalTypeDecl
- getAsClassOrClassExtensionContext -> getSelfClassDecl
- getAsEnumOrEnumExtensionContext -> getSelfEnumDecl
- getAsStructOrStructExtensionContext -> getSelfStructDecl
- getAsProtocolOrProtocolExtensionContext -> getSelfProtocolDecl
- getAsTypeOrTypeExtensionContext -> getSelfTypeDecl (private)

These do /not/ return some form of 'this'; instead, they get the
extended types when 'this' is an extension. They started off life with
'is' names, which makes sense, but changed to this at some point.  The
names I went with match up with getSelfInterfaceType and
getSelfTypeInContext, even though strictly speaking they're closer to
what getDeclaredInterfaceType does. But it didn't seem right to claim
that an extension "declares" the ClassDecl here.

- getAsProtocolExtensionContext -> getExtendedProtocolDecl

Like the above, this didn't return the ExtensionDecl; it returned its
extended type.

This entire commit is a mechanical change: find-and-replace, followed
by manual reformatted but no code changes.
2018-08-17 14:05:24 -07:00
Adrian Prantl 556c8e5a2f Add initial support for debug info for coroutine allocas.
Unfortunately the example I was testing this with still crashed IRGen later on...

<rdar://problem/43296089>
2018-08-14 19:07:55 -07:00