Commit Graph

52 Commits

Author SHA1 Message Date
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
db13bcb22e Fix typos. 2015-12-26 14:11:42 +01:00
gregomni
db44bf7d69 Add support in the diagnostic verifier for verifying no fix-its
Checked what it would look like to verify fix-its in every case, and
currently the tests are missing expected fix-its in 435 diagnoses in 60
test files.

So as an alternative, added support for a no fix-its marker “{{none}}”, and
added that marker to the c-style for deprecation tests where it applies.
2015-12-22 13:33:39 -08:00
Chris Lattner
f0aa5aa704 revert unintended change.
Swift SVN r32005
2015-09-16 20:17:55 +00:00
Chris Lattner
92fc60f619 fix rdar://22387625 QoI: Common errors: 'let x= 5' and 'let x =5' could use Fix-its
Swift SVN r32004
2015-09-16 20:12:14 +00:00
Chris Lattner
1439bba142 move the special case closure diagnostics to CSDiag out of TypeCheckPattern,
since the logic is specific to it and about to get more-so. NFC.


Swift SVN r31719
2015-09-05 22:13:49 +00:00
Chris Lattner
44b35a85f8 remove a bunch more Failure conditions that CSDiags ignores.
Swift SVN r31718
2015-09-05 21:53:08 +00:00
Chris Lattner
7ad6eaad07 the previous patch improved 22308291 enough to consider it done.
Swift SVN r31697
2015-09-04 22:35:42 +00:00
Chris Lattner
34ae9bb9b6 Fix <rdar://problem/22584076> QoI: Using array literal init with dictionary produces bogus error
This includes a few changes:
 - Enhance diagnoseGeneralConversionFailure to not ignore constraints that are fully solved by
   CSDiags' heuristics.
 - Enhance dictionary/array literals diagnostics to handle non-compliance to their literal 
   protocols with a specific and custom error message.
 - Add specific QoI for turning accidental use of array literals in dictionary context into
   the right dictionary syntax (with a fixit).


Swift SVN r31696
2015-09-04 22:31:21 +00:00
Chris Lattner
eb0131f927 refactor all of the constraint system "Fix" processing logic out of
ConstraintSystem::applySolution into its own helper function to reduce
indentation and make ConstraintSystem::applySolution much more simple
and obvious.  NFC.


Swift SVN r31290
2015-08-18 04:47:34 +00:00
Chris Lattner
1ad24fdfc2 rework how 'as' casts are diagnosed, removing a special case from CSApply and
allowing these failures to hook into other diagnostic goodies (e.g. the
"did you mean to use '!' or '?'?" cases showing in the testsuite).  That said,
by itself this doesn't have a huge impact, but avoids regressions with other
pending changes.


Swift SVN r31289
2015-08-18 04:35:41 +00:00
Chris Lattner
b889fb400d every time I commit this I get closer to doing something about it...
Swift SVN r31265
2015-08-17 16:46:04 +00:00
Chris Lattner
6c3976061c If a contextual type is available when type checking collection literals, use it to
produce specific diagnostics about individual elements being incorrect instead of
complaining about the whole thing in aggregate.

This improves diagnostics immediately, but is also important to unblock future progress.



Swift SVN r31264
2015-08-17 16:41:55 +00:00
Chris Lattner
7f7b78e051 Fix <rdar://problem/22263468> QoI: Not producing specific argument conversion diagnostic for tuple init
Swift SVN r31211
2015-08-13 06:05:03 +00:00
Chris Lattner
616dbb2a5e fix <rdar://problem/22255907> QoI: bad diagnostic if spurious & in argument list
Swift SVN r31206
2015-08-13 05:22:20 +00:00
Chris Lattner
83d6cfcb30 Yet again, didn't mean to check this in...
Swift SVN r31131
2015-08-11 06:06:26 +00:00
Chris Lattner
4b96cba12b Fix <rdar://problem/22143680> QoI: terrible diagnostic when trying to form a generic protocol
Swift SVN r31108
2015-08-10 16:50:45 +00:00
Chris Lattner
92feced290 add some code that causes -verify to error when a fixit was generated, but
not specified in a testcase.  Currently disabled, pending discussion.


Swift SVN r30990
2015-08-04 17:32:55 +00:00
Chris Lattner
7e3146025d fix an off-by-two in the previous patch.
Swift SVN r30983
2015-08-04 05:28:09 +00:00
Chris Lattner
738ccaf054 teach -verify mode to automatically update incorrect fixit requirements when
autoApplyFixes is enabled, because, well, we can.  NFC since noone uses this.



Swift SVN r30982
2015-08-04 05:25:23 +00:00
Chris Lattner
799c366451 Fix some issues where replacing multiple sequential diagnostics
could lead to an "overlapping diagnostics" assertion because
two fixits were zapping whitespace.  NFC, since noone except me
uses this.


Swift SVN r30929
2015-08-02 05:42:17 +00:00
Chris Lattner
5deadfb6e4 didn't mean to comit this...
Swift SVN r30918
2015-08-01 17:37:09 +00:00
Chris Lattner
bdaf954982 when recursively type checking an expression with its contextual type and
other constraints intentionally ripped off, tell the recursive solution that
we can tolerate an ambiguous result.  The point of this walk is not to
produce a concrete type for the subexpression, it is to expose any structural
errors within that subsystem that don't depend on the contextual constraints.


Swift SVN r30917
2015-08-01 17:31:49 +00:00
Chris Lattner
fecf0c06ad teach autoApplyFixes how to remove diagnostics that are no longer produced. NFC since noone uses this.
Swift SVN r30886
2015-07-31 22:33:47 +00:00
Chris Lattner
7851d348a8 merge the ErrorDoesNotHaveInitOnInstance complexity into the normal
"member not found" diagnostic machinery.


Swift SVN r30842
2015-07-31 04:23:07 +00:00
Chris Lattner
50be7e4ecf reapply r30789, r30795, r30796, r30797, without r30787 which causes a compile time hit:
- Produce more specific diagnostics relating to different kinds of invalid
 - add a testcase, nfc
 - Reimplement FailureDiagnosis::diagnoseGeneralMemberFailure in terms of

Not including r30787 means that we still generate bogus diagnostics like:
[1, 2, 3].doesntExist(0)  // expected-error {{type 'Int2048' does not conform to protocol 'IntegerLiteralConvertible'}}

But it is an existing and separable problem from the issues addressed here.



Swift SVN r30819
2015-07-30 23:31:56 +00:00
Chris Lattner
f293e84e04 revert part of my previous patch.
Swift SVN r30797
2015-07-30 06:35:54 +00:00
Chris Lattner
98a445384a Produce more specific diagnostics relating to different kinds of invalid
member references:

- Use of instance members from types
- Use of type members from instances
- Use of mutating getters.

This surely resolves some radars, but I'll have to dig them out later.


Swift SVN r30796
2015-07-30 06:26:43 +00:00
Chris Lattner
d24cb2dfe9 didn't mean to commit this...
Swift SVN r30666
2015-07-26 22:23:25 +00:00
Chris Lattner
66683f94f9 Eliminate the "IsReturnExpr" bit from the AST - it was a poorly maintained
version of the new CTP_ReturnStmt conversion, used to generate return-specific 
diagnostics.  Now that we have a general solution, we can just use that.

This improves diagnostics in returns for accessors, since they were apparently
not getting the bit set.


Swift SVN r30665
2015-07-26 22:05:40 +00:00
Chris Lattner
dc7b13735e didn't mean to commit this
Swift SVN r30652
2015-07-26 05:34:19 +00:00
Chris Lattner
a8d9aec957 revert r30641, it wasn't correct. We produce better diagnostics for the
cases I was worried about anyway now.


Swift SVN r30651
2015-07-26 05:33:33 +00:00
Chris Lattner
3181ea35bd implement the mechanics for -verify mode to auto-apply the fixits it generates,
this isn't wired up to anything yet though.


Swift SVN r30628
2015-07-25 15:52:36 +00:00
Chris Lattner
5e4cd16887 Have -verify mode emit the expected diagnostic text as a fixit to avoid confusing and redundant output,
e.g.:

/Users/sabre/Projects/swiftsource/swift/test/Constraints/existential_metatypes.swift:17:28: error: incorrect message found
pp = pt // expected-error{{cannot assign a value of type 'P.Type' to a value of type 'P.Protocol'}}
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                           'P.Type' is not convertible to 'P.Protocol'



Swift SVN r30626
2015-07-25 15:18:22 +00:00
Chris Lattner
9f0eb24775 reimplement the Errors array in terms of the more general llvm::SMDiagnostic
type, and use a lambda to simplify the code manipulating errors to emit. NFC.


Swift SVN r30624
2015-07-25 05:48:02 +00:00
Chris Lattner
be933f8c34 For diagnostics where the message changed, instead of producing something like:
/Users/sabre/Projects/swiftsource/swift/test/Constraints/errortype_bridging.swift:37:7: error: unexpected error produced: 'protocol<HairyErrorType, Runcible>' is not convertible to 'NSError'
ns4 = compo // expected-error{{cannot assign a value of type 'protocol<HairyErrorType, Runcible>' to a value of type 'NSError'}}
      ^
/Users/sabre/Projects/swiftsource/swift/test/Constraints/errortype_bridging.swift:37:16: error: expected error not produced
ns4 = compo // expected-error{{cannot assign a value of type 'protocol<HairyErrorType, Runcible>' to a value of type 'NSError'}}
               ^

produce a single message like:

/Users/sabre/Projects/swiftsource/swift/test/Constraints/errortype_bridging.swift:37:16: error: error had incorrect message: 'protocol<HairyErrorType, Runcible>' is not convertible to 'NSError'
ns4 = compo // expected-error{{cannot assign a value of type 'protocol<HairyErrorType, Runcible>' to a value of type 'NSError'}}
               ^



Swift SVN r30623
2015-07-25 05:34:33 +00:00
Chris Lattner
649e5f937d generalize the existing ? and + constraints on expected diagnostics to
a simpler and more general * constraint.  This paves the way for other improvements.



Swift SVN r30622
2015-07-25 05:23:30 +00:00
Chris Lattner
c469bd38d8 fix a buildbot breakage due to a dangling pointer.
Swift SVN r30621
2015-07-25 05:15:06 +00:00
Chris Lattner
fc445984ee rework -verify mode to parse the list of expected diagnostics into a temporary data structure, before verifying matches. NFC.
Swift SVN r30620
2015-07-25 04:30:50 +00:00
Chris Willmore
563d105319 Verify mode: Add support for 'expected-error?{{..}}' annotation that
matches zero or one instances of the diagnostic.

Swift SVN r29492
2015-06-18 18:58:47 +00:00
Devin Coughlin
1867b1418b Support escape sequences in @available() messages.
Allow API providers to use escaped characters in the messages of @available()
attributes. For example, for a reference to a declaration annotated with:

@available(*, unavailable, message="use print(\"\")")
public func println() {
...
}

the message displayed to the user will be:

'println() is unavailable: use print("")'.

This also supports unicode escapes (e.g. \u{1F43C}).

A complication is that AvailableAttrs imported from clang already have their
messages unescaped, so this patch keeps track of whether an availability
attribute came from clang and, if so, does not unescape the message again when
emitting the diagnostic. We could avoid this extra book-keeping by immediately
unescaping Swift messages during parsing, keeping them in an unescaped
canonical form, and then escaping them in ASTPrinter when we print the
attributes. rdar://problem/20985357 tracks keeping AvailableAttrs messages in
a canonical form.

rdar://problem/20789407

Swift SVN r28658
2015-05-16 01:51:51 +00:00
Chris Lattner
a8fe87968e enhance -verify mode wording to be more precise about diagnostics that mismatch
expectations.  Instead of saying "unexpected diagnostic not produced" and
"expected diagnostic not produced", instead say "unexpected *warning* not produced".

This helps in particular when you have an expectation for a warning but got an
error with the same wording (for example).



Swift SVN r26149
2015-03-15 06:29:07 +00:00
Chris Willmore
2ffab5f832 Fix parsing of "// expected-error@+1 2{{message}}" by the verifier.
This change allows an expected-error comment to have both a line offset
and a repeat count.

Swift SVN r23403
2014-11-18 05:37:54 +00:00
Doug Gregor
26816e2b8c QoI: Improve diagnostic for a missing required initializer with a Fix-It.
When a subclass is missing a required initializer, produce an error
within the subclass that mentions the required initializer along with
a Fix-It that provides an initializer stub, e.g.,

  required init(coder aDecoder: NSCoder!) {
      fatalError("init(coder:) has not been implemented")
  }

We take care to insert this stub in the main class, after all of the
initializers (if there are any) or near the beginning of the class (if
there aren't any initializers), and try to match the existing
indentation. If this works out, we should handle unsatisfied protocol
requirements the same way. <rdar://problem/17923210>

Swift SVN r21055
2014-08-06 00:33:54 +00:00
Jordan Rose
5a861b3515 [ClangImporter] Define header guards for <iso646.h> so it's never present.
This is a hack to work around two issues:
- <iso646.h>, which defines macros for "and", "or", and "not" (among other
  things) is an implicit submodule of Darwin.
- Macros even in explicit submodules are leaking out when the parent module
  is imported <rdar://problem/14870036>.

There's no actual reason to require <iso646.h> in SDK header files -- it
should be a user-level choice whether or not to use those names. And
selectors with "and", "or", and "not" in them should not be mangled by this.

So, as a hack, we define the header guards that <iso646.h> uses ahead of
time, so that the file will be ignored. We do this for /both/ variants of
<iso646.h> on our system (Clang's and /usr/include's) just to be safe.

<rdar://problem/17110619>

Swift SVN r19822
2014-07-10 20:19:33 +00:00
Jordan Rose
7d1371c6e5 -verify: Bring over Clang's "+" to signify "at least one" diagnostic to match.
This is useful for expected-note in particular (e.g. "declared here" notes).

Swift SVN r19521
2014-07-03 17:45:38 +00:00
Jordan Rose
cfd7851a67 [Accessibility] When a private type is used in a public way, show its decl.
At the very least, this makes it easier to mark the private type as public
if that's the correct answer.

Swift SVN r19436
2014-07-01 23:42:01 +00:00
Jordan Rose
574054b8fd Distance SourceManager from llvm::SourceMgr.
...in preparation for non-source locations, i.e. locations that don't come
frome source buffers.

No functionality change, but a fair bit of SourceManager API and idioms have
changed.

Swift SVN r18942
2014-06-17 01:15:47 +00:00
Argyrios Kyrtzidis
84b0664dab [Frontend] For verifying diagnostics, allow this format: "expected-error@<Relative line offset>{{text}}".
This is similar to clang's diagnostic verifier.

Swift SVN r9292
2013-10-13 18:50:52 +00:00