Commit Graph

216 Commits

Author SHA1 Message Date
Jordan Rose
49c43d84e6 Allow diagnostics to take either a char range or a token range (SourceRange).
This will be necessary for things like typo-correction, but currently
serves no purpose because all of our diagnostics are token-based. It's
going to be the base range type for Swift fix-its, though, so I thought I'd
get it in place now.

Swift SVN r4750
2013-04-16 01:46:31 +00:00
Doug Gregor
263cf27548 Use the pretty-printer to render imported declarations for diagnostics.
Note: this is an experiment.

When we're asked to render a diagnostic for a declaration that does
not have source information, pretty-print the declaration into a
buffer and synthesize a location pointing into that buffer. This gives
the illusion of Clang-style diagnostics where we have all of the
source headers, but without actually requiring that source location
information. It may prove useful or infuriating, but at the very least
it might help us understand how the importer works. Example:

cfuncs_diags.swift:14:7: error: no candidates found for call
  exit(5)
  ~~~~^~~
cfuncs_diags.swift:6:6: note: found this candidate
func exit(_ : Float) {}
     ^
cfuncs.exit:1:6: note: found this candidate
func exit(_ : CInt)
     ^



Swift SVN r3434
2012-12-11 00:21:20 +00:00
Doug Gregor
319a100189 Allow diagnostics to accept declarations in lieu of source locations.
Swift's diagnostic system is built on the quaint notion that every
declaration known to the front end has a valid source location to
which diagnostics mentioning that declaration (say, in a "here is a
candidate" note) can point. However, with a real module system, the
source corresponding to a declaration in a module does not need to be
present, so we can't rely on source locations.

Instead of source locations, allow diagnostics to be anchored at a
declaration. If that declaration has source-location information, it
is used. Otherwise, we just drop source-location information for
now. In the future, we'll find a better way to render this information
so it feels natural for the programmer.


Swift SVN r3413
2012-12-07 22:51:11 +00:00
Ted Kremenek
219b7bd430 Move LLVM.h to libBasic.
Swift SVN r2550
2012-08-03 23:54:29 +00:00
Eli Friedman
a2c6150c13 Error recovery for the REPL. Seems to be working reasonably well. <rdar://problem/11269380>.
Swift SVN r1523
2012-04-20 01:14:39 +00:00
Doug Gregor
7e9b7da0ca Remove the general diagnostic-suppression mechanism. Instead,
introduce a simple suppression mechanism into the type-coercion code,
which is the only place we should need it.


Swift SVN r1388
2012-04-11 14:31:40 +00:00
Doug Gregor
79ed496d87 Implement filtering of overload sets based on argument and destination
types. Use this simple overload resolution scheme in both type
checking and type coercion, simplifying both code paths a bit.

There is one significant semantic change here: we allow overload
resolution to operate on (structured) dependent arguments, which
allows for more overload filtering before we come in with the type
coercion hammer. For example, we can now properly type-check

  var x : int32;
  x + 0;



Swift SVN r1310
2012-04-02 23:22:01 +00:00
Doug Gregor
bfe7ff2168 Extend the AST walker that performs type coercion to have two modes:
one that performs the coercion on the AST and produces diagnostics for
any problems, and one that simply determines whether the coercion
would succeed. The former already existed (as
TypeChecker::convertToType), while an approximation of the latter was
already implemented as Expr::getRankOfConversionTo(). Unifying these
code paths addresses several issues:

  - Lots of redundancy in the code for computing these two properties,
    which causes bugs. For example, Expr::getRankOfConversionTo()
    wasn't able to handle literals (!).
  - Determining whether a conversion is possible will need the full
    power of the type checker, e.g., to deal with closures in cases
    like:

      func f(g : (int, int) -> int);
      func h() { f({$1 + 0}); }

    Although this is not handled correctly now.

I have opted not to adopt Clang's ImplicitConversionSequence (or
InitializationSequence) design, which computes a record of the steps
needed to perform the conversion/coercion and later applies those
steps, because we don't need that complexity yet. If we start
introducing more implicit conversions into the language, we'll revisit
this decision.



Swift SVN r1308
2012-04-02 21:43:15 +00:00
Doug Gregor
fc183b9cc3 Decouple the lexer from the ASTContext and specific BufferID. They
aren't needed for the lexer proper (which just needs a buffer to dig
through). Also, make it possible to suppress lexer diagnostics merely
by not giving it a diagnostic engine to work with.


Swift SVN r852
2011-11-09 21:49:40 +00:00
Doug Gregor
725298a2da Introduce a DiagnosticConsumer abstract interface that is used to
actually render emitted diagnostics. This is both a useful
generalization (we expect to have a number of other
DiagnosticConsumers down the road, as Clang does) and is also
important now to avoid a layering violation when adjusting the source
location at the end of a SourceRange to the end of the token.

 


Swift SVN r850
2011-11-09 18:59:39 +00:00
Doug Gregor
cd7a21de83 Introduce support for adding source ranges to diagnostics.
We don't yet properly perform the SourceRange -> llvm::SMRange mapping. 

Swift SVN r847
2011-11-09 17:53:30 +00:00
Doug Gregor
e12215b1be Introduce InFlightDiagnostic, a move-only class that will be used to emit "extra" information (ranges, Fix-Its, etc.) for a diagnostic. It's quite similar in design to Clang's DiagnosticBuilder, but slightly cleaner/more restrictive.
Note that I had to re-implement llvm::Optional, since it lamely requires a default constructor. At some point, I'll push a proper implementation back to LLVM.

Swift SVN r845
2011-11-09 17:19:30 +00:00
Doug Gregor
7106232181 Generalize the Diag<...> specializations within Diagnostic and
DiagnosticEngine so that they work properly (without extensions) for
zero arguments. Then, eliminate the zero-argument specializations.


Swift SVN r844
2011-11-09 16:00:36 +00:00
Chris Lattner
22808d5970 introduce a new Diagnostic class to represent a diagID + arguments.
Swift SVN r784
2011-10-22 06:03:30 +00:00
Chris Lattner
2cee9d300b simplify code a bit, I hear that classes with ctors can be in unions these days.
Swift SVN r783
2011-10-22 05:47:46 +00:00
Chris Lattner
9298082ebb move Diagnostics header to include/swift/AST to match .cpp files.
Swift SVN r782
2011-10-22 00:47:35 +00:00