Commit Graph

72 Commits

Author SHA1 Message Date
Adrian Prantl
e70a3443e9 [Debug Info] Remove the mostly unused FragmentType from DebugTypeInfo
This cleanup allows for more consistent debug info emission since we depend less
on IRGen magic to emit debug info for types.
2025-01-27 17:28:10 -08:00
Gabor Horvath
6d24c52b80 [cxx-interop] Use the locations imported from C++
A recent PR (#77204) started to import C++ source locations into Swift.
This PR flips a switch so these locations are actually used more widely.
Now some of the diagnostic locations are changed, but they generally
improved the quality of the diagnostics, pointing out conformances
imported from Obj-C code right when they are declared.
2024-11-01 13:49:09 +00:00
Zak Kent
a459c97d74 [SILGen] [Test] Address code review comments 2023-08-08 11:25:11 -07:00
Zak Kent
3b4e94f65b [SILGen] Emit toplevel code through emitFunctionDefinition
Emit SILDeclRefs representing entry points with SourceFile
source correctly.
2023-08-08 11:25:11 -07:00
Bob Wilson
213efe089c Merge commit '06120c9d9d1a28275a0ecd7466775b1d71716be7' into stable-update-5.1 2019-02-17 10:20:59 -08:00
Bob Wilson
5e16a652b5 master-next: Update DebugInfo tests for llvm r347806
Check for the DISPFlagDefinition flag instead of "isDefinition: true".
2019-02-08 14:22:56 -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
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
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -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
Slava Pestov
748107b42e Migrate DebugInfo tests to Swift 4 2018-06-26 16:56:33 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Pavel Yaskevich
600b15821d [Mangling/ABI] NFC: Fix DebugInfo tests to reflect label mangling changes 2017-12-18 15:44:24 -08:00
Adrian Prantl
8e309c0570 Adapt testcases to upstream changes in llvm-dwarfdump. 2017-09-12 16:04:06 -07:00
Alex Hoppen
1c7e289b96 [Mangling] Adjust subscript mangling to not include "subscript"
Change the mangling of accessors to have a variable or subscript node
as their only child node, while subscript nodes no longer contain a decl
name.
2017-09-10 19:44:07 +02:00
John McCall
80b180a9a1 Implement a syntactic peephole to recognize explicit bridging
conversions that reverse an implicit conversion done to align
foreign declarations with their imported types.

For example, consider an Objective-C method that returns an NSString*:
  - (nonnull NSString*) foo;
This will be imported into Swift as a method returning a String:
  func foo() -> String
A call to this method will implicitly convert the result to String
behind the scenes.  If the user then casts the result back to NSString*,
that would normally be compiled as an additional conversion.  The
compiler cannot simply eliminate the conversion because that is not
necessarily semantically equivalent.

This peephole recognizes as-casts that immediately reverse a bridging
conversion as a special case and gives them special power to eliminate
both conversions.  For example, 'foo() as NSString' will simply return
the original return value.  In addition to call results, this also
applies to call arguments, property accesses, and subscript accesses.
2017-07-15 01:13:41 -04: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
Erik Eckstein
2a55b26e46 Mangling: enable new mangling for symbols 2017-03-16 12:04:08 -07:00
Michael Gottesman
dfa39c1f22 [lit] Make sure that we use the just built llvm-dwarfdump in lit and update debug info tests accordingly. 2016-09-25 02:54:06 -07:00
Adrian Prantl
9f060dc5b7 Bump the DWARF format to version 4 on all platforms.
This unifies the output across all supported platforms and
brings swiftc in sync with clang.

<rdar://problem/28231982>
2016-09-12 09:31:38 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Joe Groff
1e8dd0e34b ClangImporter: Import unbounded NSSets and NSDictionaries using AnyHashable. 2016-07-26 13:36:05 -07:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00
Adrian Prantl
0fac43e11f Adapt to upstream LLVM changes.
<rdar://problem/25949511+25962000>

(cherry picked from commit df9dfac609d17cd26d6107f17024c937b1b5b1a2)
2016-05-13 22:04:00 -07:00
Adrian Prantl
44b2d4851c Debug info: Factor out the test for hidden global variables into a
separate test that is not depending on Foundation.

<rdar://problem/26133649>
2016-05-06 10:55:41 -07:00
Saleem Abdulrasool
4bfdc5c4d4 test: apply some fix-its to DebugInfo tests
These tests were causing the current swift compiler to emit fix-it hints for
changes since the tests were written.  NFC.
2016-05-05 10:24:19 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
Adrian Prantl
4c6fd6a8a6 Remove an obsolete check from this test. 2016-02-04 10:41:02 -08:00
Adrian Prantl
7e96d4486b Add back an accidentally deleted REQUIRES line. 2016-02-04 10:41:01 -08:00
Adrian Prantl
88faa3b690 Emit debug info for the compiler-generated field type accessors.
Failing to do so will lead to hard-to-debug verifier errors in LLVM
when these functions get inlined.
2016-02-04 10:11:12 -08:00
David Farler
8a5ed405bf Make var parameters an error for Swift 3
This finishes up revisions to SE-0003 - only var function parameters
are disallowed for Swift 3.
2016-01-30 12:39:17 -08:00
David Farler
3f635d04c7 Reinstante var bindings in refutable patterns, except function parameters.
This reverts commits: b96e06da44,
                      8f2fbdc93a,
                      93b6962478,
                      64024118f4,
                      a759ca9141,
                      3434f9642b,
                      9f33429891,
                      47c043e8a6.

This commit leaves 'var' on function parameters as a warning to be
merged into Swift 2.2. For Swift 3, this will be an error, to be
converted in a follow-up.
2016-01-29 15:27:08 -08:00
Dmitri Gribenko
f5153572d7 stdlib: rename count labels in underscored protocols
lengthInBytes => utf8CodeUnitCount

numberOfCodeUnits => utf16CodeUnitCount
2016-01-21 17:18:15 -08:00
Dmitri Gribenko
73ce9ae7e9 Collection.count => .length
And other API changes that naturally fall out from this, like
Array(repeating:count:) => Array(repeating:length:).
2015-12-17 15:55:29 -08:00
David Farler
8f2fbdc93a Make function parameters and refutable patterns always immutable
All refutable patterns and function parameters marked with 'var'
is now an error.

- Using explicit 'let' keyword on function parameters causes a warning.
- Don't suggest making function parameters mutable
- Remove uses in the standard library
- Update tests

rdar://problem/23378003
2015-11-09 16:56:13 -08:00
Joe Groff
2368ce774b Remove self types from mangling by default.
And include some supplementary mangling changes:

- Give the first generic param (depth=0, index=0) a single character mangling. Even after removing the self type from method declaration types, 'Self' still shows up very frequently in protocol requirement signatures.
- Fix the mangling of generic parameter counts to elide the count when there's only one parameter at the starting depth of the mangling.

Together these carve another 154KB out of a debug standard library. There's some awkwardness in demangled strings that I'll clean up in subsequent commits; since decl types now only mangle the number of generic params at their own depth, it's context-dependent what depths those represent, which we get wrong now. Currying markers are also wrong, but since free function currying is going away, we can mangle the partial application thunks in different ways.

Swift SVN r32896
2015-10-26 22:05:20 +00:00
Adrian Prantl
2f9f964219 Change the contract between Swift compiler and LLDB about how the function
prologue is handled in the line table.
We now mark the first instruction after the stack setup as end_prologue and
any further initilizations (which may include function calls to metadata
accessors) with line 0 which lldb will skip. This allows swiftc to emit
debug info for compiler-generated functions such as metadata accessors.
Mixing debug and non-debug functions is not very well supported by LLVM
and the resulting line table makes it impossible for LLDB to determine
where a function with debug info ends and a nondebug function starts.

rdar://problem/23042642

Swift SVN r32816
2015-10-22 00:20:03 +00:00
John McCall
e1eb240603 Speculatively revert a debug-info-implicating change in my
last series of patches in an attempt to placate the build.

Swift SVN r32548
2015-10-09 03:44:41 +00:00
John McCall
7f975f000b Generalize code emission for lazy metadata caches; we'll use this
for non-dependent protocol witness tables, too.

Swift SVN r32540
2015-10-09 01:06:03 +00:00
Michael Gottesman
6d74962918 Adapt all DebugInfo testcases to the new upstream LLVM metadata format.
Swift SVN r31813
2015-09-09 04:37:34 +00:00
Adrian Prantl
4f11ecc1da Get rid of Int in the debug info tests and preform some general cleanup.
<rdar://problem/20856296> Extinguish 'Int' from DebugInfo tests

Swift SVN r31177
2015-08-12 18:16:43 +00:00
Adrian Prantl
c5dd8bea82 Debug Info: Migrate from MDModule to DIModule.
MDModule was a bitcode-incompatible internal-only extension that has
since been replaced with a blessed IR node on trunk.

<rdar://problem/20965932> Upstream DIModule and support it in clang-700, swiftlang-700, and lldb-700

Swift SVN r29832
2015-07-01 02:25:22 +00:00
Adrian Prantl
96cc406c7d Debug Info: Ensure classes report their storage size correctly
by wrapping them in a pointer-sized struct as we do for all things passed
by reference.

Fixes rdar://21409965

Swift SVN r29455
2015-06-17 18:19:00 +00:00
Adrian Prantl
46135489f8 Remove a stale fixme comment.
Swift SVN r29454
2015-06-17 18:18:55 +00:00
Adrian Prantl
ab4467dc03 Debug Info: Set the mangled name for temporary composite types
and use DIBuilder::replaceTemporary() to RAUW temporary debug nodes.
This enables more opportunities for IR debug type uniquing.

Swift SVN r29410
2015-06-16 23:29:22 +00:00
Joe Groff
32fb006386 Clang Importer: Enable OptionSetType import.
Update the tests to match.

Swift SVN r28906
2015-05-22 05:47:37 +00:00
Dmitri Hrybenko
0fce5c7b4e tests: remove uses of println() that are not relevant to the tests
Swift SVN r28016
2015-05-01 03:35:50 +00:00
Doug Gregor
a815ab7386 Don't eagerly check protocol conformances for Clang-imported AST nodes.
The Clang importer introduces a number of synthesized conformances for
imported enums (normal, NS_ENUMS, or NS_OPTIONS-based all have the
same issue) that aren't used in most translation units. Rather than go
through the effort of fully checking these conformances and generating
SIL for them always, rely on semantic analysis to force them to be
fully checked when the conformance is required. This cuts down on the
amount of work we need to do for imported enumeration types
considerably. For a simple program consisting of only:

    import Foundation
    var str = NSString()

My not-entirely-scientific measurements show that:
  * Time to parse + type-check is reduced by 34%
  * Time to generate SIL is reduced by 50%
  * Time to generate IR is reduced by 47%
  * SIL output size is reduced by 66%

Fixes rdar://problem/20047340.

Swift SVN r27946
2015-04-29 23:20:54 +00:00