Commit Graph

144 Commits

Author SHA1 Message Date
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Artem Chikin
57518b5894 Do not escape UNICODE when writing out target info.
Escaping unicode characters results in invalid JSON.

- Refactor writeEscaped routine into StringExtras

Resolves rdar://90108531
2022-03-16 15:30:21 -07:00
Ben Langmuir
5ce7bf9c18 Use std::reverse_iterator_range
We're using c++14, so no need to use the llvm:: copy of this. The llvm
version is going away, so this fixes build errors on the "next" branch.
2022-02-24 13:49:28 -08:00
Rintaro Ishizaki
7ef93b2a67 [Basic] Move copyCString to Basic/StringExtras.
Also, use StringRef.copy() instead of copyString().
2022-02-18 11:34:45 -08:00
Evan Wilde
42ff140171 llvm::StringRef equals_lower -> equals_insensitive
The `equals_lower` API was replaced with `equals_insensitive` in llvm
commit 2e4a2b8430aca6f7aef8100a5ff81ca0328d03f9 and
3eed57e7ef7da5eda765ccc19fd26fb8dfcd8d41.

Ran git clang-format.

(cherry picked from commit e21e70a6bf)
2021-07-02 10:55:17 -07:00
Evan Wilde
0919c2cd70 StringRef ends/startswith-lower -> insensitive
Updating StringRef startswith and endswith API to use insensitive rather
than lower.

(cherry picked from commit 1b8b39e6de)
2021-07-02 10:55:17 -07:00
Doug Gregor
ae3049f4b9 [Importer] Make sure we drop "WithBlock" as a completion-handler suffix.
Fixes rdar://73641827.
2021-02-09 15:00:32 -08:00
Robert Widmann
17a2bc5212 [NFC] Use std::mismatch Now That We Live In The Future 2020-12-08 18:20:20 -08:00
Doug Gregor
719e2201c8 [Concurrency] Move "extra" text from completion handler parameter to base name.
When a completion-handler parameter has text before, e.g.,
"WithCompletionHandler", put the extra text on the base name rather
than the corresponding parameter. This ensures that we don't lose the
detail from the text, but always put it into a consistent place.
2020-12-07 16:47:31 -08:00
Doug Gregor
b837675910 [Concurrency] Introduce more completion-handler names to the import heuristics.
Extend the set of completion-handler names we look for to infer an
`async` import of an Objective-C method, which includes:

* (with)CompletionBlock
* (with)reply
* (with)replyTo

both as parameter names and as base name suffixes.
2020-12-07 16:47:31 -08:00
Doug Gregor
16104d8045 [Concurrency] Don't lose name information from completion-handler arguments.
When a completion handler parameter has a selector piece that ends with
"WithCompletion(Handler)", prepend the text before that suffix to the
base name or previous argument label, as appropriate. This ensures that
we don't lose information from the name, particularly with delegate names.
2020-10-22 13:32:03 -07:00
Doug Gregor
8521453af3 [Concurrency] Drop "Asynchronously" suffix from imported 'async' methods.
The "Asynchronously" is a needless word for an "async" function. Remove
it.
2020-10-21 21:57:30 -07:00
Doug Gregor
24ea8becc8 [Concurrency] Move removal of leading "get" for async imports.
Name adjustments should be performed by omitNeedlessWords(), not the
early classifcation of async imports.
2020-10-21 21:48:52 -07:00
Jordan Rose
9ecd9abc84 Merge pull request #27750 from jrose-apple/omit-more-needle-swords
Further simplifications to omitNeedlessWords
2019-10-17 10:33:43 -07:00
Jordan Rose
e24c9e755d omitNeedlessWords: Fix self-type-stripping regression (#27742)
Turns out self-type-stripping /always/ operates on a type without
prefixes rather than /never/. Neither of these behaviors are really
what we'd want, but we'll live with it!

rdar://problem/56334797
2019-10-17 09:46:56 -07:00
Jordan Rose
f93811ae24 omitNeedlessWords: use drop_back to simplify suffix stripping 2019-10-16 19:55:48 -07:00
Jordan Rose
2465f5c2c3 omitNeedlessWords: Remove dead code from base name splitting
"and" is not a preposition, so we'll never get a false preposition
match for "and return".
2019-10-16 19:55:48 -07:00
Jordan Rose
6db1e020c2 omitNeedlessWords: Avoid an extra temporary SmallString
Yeah, SmallVectorImpl<char> is less convenient to work with, but
that's no reason to write out a stack buffer and then do a copy.

No functionality change.
2019-10-16 19:55:47 -07:00
Jordan Rose
1ef99c533c omitNeedlessWords: don't bother lowercasing an intermediate name
All of the remaining name-matching logic is case-insensitive, and
the resulting name will have a stronger form of lowercasing applied
anyway, so we can leave the name with a leading uppercase letter in
its intermediate state. Slightly less pure, but also slightly less
code and slightly less memory use.
2019-10-16 19:55:47 -07:00
Jordan Rose
a5d521698c omitNeedlessWords: separate BaseName in trailing type name matching
Method base names are where the most complicated logic is, so let's
split it out from the other cases a bit. Also makes early returns more
explicit.

No intended functionality change.
2019-10-16 19:55:47 -07:00
Jordan Rose
0f071e28ea Simplify getPrepositionKind to isPreposition
No one was distinguishing directional and non-directional prepositions
anymore. No functionality change.
2019-10-16 19:55:46 -07:00
Jordan Rose
86de8b8257 omitNeedlessWords: Rename helper: omitTrailingTypeNameWithSpecialCases
Previously this was /also/ called 'omitNeedlessWords'. Rename it to
avoid confusion and better describe the particular step it's taking.

I don't love the "with special cases" but I think it's important to
note that this isn't an exact parallel of matchLeadingTypeName.
2019-10-10 10:48:14 -07:00
Jordan Rose
758e727e07 omitNeedlessWords: Use existing helpers getPriorStr and getRestOfStr
...rather than asking WordIterators for their position and then
immediately calling StringRef::substr.

No functionality change.
2019-10-10 10:48:13 -07:00
Jordan Rose
e1e885ed7d omitNeedlessWords: delete accidentally dead code
StringRef::drop_back returns a new string instead of mutating the
existing one, so this check would never actually make a
difference. Drat.
2019-10-10 10:48:13 -07:00
Jordan Rose
42f7a35c4d omitNeedlessWords: sink helper enum into .cpp file
No functionality change.
2019-10-10 10:48:12 -07:00
Jordan Rose
3fdbd1b154 omitNeedlessWords: split out BaseNameSelf omission
This is the only omission kind that needs to look in the middle of a
name rather than just at the start or the end. So, handle that
explicitly instead to simplify all the other code.
2019-10-10 10:48:12 -07:00
Jordan Rose
981d1a9fab omitNeedlessWords: Factor out matchTypeNameFromBackWithSpecialCases
Separate the functional searching bit from the actual "omitting" bit
once the type name is matched. This in turn provides a good place to
flip from reverse iterators back to forward iterators, making the
following code about omitting a fair bit clearer.

No functionality change. This is 90% moving things around and 10%
rephrasing.
2019-10-10 10:48:11 -07:00
Jordan Rose
e22d55d27b omitNeedlessWords: Early exit instead of using a big if
Also, use Optional instead of a value and a separate flag.

No functionality change.
2019-10-10 10:48:11 -07:00
Sam Lazarus
2a38b48eea Parse / AST: Allow let / var as argument labels with a warning.
The diagnostic is now a warning and the new message alerts the user that
though it is valid to have let and var as argument label names,
they are interpreted as argument labels, not keywords.
2019-04-26 04:08:01 -04:00
Sho Ikeda
b506cbadb2 Merge pull request #15205 from ikesyo/stringextras-stringswitch
[NFC][StringExtras] Use llvm::StringSwitch in canBeArgumentLabel as with canBeMemberName
2018-03-16 11:58:28 +09:00
Sho Ikeda
521b6598a7 [NFC][StringExtras] Use llvm::StringSwitch in canBeArgumentLabel as with canBeMemberName 2018-03-14 00:59:39 +09:00
Sho Ikeda
eaf33e0998 [gardening][lib/Basic] Replace typedef with using 2018-03-13 13:46:38 +09:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Michael Gottesman
16165482f4 [gardening] Eliminate dead never read variable. Found with clang-tidy. 2016-12-06 23:54:23 -08:00
Michael Gottesman
1af1cbfb76 [gardening] Add a bunch of end namespace comments found by clang-tidy. 2016-12-06 19:22:52 -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
17503b0d85 [gardening] Use American English. 2016-11-06 10:12:04 +01:00
Robert Widmann
6accc5989e Disable the ability to use '$' as an identifier harder
When in Swift 3 Compatibility Mode we now acceptable a standalone
'$' as an identifier.  In all other cases this is now disallowed
and must be surrounded by backticks.
2016-10-27 16:51:18 -04:00
Joe Groff
aac85cb93f SIL: Introduce a 'closure' convention for unapplied invocation functions.
We don't want the machine calling conventions for closure invocation functions to necessarily be tied to the convention for normal thin functions or methods. NFC yet; for now, 'closure' follows the same behavior as the 'method' convention, but as part of partial_apply simplification it will be a requirement that partial_apply takes a @convention(closure) function and a box and produces a @convention(thick) function from them.
2016-10-17 15:55:04 -07:00
Ben Langmuir
04107ed8b2 Revert "[omit-needless-words] Fix a bug found by -Wunused-result" 2016-09-14 14:27:32 -07:00
Ben Langmuir
7562c10333 [omit-needless-words] Fix a bug found by -Wunused-result
StringRef::drop_back() returns the new string; it doesn't mutate `this`.
2016-09-14 13:52:59 -07:00
Robert Widmann
9c83e7223e Fixup diagnostics around type(of:) and dynamicType handling
Be laxer about the parsing for type(of:) so as not to get in the way of
other declarations that may use ‘type’ as their base name.
2016-07-30 03:24:05 -07:00
Doug Gregor
5bea187b0f [Omit needless words] Fix lowercasing of initialisms with two-letter initial words.
Fixes rdar://problem/26643039.
2016-06-13 18:15:43 -07:00
Doug Gregor
7b226ad177 [Omit Needless Words] Don't remove a first argument label when the parameter has as default argument.
Parameters that have default arguments should have argument labels;
don't remove them on import. Fixes rdar://problem/26611977.
2016-06-13 11:58:41 -07:00
Doug Gregor
1d39707311 [Omit needless words] Don't split "PlugIn".
Fixes rdar://problem/26334014.
2016-06-12 23:13:01 -07:00
Doug Gregor
c390c97255 [Clang importer] Minor fixes for swift_newtype name adjustments. 2016-05-07 14:44:48 -07:00
Doug Gregor
b6c68449a7 [Omit needless words] Don't avoid keywords that will be allowed after '.'.
In anticipation of SE-0071, teach the Clang importer to only avoid
dynamicType/self/Protocol/init as base names. Fixes
rdar://problem/25399965.
2016-04-26 17:02:35 -07:00
Doug Gregor
a82cc07ee0 [Omit needless words] Strip context from "set" methods.
Fixes rdar://problem/25750367.
2016-04-26 16:42:35 -07:00
Doug Gregor
6e680798ae [Omit needless words] Treat "separated by" as a single preposition.
Fixes rdar://problem/25883450.
2016-04-26 16:05:08 -07:00