Commit Graph

117 Commits

Author SHA1 Message Date
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