Commit Graph

29 Commits

Author SHA1 Message Date
Bob Wilson
390058972a [master-next] Use PRIVATE in target_link_libraries for executables
This is needed to work with LLVM r319840.
2017-12-06 21:55:22 -08:00
Davide Italiano
d74dd7df74 [gardening] Remove more unused lambda captures. NFCI. (#11908) 2017-09-13 17:16:31 -07:00
Davide Italiano
e30b1f5101 [AST/Unittest] Don't swallow a const qualifier.
I found this by inspection (also, I found that newer
clang versions also warns for this under -Wall). While here,
convert to static_cast<> for a more idiomatic C++.
2017-09-11 18:04:43 -07:00
Xi Ge
34e2aec662 Parser: use parser to generate a refined token stream to help syntax coloring. (#11809)
This patch allows Parser to generate a refined token stream to satisfy tooling's need. For syntax coloring, token stream from lexer is insufficient because (1) we have contextual keywords like get and set; (2) we may allow keywords to be used as argument labels and names; and (3) we need to split tokens like "==<". In this patch, these refinements are directly fulfilled through parsing without additional heuristics. The refined token vector is optionally saved in SourceFile instance.
2017-09-08 10:28:19 -07:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Jordan Rose
5f30eac288 Excise "Accessibility" from the compiler (1/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the names of methods, fields, a few local
variables, and even a swift-ide-test flag. The full list is below.

accessibilityForDiagnostics -> accessLevelForDiagnostics
checkAccessibility -> checkAccess
checkGenericParamAccessibility -> checkGenericParamAccess
checkTypeAccessibility -> checkTypeAccess
checkWitnessAccessibility -> checkWitnessAccessibility
computeAccessibility -> computeAccessLevel
computeDefaultAccessibility -> computeDefaultAccessLevel
fixItAccessibility -> fixItAccess
getAccessibilityString -> getAccessLevelString
getAccessibilityStrictly -> getAccessLevelStrictly
getAccessibilityUID -> getAccessLevelUID
getActualAccessibility -> getActualAccessLevel
getDefaultAccessibility -> getDefaultAccessLevel
getMaxAccessibility -> getMaxAccessLevel
getOverridableAccessibility -> getOverridableAccessLevel
getRawStableAccessibility -> getRawStableAccessLevel
getSetterAccessibility -> getSetterFormalAccess
hasAccessibility -> hasAccess
hasDefaultAccessibility -> hasDefaultAccessLevel
inferAccessibility -> inferAccessLevel
inferDefaultAccessibility -> inferDefaultAccessLevel
inferSetterAccessibility -> inferSetterAccessLevel
overwriteAccessibility -> overwriteAccess
overwriteSetterAccessibility -> overwriteSetterAccess
printAccessibility -> printAccess
requiredAccessibilityForDiagnostics -> requiredAccessForDiagnostics
resolveAccessibility -> resolveAccessControl
setAccessibility -> setAccess
setSetterAccessibility -> setSetterAccess
setDefaultAndMaxAccessibility -> setDefaultAndMaxAccess
validateAccessibility -> validateAccessControl

Accessibility -> AccessLevel
AccessibilityFilter -> AccessFilter
IgnoreAccessibility -> IgnoreAccessControl
NL_IgnoreAccessibility -> NL_IgnoreAccessControl
PrintAccessibility -> PrintAccess
PrintInternalAccessibilityKeyword -> PrintInternalAccessKeyword
SetterAccessibility -> SetterAccessLevel

setterAccessibility -> setterAccess
storedPropertyAccessibility -> storedPropertyAccess

-print-accessibility -> -print-access
2017-08-28 11:11:57 -07:00
Jordan Rose
b4759bc8e2 [Parse] Split ParseSIL out into its own library.
...finally breaking the dependency of Parse on Sema.

There are still some unfortunate dependencies here -- Xi's working on
getting /AST/ not dependent on Sema -- but this is a step forward.

It is a little strange that parseIntoSourceFile is in ParseSIL, and
therefore that that's still a dependency for anyone trying to, well,
parse. However, nearly all clients that parse want to type-check as
well, and that requires Sema, Serialization, and the ClangImporter...
and Serialization and SIL currently require each other as well
(another circular dependency). So it's not actively causing us trouble
right now.
2017-07-17 12:18:41 -06:00
Jordan Rose
1ab51ea3bd Hack: allow dropping noescape-ness when overriding ObjC methods (#10775)
In today's Swift, only non-optional function parameters can be
non-escaping (and are by default). An optional function parameter uses
a function type as a generic argument to Optional, and like any other
generics that's considered an opaque and therefore possibly escaping
use of the type. This is certainly unfortunate since it means a
function parameter cannot be both Optional and non-escaping.

However, this "unfortunate" becomes a concrete problem when dealing
with Objective-C, which /does/ allow applying its 'noescape' attribute
to a callback block marked 'nullable'. This is fine for /uses/ of
methods with such parameters, but prevents anyone from /overriding/
these methods.

This patch pokes a very narrow hole into the override checking to
accomodate this: if a declaration comes from Objective-C, and it has
an optional, non-escaping closure parameter, it's okay to override it
in Swift with an optional, escaping closure parameter. This isn't
strictly safe because a caller could be relying on the
non-escaping-ness, but we don't have anything better for now. (This
behavior will probably be deprecated in the future.)

(Some people have noted that the old 'noescape' type attribute in
Swift still works, albeit with a warning. That's not something people
should have to type, though---we want to remove it from the language,
as described in SE-0103.)

rdar://problem/32903155
2017-07-10 16:03:37 -07:00
Robert Widmann
ac5594dabe Use a meaningful representation of parameter specifiers
In anticipation of future attributes, and perhaps the ability to
declare lvalues with specifiers other than 'let' and 'var', expand
the "isLet" bit into a more general "specifier" field.
2017-06-29 16:03:49 -07:00
Jordan Rose
f170b94bba [AST] Don't allow IUO-to-non-optional in non-parameter positions.
The previous logic accidentally propagated the "is parameter" flag
into any number of nested tuples. Fix this by differentiating between
"input of a function type" and "member of a tuple that's the input of
a function type".
2017-05-04 17:48:48 -07:00
Jordan Rose
c333b0b071 [AST] Generalize TypeBase::canOverride to TypeBase::matches.
This allows fuzzy matching of top-level optionals in types, using the
same logic we use to fuzzy-match potential overrides.
2017-05-04 17:48:48 -07:00
Graydon Hoare
3a79d83233 Forward declare TypeRepr in TypeLoc.h, adjust other code to compensate. 2017-04-18 11:12:53 -07:00
Maxwell Swadling
9edb93693b Updated the tests for when the AssignExpr's EqualLoc is invalid 2017-01-26 12:31:37 +11:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Brian Gesiak
4108e1d9af [Sema] Mark VarDecl in capture lists
Fixes SR-2757.

Variables in capture lists are treated as 'let' constants, which can
result in misleading, incorrect diagnostics. Mark them as such in order
to produce better diagnostics, by adding an extra parameter to the
VarDecl initializer.

Alternatively, these variables could be marked as implicit, but that
results in other diagnostic problems: capture list variables that are
never used produce warnings, but these warnings aren't normally emitted for
implicit variables. Other assertions in the compiler also misfire when
these variables are treated as implicit.

Another alternative would be to walk up the AST and determine whether
the `VarDecl`, but there doesn't appear to be a way to do so.
2017-01-01 12:41:06 -05: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
Mishal Shah
f08601f550 Merge pull request #5321 from mxswd/tuple-expr-sourcerange
Updated TupleExpr's getSourceRange to inspect child elements source ranges
2016-10-18 16:16:58 -07:00
Maxwell Swadling
7f1f3b5aa2 fixed typo 2016-10-17 20:36:45 -07:00
Maxwell Swadling
3c7a17e261 Fixed a bug in AssignExpr that caused it to create invalid source ranges 2016-10-16 17:41:28 -07:00
Maxwell Swadling
5999021878 Fixed a bug in StmtConditionElement::getSourceRange where it would create invalid source ranges
This bug was causing an assert.
2016-10-16 16:34:59 -07:00
Maxwell Swadling
91e3c67493 Updated TupleExpr's getSourceRange to inspect child elements source ranges 2016-10-16 13:30:43 -07:00
Maxwell Swadling
dbeec26ac6 Added test for when the 2nd element of a tuple expr has an invalid source range
Also cleaned up the variable names
2016-10-12 09:55:20 -07:00
Maxwell Swadling
339e40fb02 Fixed an assert caused when a TupleExpr that didn't have a valid SourceRange had a valid SourceLoc for the first element but not for the last 2016-10-08 23:31:01 -07:00
Jordan Rose
4ec661d9b7 Fix the SourceRange of an AssignExpr with an implicit source.
Fixed by Maxwell Swadling, unit test by me.
2016-09-14 19:55:08 -07:00
Jordan Rose
2fdd456d91 [unittests] Factor out TestContext helper for AST tests.
This is used to set up a very simple AST context so that AST nodes
can be allocated as usual.

No functionality change.
2016-09-14 18:22:19 -07:00
Doug Gregor
211c580158 [Cleanup] Eliminate DerivedFileUnit.
The only client of DerivedFileUnit was synthesized global '=='
operators for Equatable conformances, which has since been removed.
2016-07-21 12:54:27 -07:00
Jordan Rose
996ee1ec53 Add an override-checking mode that allows mismatched optionals.
Not yet plugged into any actual features.
2016-04-15 17:18:10 -07:00
practicalswift
945c3cbcee [gardening] Fix recently introduced typo: "anothor" → "another" 2016-04-15 20:06:54 +02:00
Jordan Rose
fadf6b3c9f [unittest] Add some basic tests for TypeBase::canOverride.
Also, move the version lattice tests under a general "AST" test bundle.
2016-04-14 16:00:46 -07:00