Commit Graph

138 Commits

Author SHA1 Message Date
Doug Gregor
89e5e5b6fa Diagnose redeclarations of Objective-C methods.
@objc methods, initializers, deinitializers, properties, and
subscripts all produce Objective-C methods. Diagnose cases where two
such entities (which may be of different kinds) produce the same
Objective-C method in the same class.

As a special exception, one can have an Objective-C method in an
extension that conflicts with an Objective-C method in the original
class definition, so long as the original class definition is from a
different model. This reflects the reality in Objective-C that the
category definition wins over the original definition, and is used in
at least one overlay (SpriteKit).

This is the first part of rdar://problem/18391046; the second part
involves checking that overrides are sane.

Swift SVN r23147
2014-11-07 01:15:14 +00:00
Chris Lattner
d7bcbc3817 make ? a general operator character, allowing user defined operators like ??=. We already
reserve ? itself as a special token that cannot be defined (protecting ternary, postfix ?, 
etc) but add some defensive code to prevent people from defining those operators.

<rdar://problem/17923322> allow ? as a general operator character



Swift SVN r21051
2014-08-05 23:06:29 +00:00
Joe Groff
e733f1e816 Lexer: Accept variation selectors as continuations of operators.
Fixes mysterious "invalid character" errors when an operator character is followed by a variation selector.

Swift SVN r17807
2014-05-09 22:03:24 +00:00
Doug Gregor
3d4df3427a Pretty-print DeclNames with no keyword arguments by dropping the parenthsized bit.
Instead of printing "f(_:_:)", just print "f". 


Swift SVN r17078
2014-04-30 06:28:36 +00:00
Argyrios Kyrtzidis
9638623493 [AST] Make dump functions const, NFC.
Swift SVN r16917
2014-04-27 05:33:38 +00:00
Doug Gregor
9ccaf63998 Implement sane redeclaration checking.
Perform redeclaration checking of global and type-member declarations
at the time of declaration, using a notion of the signature of a
declaration to determine when one declaration is a redeclaration of
another. See ValueDecl::getOverloadSignature() and 
conflicting(OverloadSignature, OverloadSignature) for the specific
rules we implement. In a nutshell:

  - For functions, the signature includes:
    + The full name (which includes argument names)
    + The interface type
    + Whether the function is a class/static or instance method
    + For an operator, whether it is prefix or postfix
  - For a subscript, the signature is the interface type
  - For everything else, the signature is just the name

This tightens the rules in a number of ways, which is reflected in the
test case churn:

  - We now properly perform redeclaration checking for generics
  - We now propertly handle API argument names for functions
  - We now ban overloading between two variables of the same name but
    different type 
  - We now ban overloading between a variable/property and a function
  - We now ban overloading for initializers

The two test cases of actual interest are:

  test/decl/overload.swift: A bunch of new test cases for our checking

  test/Constraints/members.swift: I commented out a useful test for
  now, because it relies on overloading between a property and a
  function. We can reconsistute this test with a couple of modules.

This commit fixes at least a half dozen radars under the umbrella
<rdar://problem/11212777>. I still need to check them individually to
close them out.



Swift SVN r16691
2014-04-23 07:03:38 +00:00
Doug Gregor
86ecc725c9 Start building compound names for functions parsed with the new signature style.
Swift SVN r16394
2014-04-16 03:55:05 +00:00
Doug Gregor
cd4ca76b6a Introduce the ObjCSelector class to store an Objective-C selector.
We have to work with selectors quite often, so provide an efficient
representation for them. Switch ObjCAttr over to this representation,
which has the nice property that it efficiently represents implicit
@objc attributes with names and allows us to overwrite the Objective-C
name without losing all source information. Addresses
<rdar://problem/16478678>, and sets us up for dealing with selectors
better.

Swift SVN r16327
2014-04-14 20:05:35 +00:00
Doug Gregor
18bf604360 Distinguish betweeen simple names ("foo") and zero-argument compound names ("foo()").
This isn't actually used yet, but it's an important distinction.

Swift SVN r16326
2014-04-14 20:05:34 +00:00
Doug Gregor
9189145cc5 Change DeclName over to basename(arg1:arg2:...argN:).
Swift will use the basename + argument names formulation for
names. Update the DeclName interfaces, printing, and __FUNCTION__ to
use the method syntax.

We'll still need to rework the "x.foo:bar:wibble:" syntax; that will
come (significantly) later.

Swift SVN r15763
2014-04-02 00:00:03 +00:00
Joe Groff
1585b625f9 Sema: Wire up compound name lookup to UnresolvedSelectorExpr.
Resolve selector references using compound name lookup, pushing DeclNames a bit deeper through the type-checker and diagnostics as necessary.

Swift SVN r14791
2014-03-07 20:52:30 +00:00
Joe Groff
96c09d7179 Renovate name lookup to prepare for compound name lookup.
Make the name lookup interfaces all take DeclNames instead of identifiers, and update the lookup caches of the various file units to index their members by both compound name and simple name. Serialized modules are keyed by identifiers, so as a transitional hack, do simple name lookup then filter the results by compound name.

Swift SVN r14768
2014-03-07 03:21:29 +00:00
Joe Groff
c2339cd091 AST: Unique compound names in the ASTContext.
Add a folding set for CompoundDeclNames so that identical names can be compared by pointer equality.

Swift SVN r14753
2014-03-06 21:10:28 +00:00
Chris Lattner
96947b2606 Change silgen to lower string literal lengths to an explicit value, instead of using
the result of the string_literal instruction.

This fixes:
<rdar://problem/15883849> Diagnostic CCP should be able to fold operations on string_literal lengths

I will follow up with cleanups this enables.




Swift SVN r13361
2014-02-03 18:26:46 +00:00
Dmitri Hrybenko
fcb3dbe0e6 Lookup visible decls / code completion for DynamicLookup: don't report
declarations with the same signature multiple times


Swift SVN r8864
2013-10-03 00:17:13 +00:00
Doug Gregor
e6933443d4 Zap unintentional commit
Swift SVN r6196
2013-07-12 00:47:00 +00:00
Doug Gregor
9ba865e852 Diagnose ambiguity type-checks by pointing to candidates.
Introduces very basic support for diagnosing ambiguous expressions,
where the source of the ambiguity is a reference to an overloaded
name. Simple example:

t.swift:4:1: error: ambiguous use of 'f0'
f0(1, 2)
^
t.swift:1:6: note: found this candidate
func f0(i : Int, d : Double) {}
     ^
t.swift:2:6: note: found this candidate
func f0(d : Double, i : Int) {}
     ^

There's a lot of work needed to make this cleaner, but perhaps it will
ease the pain of developing the library <rdar://problem/14277889>.


Swift SVN r6195
2013-07-12 00:45:17 +00:00
Joe Groff
bec638856d Sema: Resolve tuple patterns.
Preprocess case label patterns with a ResolvePattern pass that pushes pattern-ness down the AST through tuples of patterns.

Swift SVN r5900
2013-06-30 03:56:25 +00:00
Chris Lattner
cc3f22839a rework how autoimport happens. Instead of being driven by what the
source file imports in the first few lines, drive it based on the TU
mode.


Swift SVN r5751
2013-06-21 18:45:58 +00:00
Joe Groff
0249a6d0b8 Identifiers only need two tag bits available.
When allocated with malloc, Identifiers occasionally end up four-byte-aligned.

Swift SVN r5471
2013-06-04 20:34:58 +00:00
Doug Gregor
b8bf08f0cf Suppress warning in release mode
Swift SVN r5435
2013-06-03 18:37:45 +00:00
Joe Groff
a2341a4cde Add Unicode symbol characters to operator charset.
Remove '@' from the operator character set, but add the math, symbol, punctuation, arrow, and line- and box-drawing characters. Also allow operators to contain (but not start with) combining characters--this should be safe, because identifiers can't start with combining characters either, and we don't allow them anywhere else.

Swift SVN r5019
2013-05-01 23:13:48 +00:00
Joe Groff
0566088bf2 Move name mangling into SIL.
Sever the last load-bearing link between SILFunction and SILConstant by naming SILFunctions with their mangled symbol names. Move the core of the mangler up to SIL, and teach SILGen how to use it to mangle a SILConstant.

Swift SVN r4964
2013-04-28 03:32:41 +00:00
Ted Kremenek
219b7bd430 Move LLVM.h to libBasic.
Swift SVN r2550
2012-08-03 23:54:29 +00:00
John McCall
30f5e36dbc Semantic analysis and AST support for postfix operators.
Also prevent us from including unary operators in the
lookup results for operators written binary-style and
vice-versa.

Swift SVN r2162
2012-06-07 01:00:08 +00:00
Eli Friedman
3dbb44e8e8 '\0' is not an operator character. Make sure Identifier::isOperatorChar knows that.
Swift SVN r1723
2012-05-03 20:33:17 +00:00
Doug Gregor
cd7be4edf1 Add an AST for subscript expressions; no real type checking yet.
Swift SVN r1512
2012-04-19 22:07:42 +00:00
Eli Friedman
6a001efbbb Make "..", "*^.^*", etc. into overloadable operators. Make 1..10 construct a Range.
This has the side-effect that you can't explicitly refer to an operator* with "swift.*", etc., but per discussion with Doug, that's probably okay.



Swift SVN r1443
2012-04-17 00:21:38 +00:00
Chris Lattner
2599a55231 add ~ as an operator.
Swift SVN r1407
2012-04-12 23:24:11 +00:00
Doug Gregor
63ca527a95 Introduce accessors into DeclVarName and eliminate direct mutation by
setting all fields on construction. Use this opportunity to save a
pointer of storage for every DeclVarName.
squeeze out a pointer's worth of storage


Swift SVN r639
2011-08-29 19:59:33 +00:00
Chris Lattner
f03486e991 diagnose a bunch of problem cases with operators.
Swift SVN r575
2011-08-20 01:29:00 +00:00
Chris Lattner
7275ca527a pull in StringRef and Twine.
Swift SVN r422
2011-07-19 06:00:20 +00:00
Chris Lattner
c5506dc66e Capture the structure of a declared VarName in the ast as DeclVarName.
Swift SVN r266
2011-03-14 21:54:21 +00:00
Chris Lattner
a37e52624e Improve error message to list the type name.
Swift SVN r246
2011-03-01 08:48:11 +00:00
Chris Lattner
04f7a08621 add support for tuple field access with ".", e.g.:
var a : (int, var f : int, int);
  var b = a.field0+a.field1+a.f;

This also eliminates TupleConvertExpr.

Swift SVN r137
2010-08-03 06:55:08 +00:00
Chris Lattner
f248ffb53a Introduce a scope abstraction, the next step to implementing
name lookup.


Swift SVN r65
2010-07-23 04:37:16 +00:00
Chris Lattner
ed1be4f17a add printing support for Identifier, switch VarDecl to have an
identifier instead of a stringref.


Swift SVN r63
2010-07-23 03:50:09 +00:00
Chris Lattner
8bf327b648 add a new AST/Identifier class which represents a uniqued string.
Add support to ASTContext to unique strings into identifiers.


Swift SVN r62
2010-07-23 03:40:02 +00:00