Commit Graph

4149 Commits

Author SHA1 Message Date
John McCall
2bf56a3a2e Add a Range type which just bundles two iterators together and
lets you iterate that.

Swift SVN r4463
2013-03-21 05:29:16 +00:00
John McCall
05c91bd292 Use the header-guard idiom properly.
Swift SVN r4462
2013-03-21 05:29:13 +00:00
Joe Groff
062ad267c4 Value-only switch statements.
Implement switch statements with simple value comparison to get the drudge work of parsing and generating switches in place. Cases are checked using a '=~' operator to compare the subject of the switch to the value in the case. Unlike a C switch, cases each have their own scope and don't fall through. 'break' and 'continue' apply to an outer loop rather to the switch itself. Multiple case values can be specified in a comma-separated list, as in 'case 1, 2, 3, 4:'. Currently no effort is made to check for duplicate cases or to rank cases by match strength; cases are just checked in source order, and the first one wins (aside from 'default', which is branched to if all cases fail).

Swift SVN r4359
2013-03-12 04:43:01 +00:00
Joe Groff
00f1c0f687 Simplify Optional.h.
Putting T inside an anonymous union is enough to suppress its implicit value semantics--no need for aligned_storage shenanigans.

Swift SVN r4358
2013-03-12 04:42:57 +00:00
Doug Gregor
e27279c0ff Turn on the constraint-based type checker by default <rdar://problem/13324871>.
Lots of tests (46 of them) fail with the constraint-based type
checker, either due to changes in diagnostics or due to outright
bugs in the constraint-based type checker. Use -no-constraint-checker
for these tests.

Note that the hack to parse imported swift.swift with
-no-constraint-checker remains in place, for build-performance
reasons.



Swift SVN r4300
2013-03-06 06:32:40 +00:00
Joe Groff
ddb7ead55c REPL: Contextual completions.
If the completion prefix has a '.' behind it, guesstimate a context expression by lexing backward through an identifier(.identifier)* dotted path, then attempt to parse and typecheck that expression to decide on a base type in which to find completions.

Swift SVN r4063
2013-02-16 20:07:50 +00:00
Doug Gregor
42b1ab6fbd Introduce a LangOptions class to capture various type-checker-tweaking flags. For now, introduce bits to enable the constraint solver and to enable debugging of the constraint solver, and use those to eliminate the "useConstraintSolver" bit that was threaded through too much of the type checker.
Swift SVN r2836
2012-09-12 20:19:33 +00:00
Chris Lattner
7055cfe43a move DiverseList and DiverseStack to swift/Basic, out of IRGen.
Swift SVN r2784
2012-08-26 20:10:10 +00:00
Ted Kremenek
219b7bd430 Move LLVM.h to libBasic.
Swift SVN r2550
2012-08-03 23:54:29 +00:00
Doug Gregor
cf5eb59956 Extend SpecializeExpr with information about the types used to replace
each primary archetype along with the protocol conformance records for
each of the requirements placed on that archetype.


Swift SVN r2250
2012-06-26 00:10:23 +00:00
Doug Gregor
ec31aaf04b Parse a generic parameter list within a function declaration, and
introduce the generic type parameters (which are simply type aliases
for a to-be-determined archetype type) into scope for name
lookup. We can now parse something like

  func f<T, U : Range>(x : T, y : U) { }

but there is no semantic analysis or even basic safety checking (yet).




Swift SVN r2197
2012-06-18 22:49:54 +00:00
Chris Lattner
3ae29d8c82 provide facilities to elide the filename for a sourceloc if it matches the previous sourceloc. We now
print ranges as: [t.swift:22 - :23] instead of [t.swift:22 - t.swift:23].


Swift SVN r1753
2012-05-05 21:14:36 +00:00
Chris Lattner
d77d0d3fe3 refactor SourceRange printing out of Verifier.cpp into methods on SourceRange and SourceLoc.
Swift SVN r1752
2012-05-05 21:08:44 +00:00
John McCall
c36c7e2c86 Include what you use.
Swift SVN r1382
2012-04-11 02:59:58 +00:00
John McCall
8aefa67399 Add a convenient way to construct an empty Optional without naming
a potentially long template-id.



Swift SVN r872
2011-11-17 09:27:56 +00:00
Doug Gregor
0223f3edf1 Implement Expr::getSourceRange() and introduce proper support for this
function into all of the expression nodes. Re-implement
Expr::getStartLoc() in terms of this function, and add it's brother
Expr::getEndLoc(), removing the specialized implementations.

Clean up the source ranges of implicitly-created tuple expressions in
the process.


Swift SVN r855
2011-11-10 00:25:48 +00:00
Doug Gregor
d4d7ac1e6b SMRange is inclusive of the end location, so adjust our end location
accordingly when printing diagnostics.


Swift SVN r854
2011-11-09 22:07:29 +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
1334180b3b Add non-const operator-> and operator* overloads to Optional.
Swift SVN r846
2011-11-09 17:51:18 +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
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
Chris Lattner
2f434d98fb straighten out identifiers in diagnostics a bit.
Swift SVN r780
2011-10-22 00:39:28 +00:00
Chris Lattner
dfd529ce3a rename diags::foo to diag::foo
Swift SVN r779
2011-10-22 00:36:19 +00:00
Chris Lattner
5e8370dea0 eliminate some printouts from IRGen in favor of real diagnostics.
Swift SVN r777
2011-10-22 00:32:14 +00:00
Chris Lattner
2ac742d7c6 convert the rest of sema to the new diagnostics stuff.
Swift SVN r775
2011-10-22 00:25:35 +00:00
Chris Lattner
0c3b3fe76b use Type and Identifier arguments to diagnostics more uniformly.
Swift SVN r774
2011-10-21 23:32:14 +00:00
Chris Lattner
0c0e65e553 violate diagnostic layering harder, making it fine to cram types into diagnostics.
Lets here it for non-pod's in unions.


Swift SVN r773
2011-10-21 23:25:29 +00:00
Chris Lattner
2f5964abd8 switch TC Coercion over.
Swift SVN r772
2011-10-21 23:19:39 +00:00
Chris Lattner
d36e080d5f switch name binding to the new diagnostics stuffola
Swift SVN r771
2011-10-21 23:00:34 +00:00
Chris Lattner
2092ddeb54 switch the lexer over to the new diagnostics subsystem. Drop the
"no newline at the end of // comment" warning, swift doesn't require
a \n at the end of file.


Swift SVN r770
2011-10-20 21:52:16 +00:00
Chris Lattner
60afdf4842 switch irgen to new diags
Swift SVN r769
2011-10-20 21:29:50 +00:00
Chris Lattner
9f906da738 sink (a copy of) HadError into DiagnosticEngine, so that errors produced by it trigger error returns from main().
Swift SVN r768
2011-10-20 20:55:22 +00:00
Chris Lattner
a1781fed38 switch expr parsing to the new diagnostics subsystem
Swift SVN r766
2011-10-20 20:41:48 +00:00
Chris Lattner
6fcd10e290 deconstify member to make Diag<>'s assignable and otherwise behave as
a proper value type.


Swift SVN r765
2011-10-20 20:27:03 +00:00
Chris Lattner
8c07ba4034 switch parseStmtBrace to the new diagnostics api
Swift SVN r764
2011-10-20 20:18:36 +00:00
Chris Lattner
d8343e9a42 convert parseToken to new diagnostic api
Swift SVN r763
2011-10-20 20:09:04 +00:00
Chris Lattner
96f732b6a2 convert parseType to take a DiagID.
Swift SVN r762
2011-10-20 19:53:00 +00:00
Chris Lattner
f149ab5527 make Identifiers default to be quoted in diagnostic output.
Swift SVN r761
2011-10-19 01:07:31 +00:00
Chris Lattner
ff9d19afbb switch another diagnostic off deprecated calls.
Swift SVN r760
2011-10-19 01:04:18 +00:00
Chris Lattner
fcc547d000 switch parseIdentifier and all its uses to the new diagnostics machinery.
Swift SVN r759
2011-10-19 00:57:50 +00:00
Chris Lattner
3bc1db5776 add convenience support in diagnostics for identifiers. This is a layering violation, to be resolved later.
Swift SVN r758
2011-10-19 00:46:48 +00:00
Chris Lattner
a7c7d64fa0 Switch swift to use SourceLoc instead of SMLoc.
Also use the new getAdvancedLoc() method instead of hacking
on SMLoc directly.

Also fix the warning/note/error methods to forward through ASTContext
instead of being replicated everywhere.



Swift SVN r750
2011-10-18 01:22:29 +00:00
Chris Lattner
3ec9a9720a Add datatypes for swift to represent source locations and ranges, which are
distinct from the SMXXX types.  This is important because SMRange and
SourceRange have subtly different semantics, and is also nice to isolate
SMLoc from swift.


Swift SVN r749
2011-10-18 01:21:29 +00:00
Chris Lattner
44cc26c814 switch to LLVM umbrella header to get stringref.
Swift SVN r746
2011-10-18 00:18:15 +00:00
Doug Gregor
f97641d84c Add support for %select{option1|option2}idx to the diagnostic formatter, and use it in the parser
Swift SVN r739
2011-09-27 00:56:09 +00:00
Doug Gregor
a60a77bb8e C99 variadic macros suck. Use template metaprogramming tricks so we
aren't forced to rely on extensions.


Swift SVN r738
2011-09-27 00:25:56 +00:00
Doug Gregor
c0d0149401 Don't rely on silly GNU extensions. __VA_ARGS__ works fine the way we're using it
Swift SVN r736
2011-09-27 00:02:22 +00:00
Doug Gregor
d7a47dd8bf Don't build zero-length arrays
Swift SVN r735
2011-09-26 23:59:08 +00:00
Doug Gregor
3d15bf3d55 Introduce a diagnostic-formatting engine and port most of the parser's
diagnostics over to it.

There are a few differences between this diagnostic engine and Clang's
engine:
  - Diagnostics are specified by a .def file (Diagnostics.def), rather
  than via tblgen, which drastically simplifies the build and makes
  code completion work when you add a new diagnostic.
  - Calls to the "diagnose()" method are safely typed based on the
  argument types specified in the .def file, so it's harder to write a
  diagnostic whose expected arguments (in the string) and whose actual
  arguments (in the code) don't match.
  - It uses variadic templates, so it hangs with the cool kids.



Swift SVN r734
2011-09-26 23:46:28 +00:00