Commit Graph

45 Commits

Author SHA1 Message Date
Michael Gottesman
d0219b6f7a [stlextras] Add overloads for binary_search that take containers. 2019-11-15 12:57:39 -08:00
Jordan Rose
7b0d081965 Remove IteratorRange in favor of llvm::iterator_range
Now that llvm::iterator_range has 'empty', there's not enough reason to
keep our own version of it in the Swift repo.

No functionality change.
2019-10-08 11:23:28 -07:00
Jordan Rose
262f6864c2 Remove unused swift::FilterIterator and swift::FilterRange
No functionality change ("unused")
2019-10-02 10:23:19 -07:00
Jordan Rose
8b8c88e258 Improve swift::TransformRange enough to delete TransformArrayRef
We have a lot of "transform a range" types already:
llvm::mapped_iterator, swift::TransformRange and
swift::TransformIterator, and swift::ArrayRefView for static
transformations. This gets rid of one more layer without losing
any real functionality.
2019-10-02 10:23:05 -07:00
Michael Gottesman
7b2fc076f7 [sil] Add new API ValueBase:getUsersOfType<T>().
For some time now we have had the API ValueBase::getSingleUserOfType<T>() but we
never implemented getUsersOfType<T>() using transform/filter iterators.

Since there wasn't a specific API, several incarnations of this API have been
created for BeginBorrow, LoadBorrow, BeginAccess.

In this commit, I introduce the API and use it to excise the redundant code in
those above mentioned 3 instructions.
2019-09-06 16:40:51 -07:00
Michael Gottesman
69f6000921 [opt-transform-range] Do not assume that Range::iterator exists.
The reason not to do this is that some important range
adapters (e.x. llvm::iterator_range) do not have such a typedef. Rather than
changing upstream this commit just fixes the problem by inferring the iterator
type from the result of Range::begin().

TLDR: This makes OptionalTransformRange work with llvm::iterator_range.
2019-09-05 19:52:20 -07:00
Michael Gottesman
9c58e4b0a3 [patternmatch] Add InstructionOperand_match to support for matching against instructions with misc number of operands.
NOTE:

1. To test this I changed UnaryOp_match to use this under the hood.

2. These types of m_##ID##Inst matchers now will only accept compound types and
I added a static assert to verify that this mistake doesn't happen. We
previously had matchers that would take an int or the like to match tuple
extract patterns. I converted those to use TupleExtractOperation that also
properly handles destructures.
2019-08-05 17:26:02 -07:00
Jordan Rose
844ae38722 Remove some Swift STLExtras that LLVM now provides (#26443)
No functionality change.
2019-07-31 18:34:52 -07:00
David Ungar
663760e3b7 ASTOOScope ontology 2019-05-28 10:48:22 -07:00
Jordan Rose
f6c7973911 Teach -verify-apply-fixes to handle overlapping fix-its (#23970)
...by coalescing duplicates and dropping conflicts. Both cases can
happen with "expected-error 2 {{...}}": we might get multiple fix-its
providing the same new message, or one message might have diverged
into two, giving us incompatible changes.
2019-04-12 13:19:54 -07:00
Jordan Rose
4bfe4eff6d [ParseableInterfaces] Add -prebuilt-module-cache-path to the frontend
When trying to load a swiftinterface, search this directory before
doing all the work of building a swiftmodule.
2018-12-17 18:23:28 -08:00
Sho Ikeda
9c3e4848bf [gardening][Basic] Replace typedef with using 2018-03-28 21:27:26 +09:00
Michael Gottesman
a05f4f6666 [stl-extras] Add a range version of std::accumulate. 2017-10-09 13:36:18 -07:00
Jordan Rose
9a04bee421 [ClangImporter] Turn ImportNameVersion into a struct.
...so that we don't have to keep coming back to update it every major
release. And also so we can actually put methods on it instead of
using free functions.

No intended behavior change (yet).
2017-09-15 14:30:24 -07:00
Michael Gottesman
7248221d40 [stl-extras] Provide next_or_default and prev_or_default helpers for iterators.
These work like next_or_end or prev_or_begin, except that instead of forcing the
default value to be the compared against the value, you can specify the value
used upon going out of range.

i.e., instead of:

(x, y) -> (x == y) ? y : std::next(x)

We have:

(x, y, z) -> (x == y) ? z : std::next(x)

This is a strict generalization of next_or_end and prev_or_begin so I
re-implemented both routines in terms of the new routines, so no source needed
to be updated.
2017-09-09 16:23:12 -07:00
Bob Wilson
b87f9d0d4e master-next: Change TransformIterator to work with bidirectional iterators.
The custom DFS implementation for dominators in LLVM r307727 uses a reverse
iterator and so fails to build if SILBasicBlocks do not support that.
2017-07-14 10:40:15 -07:00
Michael Gottesman
e11daa8ddf [upstream-update] Do not use succ_iterator in GraphTraits. Use succblock_iterator instead.
rdar://31790907
2017-04-26 16:50:57 -07:00
Michael Gottesman
aa76c2a5e6 [silgen] (mark_uninitialized (project_box (alloc_box))) -> (project_box (mark_uninitialized (alloc_box)))
I put in a simple fixup pass (MarkUninitializedFixup) for staging purposes. I
don't expect it to be in tree long. I just did not feel comfortable fixing up in
1 commit all of the passes up to DI.

rdar://31521023
2017-04-17 17:45:54 -07:00
Michael Gottesman
e34bbdf2fb [semantic-sil] Create a new higher level API for accessing the ownership checker. It is meant to be used by passes.
rdar://29870610
2017-04-05 14:34:21 -07:00
Andrew Trick
1abeddcc5d [SILType] SILFunctionConventions API.
Separate formal lowered types from SIL types.
The SIL type of an argument will depend on the SIL module's conventions.
The module conventions are determined by the SIL stage and LangOpts.

Almost NFC, but specialized manglings are broken incidentally as a result of
fixes to the way passes handle book-keeping of aruments. The mangler is fixed in
the subsequent commit.

Otherwise, NFC is intended, but quite possible do to rewriting the logic in many
places.
2017-01-26 15:35:48 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Michael Gottesman
6f3c1ee658 Add a new ArrayRefView like structure called TransformArrayRef.
The difference is that TransformArrayRef stores its function as an std::function
instead of using a template parameter. This is useful in situations where one
wants to define such a type in a header on forward declared pointers. If one had
to define the function to be used as a template parameter, one would have to
define the function or provide a forward declared version
2016-12-18 01:11:14 -08:00
Michael Gottesman
0bfda96ace [sil-func-extractor] Teach sil-extract to extract a list of functions and the inverse of a list of functions. Also rename to sil-func-extractor to make it clearer what it is doing.
This will allow for modules to be split from the command line using a script.

The one thing that is missing from this still is that it does not handle shared
functions in IMO a satisfactory way. Given that we are splitting a module, my
feeling that the correct way to do this is to create a public shim for the
shared function in the module that the shared function gets put in and let all
other users use that entry point.

But I need to think about this a bit more.
2016-12-08 18:29:33 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift
566bfc0d56 [gardening] Fix typos. 2016-10-13 22:19:08 +02:00
Francis Ricci
66dcad0d34 SIL: Avoid dereferencing sentinel nodes in ilist_iterators
The behaviour of ilist has changed in LLVM.  It is no longer permissible to
dereference the `end()` value.  Add a check to ensure that we do not
accidentally dereference the iterator.
2016-10-12 11:46:31 -07:00
Dan Raviv
29d76f3b68 Canonize swift header files headers and footers
- Added missing ifdef guard in PointerIntEnum header
- Consistent naming convention for ifdef guards
- Consistent 'end namespace swift'
- Consistent single EOL at end of header files
2016-03-23 09:04:12 +02:00
Michael Gottesman
6434e5b032 Some small fixes suggested by Jordan to ImmutablePointerSet.
The larger changes are coming in a subsequent commit.
2016-02-16 02:13:55 -08:00
Michael Gottesman
f09749791a [arc] Move some code that is STL like from ImmutablePointerSet.h -> STLExtras.h
Specifically:

1. set_union_for_each. This is like std::for_each, but it visits its inputs
(which are assumed to be sorted/uniqued sets) in set_union order.
2. is_uniqued_and_sorted.

I also fixed several nits from Jordan.
2016-02-15 14:16:05 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Michael Gottesman
389238e801 Add support for multiple @_semantics attributes at the SIL level.
This is something that we have wanted for a long time and will enable us to
remove some hacks from the compiler (i.e. how we determine in the ARC optimizer
that we have "fatalError" like function) and also express new things like
"noarc".
2016-01-02 04:17:07 -06:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
fa0b339a21 Fix typos. 2015-12-26 17:51:59 +01:00
Michael Gottesman
c29236cc89 When sort/uniqueing exiting regions for processing, unique not by pointer value, but by ID. 2015-12-15 00:36:56 -06:00
Michael Gottesman
315b9c40b6 Add comment and self documentation of the requirements for sortUnique.
Specifically:

1. Use std::enable_if to enforce that the passed in collection's iterator is a
random access iterator.
2. Add comment that explains that the container must have an erase method that
can remove a range of items specified by a random access iterator.

Swift SVN r25015
2015-02-05 20:19:33 +00:00
Michael Gottesman
41912c9523 Add STLExtra sortUnique(vector).
This helper function takes in a vector-like object and then performs:

  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());

Swift SVN r25003
2015-02-05 19:11:32 +00:00
Jordan Rose
5ad871ecd6 Adopt llvm::function_ref for callbacks that aren't persisted.
...removing a few other constructs that were doing the same thing
(mostly from me).

No functionality change.

Swift SVN r23294
2014-11-13 00:19:03 +00:00
Jordan Rose
3fcdfd40e9 Remove the "swift/Basic/Optional.h" header.
llvm::Optional lives in "llvm/ADT/Optional.h". Like Clang, we can get
Optional in the 'swift' namespace by including "swift/Basic/LLVM.h".

We're now fully switched over to llvm::Optional!

Swift SVN r22477
2014-10-02 18:51:45 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Dmitri Hrybenko
d225e496e6 Fix warnings about && nested in ||
Swift SVN r22326
2014-09-28 01:55:18 +00:00
Dmitri Hrybenko
67e52caaab Fix a bug in TransformRange::empty()
Swift SVN r22315
2014-09-27 22:51:18 +00:00
Doug Gregor
0043652979 NFC: Replace DeclFilterRange with an elaborate set of iterator and range adaptors.
We're going to want these various adaptors, and helpers built on top
of them, when we replace the array-based storage of members in nominal
types and extensions with something more sane.


Swift SVN r16569
2014-04-19 18:19:59 +00:00
Joe Groff
9f12e2e4a4 Enable same-type concrete constraints, e.g. <T: P where T.Assoc == Int>
Let ArchetypeType nested types and PotentialArchetypes be bound to concrete types in addition to archetypes. Constraints to outer context archetypes still suffer type-checker issues, but constraints to true concrete types should work now.

Swift SVN r14832
2014-03-08 17:18:17 +00:00
Jordan Rose
9d5c803aff Enable specific-decl imports.
Note that the import kind is not checked yet; this is effectively our old
behavior for "import swift.print".

Infrastructure: move Module::forAllVisibleModules out-of-line, and add
makeStackLambda to STLExtras for using a non-escaping lambda with
std::function.

Swift SVN r6852
2013-08-02 21:00:41 +00:00
Jordan Rose
e3999dde36 [serialization] Handle absent protocol conformances.
These still need to be serialized, because they are one-to-one with the
type's protocol list, but don't actually require any data. Found on
attempting to emit a module for the standard library.

Most of the churn here is moving Interleave.h to a more general STLExtras.h.

Swift SVN r6167
2013-07-11 18:38:50 +00:00