Commit Graph

128 Commits

Author SHA1 Message Date
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
Dmitri Hrybenko
70f2b64ad9 Add CharSourceRange -- a half-open character range, which will be used in IDE
integration

Motivation: libIDE clients should be simple, and they should not have to
translate token-based SourceRanges to character locations.

This also allows us to remove the dependency of DiagnosticConsumer on the
Lexer.  Now the DiagnosticEngine translates the diagnostics to CharSourceRanges
and passes character-based ranges to the DiagnosticConsumer.


Swift SVN r7173
2013-08-12 20:15:51 +00:00
Chris Lattner
121e70f4fa Refactor diagnostic verification (-verify mode) out to its own file
in libFrontend.


Swift SVN r6985
2013-08-07 17:53:09 +00:00