Commit Graph

310 Commits

Author SHA1 Message Date
Saleem Abdulrasool
46d684f35f remove usage of BitstreamReader
LLVM SVN r286207 removed the BitstreamReader interface.  Remove the usage of the
type, updating the cursor constructor accordingly.
2016-11-15 17:39:37 -08:00
Bob Wilson
198cb095a8 Merge pull request #5233 from bob-wilson/module-file-undefined-behavior
Avoid undefined behavior with std::minmax and rvalues.
2016-10-11 13:08:42 -07:00
Bob Wilson
3d67d824ed Avoid undefined behavior with std::minmax and rvalues.
The behavior of std::minmax with rvalue arguments is undefined after the
end of the expression that contains the call to minmax. This code to
special-case the comparisons for ARM vs. Thumb and macOS vs. Darwin was a
little overly clever anyway. Rewrite it to use straightforward comparisons.
This fixes a test failure in Serialization/target-incompatible.swift when
building with a recent version of clang, because these checks were completely
optimized away due to the undefined behavior. rdar://problem/28700005
2016-10-11 11:04:52 -07:00
Jordan Rose
5d3a7f7c23 [serialization] Yet Another Misuse of ArrayRef (#5216)
I wonder if we can assert that the lifetime is valid or something.

rdar://problem/28699599
2016-10-10 16:24:25 -07:00
Jordan Rose
16c61bbbba [Serialization] Add some asserts to catch giant method lists.
This would have allowed us to triage rdar://problem/28305755 much
sooner. The actual problem is pretty bad: if you have too many methods
with the same selector, serialization just falls over.  "Too many" is
in the thousands, which seems unlikely, but 'dealloc' can actually get
there if there are a lot of little classes, and 'init' might as well,
so we really should do better here.
2016-10-06 14:07:04 -07:00
Argyrios Kyrtzidis
3bc81f7df4 [Serialization] Fix deserialization crash occurring when a mixed framework fails to load its ObjC part.
rdar://27709042
2016-08-04 15:59:05 -07:00
John McCall
c8c41b385c Implement SE-0077: precedence group declarations.
What I've implemented here deviates from the current proposal text
in the following ways:

- I had to introduce a FunctionArrowPrecedence to capture the parsing
  of -> in expression contexts.

- I found it convenient to continue to model the assignment property
  explicitly.

- The comparison and casting operators have historically been
  non-associative; I have chosen to preserve that, since I don't
  think this proposal intended to change it.

- This uses the precedence group names and higherThan/lowerThan
  as agreed in discussion.
2016-07-26 14:04:57 -07:00
Roman Levenstein
89c41ca2d4 [sil-serializer] Do not use RPOT order for serializing SIL basic blocks
My earlier patch started serializing SIL basic blocks using the RPOT order. While it works, changing the existing order of BBs during the serialization may be very surprising for users. After all, serialization is not supposed to transform the code.

Therefore, this patch follows a different approach. It uses the existing order of BBs during the serialization. When it deserializes/parses SIL and detects a use of an opened archetype before its definition, it basically introduced a forward definition of this opened archetype. Later on, when the actual definition of the opened archetype is found, it replaces the forward definition. There is a correctness check at the end of a SIL function deserialization, which verifies that there are no forward definitions of opened archetypes left unresolved.
2016-07-19 13:04:40 -07:00
practicalswift
57bccc8b06 [gardening] Fix inconsistent formatting. 2016-06-04 00:37:15 +02:00
Argyrios Kyrtzidis
8ce372dca9 [IDE] Move determination of the decl group at the Decl::getGroupName() caller. 2016-05-08 16:27:46 -07:00
Jordan Rose
8f820dea2b [serialization] Diagnose loading modules from older Swifts.
...with a better message than the generic "older version of the
compiler" one, when we know it's actually a different version of
Swift proper.

This still uses the same internal module version numbers to check
if the module is compatible; the presentation of language versions
is a diagnostic thing only.

Speaking of module version numbers, this deliberately does NOT
increment VERSION_MINOR; it's implemented in a backwards-compatible
way.

This will only work going forwards, of course; all existing modules
don't have a short version string, and I don't feel comfortable
assuming all older modules we might encounter are "Swift 2.2".

rdar://problem/25680392
2016-04-29 16:25:33 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Slava Pestov
1ce1e78951 AST: Record -sil-serialize-all in the ModuleDecl
We want to distinguish the special case of a library built with
-sil-serialize-all, from a SIL function that is [fragile] because
of an explicitly @_transparent or @inline(__always).

For now, NFC.
2016-03-28 14:14:49 -07:00
Xi Ge
fda0751cae [SourceKit] In interface-gen request, allow clients to send SourceKit an interested USR from which we can infer the group name. 2016-03-23 17:26:44 -07:00
Xi Ge
3dd149ab99 [SourceKit] CursorInfo: The result of cursor info for a module name starts to include group names in that module. 2016-03-21 17:20:18 -07:00
Xi Ge
d0e176810f [Serialization] Serialize doc comments for extensions. Need this for rdar://25157796
We did not serialize them because getting USR for extensions is tricky (USRs are
usually for value decls). This commit starts to make up an USR for an extension by combining
the extended nominal's USR with the USR of the first value member of the extension. We use
this made-up USR to associate doc comments when (de)serializing them.
2016-03-15 13:35:07 -07:00
Xi Ge
09cd9c1f9d ModulePrinting: Fix several issues pointed by Ben. 2016-03-08 18:34:38 -08:00
Ben Langmuir
92a91810e4 Make getGroupDecl static 2016-03-08 18:04:55 -08:00
Xi Ge
c84f667676 [Serialization] Serialize the source order of Decls appearing in their original source file.
We used to think the source order is preserved after de-serialization; however, this seems to be
not the case.
2016-03-08 12:18:10 -08:00
Xi Ge
7a3276738b Re-apply "ModulePrinter: Print decls from the same source file near each other."
This reverts commit 1db83907e3.
2016-03-08 12:18:10 -08:00
Xi Ge
1db83907e3 Revert "ModulePrinter: Print decls from the same source file near each other."
This reverts commit a5c9072344 for mysterious bot test failure.
2016-03-07 23:33:23 -08:00
Xi Ge
a5c9072344 ModulePrinter: Print decls from the same source file near each other. 2016-03-07 22:51:50 -08:00
Xi Ge
65a3aade7e [SourceKit] Cursor info: for extension decls, the cursor info query always returns the extended nominal's group name. 2016-03-02 17:30:11 -08:00
Xi Ge
2db856e5f9 Simplify some code, NFC. 2016-02-24 16:21:42 -08:00
Slava Pestov
5e020e62da Nuke more trivial usages of getDeclaredTypeInContext(), NFC 2016-02-16 23:08:57 -08:00
Jordan Rose
e7e0a87db2 Merge pull request #1254 from jrose-apple/Fixnum
Replace uses of llvm::Fixnum with llvm::PointerEmbeddedInt.
2016-02-11 13:06:45 -08:00
Xi Ge
9aa3d01101 [Serialization] Avoid serializing source orders, trust deserialized decls in preserving such order. rdar://24610992
Thank Jordan for suggesting this.
2016-02-11 12:24:38 -08:00
Jordan Rose
36a44cf308 Replace uses of llvm::Fixnum with llvm::PointerEmbeddedInt.
The two types are nearly identical, and Fixnum is only in the Swift branches of LLVM,
not in mainline LLVM.

I do want to add ++ to PointerEmbeddedInt and fix some of this ugliness, but that'll
have to go through LLVM review, so it might take a bit.
2016-02-11 09:52:07 -08:00
Xi Ge
767fba9c92 Rename BriefAndRawComment to CommentInfo. NFC 2016-02-10 19:27:21 -08:00
Xi Ge
98734f588a [Serialization] Serialize and deserialize source order in module doc files. 2016-02-10 17:46:49 -08:00
Xi Ge
329345077b [SourceKit] Add a new query to collect all group names from a module.
Input:
  Request Id: 'source.request.module.groups'
  Required field: 'key.modulename'

Output:
  Array of group names in that module, if any.
2016-02-08 17:22:10 -08:00
Ben Langmuir
cfff55e989 [InterfaceGen] Fix deserializing submodule ImportDecls
Use the isScoped() bit to distinguish scoped imports from submodule
imports (both of which are split by null bytes in the string) so that we
don't try to lookup a submodule name as if it were a decl (leading to
assertion failures when it wasn't found).

This fixes interface generation of swift modules that import clang
submodules.

rdar://problem/24534122
2016-02-08 17:00:23 -08:00
Slava Pestov
3af2ddd957 Serialization: Fix a warning, NFC 2016-02-05 18:14:15 -08:00
Xi Ge
a25551e54d [SourceKit] Surface group names via cursor info query. 2016-02-05 16:56:41 -08:00
Xi Ge
33b4de7ff6 [Serialization] Add grouping information of Stdlib to its module documentation file and deserialize it into ModuleFile.
We currently do not support more sophisticated naming mechanisms; group names are stemmed source file names.
2016-02-05 16:56:41 -08:00
Doug Gregor
1a830fa541 SE-0022: Deprecate string-literal-as-selector in favor of #selector.
Introduce Fix-Its to aid migration from selectors spelled as string
literals ("foo:bar:", which is deprecated), as well as from
construction of Selector instances from string literals
(Selector("foo:bar"), which is still acceptable but not recommended),
to the #selector syntax. Jump through some hoops to disambiguate
method references if there are overloads:

    fixits.swift:51:7: warning: use of string literal for Objective-C
         selectors is deprecated; use '#selector' instead
      _ = "overloadedWithInt:" as Selector
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          #selector(Bar.overloaded(_:) as (Bar) -> (Int) -> ())

In the cases where we cannot provide a Fix-It to a #selector
expression, we wrap the string literal in a Selector(...) construction
to suppress the deprecation warning. These are also easily searchable
in the code base.

This also means we're doing more validation of the string literals
that go into Selector, i.e., that they are well-formed selectors and
that we know about some method that is @objc and has that
selector. We'll warn if either is untrue.
2016-01-28 10:58:27 -08:00
practicalswift
8efa5f587e [gardening] Remove "-*- C++ -*-" tag from .cpp files
Emacs assumes .h files are C files by default which is why the
tag "-*- C++ -*-" is needed.

.cpp files do not have this problem.
2016-01-23 12:09:32 +01:00
Slava Pestov
81267ce1db AST: Serialize -enable-resilience flag on the ModuleDecl
Since resilience is a property of the module being compiled,
not decls being accessed, we need to record which types are
resilient as part of the module.

Previously we would only ever look at the @_fixed_layout
attribute on a type. If the flag was not specified, Sema
would slap this attribute on every type that gets validated.

This is wasteful for non-resilient builds, because there
all types get the attribute. It was also apparently wrong,
and I don't fully understand when Sema decides to validate
which decls.

It is much cleaner conceptually to just serialize this flag
with the module, and check for its presence if the
attribute was not found on a type.
2016-01-16 02:23:27 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
practicalswift
ef849258c6 Fix typo: ambigous → ambiguous 2015-12-13 23:56:40 +01:00
Jordan Rose
3028dc8f44 Failure to load a bridging header -> failure to load a module.
This is important for both test targets and for debugging.

rdar://problem/20616099

Swift SVN r30784
2015-07-30 00:39:35 +00:00
Jordan Rose
98ed31fb99 Make -import-underlying-module automatically export that module.
That's how everything behaved anyway. Might as well make it explicit and
stop special-casing it.

I've left in compatibility for modules built with older compilers so that
people using the OS toolchains aren't immediately unable to debug their apps.
As soon as we change the module format in a more significant way, I can take
this out.

Groundwork for rdar://problem/21254367; see next commit.

Swift SVN r29437
2015-06-17 04:47:39 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
Jordan Rose
f0d529719c Deduplicate search paths.
Now that we can pick up search paths from frameworks (necessary to debug
them properly), we can end up with exponential explosions leading to the
same search path coming up thousands of times, which destroys compilation
time /and/ debugger responsiveness. This is already hitting people with
frameworks compiled for app extensions (due to a mistaken approximation
of whether or not something is a framework), but we're turning this on for
all frameworks in the immediate future.

rdar://problem/20291720

Swift SVN r27087
2015-04-07 18:24:12 +00:00
Jordan Rose
960a4f164a Add LangOptions::EnableTargetOSChecking, so that LLDB can ignore OS mismatches.
In particular, this is problematic when libraries are loaded dynamically, and
may have newer deployment targets than the main executable.

Swift SVN r26786
2015-04-01 01:12:29 +00:00
Doug Gregor
8b97f911c6 Reimplement (de-)serialization of protocol conformances.
Primarily, unique normal protocol conformances and reference them via
a conformance ID. This eliminates the use of trailing records for
normal protocol conformances and (more importantly) the cases were we
would write incomplete conformances. The latter could cause problems
if we ever ended up deserializing an incomplete conformance without
also deserializing a complete record for that same conformance.

Secondarily, simplify the way we write conformances. They are now
always trailing records, and we separate out the derived conformance
kinds (specialized/inherited) from either a reference to a normal
conformance in the current module file (via a normal conformance ID)
or via a cross-reference to a conformance in another module file
(currently always a normal conformance, but this need not always be
the case). As part of this, make each conformance record
self-sustaining, so we don't have to push information down to the
reading routines (e.g., the conforming type) to actually produce a
proper conformance. This simplifies deserialization logic further.

Swift SVN r26482
2015-03-24 06:48:23 +00:00
Jordan Rose
e6c2131bda Check that "@testable import Foo" is only used to import testable modules.
(i.e. modules compiled with -enable-testing)

Part of testability (rdar://problem/17732115)

Swift SVN r26293
2015-03-19 02:20:41 +00:00
Luqman Aden
34b74cfa1c [driver] Add -emit-sib primary action.
Swift SVN r25783
2015-03-05 19:15:07 +00:00
Dmitri Hrybenko
f6faf8ad81 sil-opt: implement partial AST verification
... and use it to parallelize the parse_stdlib.sil test, which was
taking too long.

Swift SVN r25295
2015-02-14 11:48:11 +00:00