Commit Graph

90 Commits

Author SHA1 Message Date
Chris Lattner
868a795566 Introduce a new class between TypeDecl and NominalTypeDecl named GenericTypeDecl.
This factors the DeclContext and generic signature behavior out of NTD, allowing
it to be reused in the future.  NFC.
2016-03-04 23:09:15 -08:00
practicalswift
8efa5f587e [gardening] Remove "-*- C++ -*-" tag from .cpp files
Emacs assumes .h files are C files by default which is why the
tag "-*- C++ -*-" is needed.

.cpp files do not have this problem.
2016-01-23 12:09:32 +01:00
Michael Ilseman
dc689e607c [Diagnostics] -suppress-warnings and -warnings-as-errors flags
Exposes the global warning suppression and treatment as errors
functionality to the Swift driver. Introduces the flags
"-suppress-warnings" and "-warnings-as-errors". Test case include.
2016-01-15 14:20:44 -08:00
Michael Ilseman
8b5fb7d200 [Diagnostics] Add in treating warnings as errors 2016-01-14 14:39:18 -08:00
Michael Ilseman
de0062e437 [Diagnostics] Remove all categories
Diagnostic categories are entirely unused and arguably useless as
implemented, as they merely denote the sub-component of the
compiler.

As far as categorizing warnings are concerned, I'm abandoning the
effort for now, as the utility is marginal and Swift and the Swift
compiler are probalby not ready for these to be nailed down. For the
sake of cleanliness, the CATEGORY field is also stripped from
WARNINGS.

If there's a need for automatic identifying of compiler sub-components
for diagnstics in the future, there are better ways to do this.

NFC
2016-01-14 14:39:18 -08:00
Michael Ilseman
ab805ea3a5 [Diagnostics] Refactor and clarify diagnostic behavior rules.
Restores StoredDiagnosticInfo, which is useful to help distinguish
when the user explicitly modifies the behavior of a diagnostic vs
we're just picking up the default kind.

Adds some clarifying comments, and lays out the suppression workflow,
whereby different types of suppression (per-diagnostic, per-category,
etc) have different precedence levels.
2016-01-14 14:32:59 -08:00
Michael Ilseman
80270a9f94 Incorporate Doug's review suggestions 2016-01-11 21:30:18 -08:00
Michael Ilseman
d282fd743d Allow suppressing individual diagnostics.
Extend DiagnosticState to track per-diagnostic desired behaviors,
allowing users of the APIs to individually suppress diagnostics.
2016-01-11 16:48:42 -08:00
Michael Ilseman
31314b19b0 Add ignoreAllWarnings API
New API on DiagnosticEngine to disable the reporting of warnings. No
tests currently, as this is not exposed upwards to any test-able
level, but tests will come when this is exposed e.g. through command
line arguments.
2016-01-10 21:42:51 -08:00
Michael Ilseman
767597d006 Track previous diagnostic behavior
Switch from a fatal-state machine to a previous-behavior-state
machine, which is more flexible in the presence of suppressible
warnings.
2016-01-10 20:35:52 -08:00
Michael Ilseman
dcb1924425 Introduce DiagnosticState to track how we should handle diagnostics
Refactor DiagnosticEngine to separate out diagnostic state
tracking. This allows gives us a base from which to add further
refinements, e.g. warning suppression.
2016-01-10 19:04:19 -08:00
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
Chris Lattner
feace85d5a Enhance SubscriptDecl to be a DeclContext, so it can hold its indices.
This is necessary for some other work I'm doing, which really wants
paramdecls to have reasonable declcontexts.  It is also a small step
towards generic subscripts.
2015-12-31 12:38:28 -08:00
Chris Lattner
49cd50da01 remove a fallback algorithm that is not necessary anymore. 2015-12-29 21:09:11 -08:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
Argyrios Kyrtzidis
034ec91f1a [AST/PrintOptions] Refactor PrintOptions::printInterface(bool) and introduce separate printForDiagnostics() function.
This makes the use case clear both for the caller and when adding new options on where they should be enabled or not.

Swift SVN r32152
2015-09-22 17:54:21 +00:00
Chris Lattner
dfc85cefad teach the Swift diagnostics engine about the "s" modifier that clang has,
used to pluralize integers in diagnostics.  NFC since it isn't used yet.


Swift SVN r31714
2015-09-05 20:47:09 +00:00
Chris Lattner
be818c6193 Adjust how diagnostics synthesize decls (e.g.) when printing overload sets,
to print them with their interface representation.  This squelches attributes
like @_inline and @semantics.


Swift SVN r31462
2015-08-25 23:52:53 +00:00
Jordan Rose
f5b1efb354 Move client-affecting configuration options into a generated Config.h.
This way they can be used from other projects, like LLDB. The downside
is we now have to make sure the header is included consistently in all
the places we care about, but I think in practice that won't be a problem,
especially not with tests.

rdar://problem/22240127

Swift SVN r31173
2015-08-12 17:50:13 +00:00
Chris Lattner
0a3197390f Various changes:
- Don't "aka" a Builtin.Int2123 type, it just makes a bad diagnostic worse.
 - Split out the predicate that CSDiag uses to determine what a conversion
   constraint is to a helper fn, and add subtype constraints to the mix.
 - Move eraseTypeData into CSDiag (its own client) as a static function.
 - Make eraseTypeData be a bit more careful about literals, in an attempt to
   improve diagnostics when literals get re-type-checked.  It turns out that
   this still isn't enough as shown by the regression on the 
   decl/func/default-values.swift testcase, and the 
   Constraints/dictionary_literal.swift testcase where one bad diagnostic turns
   into another different one, but I'll keep working on it.
 - Beef up diagnoseContextualConversionError and the caller to it to be more
   self contained and principled about the conversion constraints it digs out
   of the system.  This improves the diagnostics on a couple of cases.



Swift SVN r30642
2015-07-26 00:29:40 +00:00
Chris Lattner
622ea5e2f6 wind down most of CSDiag's uses of getUserFriendlyTypeName to pass the Type
directly into the diagnostics subsystem.  This ensures a more consistent 
treatment of type printing (e.g. catches a case where a diagnostic didn't 
single quote the type) and gives these diagnostics access to "aka".


Swift SVN r30609
2015-07-25 00:54:05 +00:00
Chris Lattner
6a27182712 two unrelated changes:
- Have DiagnosticEngine produce "aka" annotations for sugared types.
 - Fix the "optional type '@lvalue C?' cannot be used as a boolean; test for '!= nil' instead"
   diagnostic to stop printing @lvalue noise.

This addresses:
<rdar://problem/19036351> QoI: Print minimally-desugared 'aka' types like Clang does



Swift SVN r30587
2015-07-24 20:22:20 +00:00
Chris Lattner
3ad108b0be Reapply r29419:
Enhance fixItRemove() to be a bit more careful about what whitespace it leaves around: if the thing it is removing has leading and trailing whitespace already, this nukes an extra space to avoid leaving double spaces or incorrectly indented results.  

This includes an extra fix for looking off the start of a buffer, which extractText doesn't and can't handle.

This fixes <rdar://problem/21045509> Fixit deletes 'let' from non-binding 'if case let' statements, but leaves an extra space




Swift SVN r29449
2015-06-17 16:31:26 +00:00
Ted Kremenek
d13549e607 Revert "enhance fixItRemove() to be a bit more careful about what whitespace it leaves around:"
This was breaking the bots.

Swift SVN r29432
2015-06-17 02:20:52 +00:00
Chris Lattner
6b3167ab36 enhance fixItRemove() to be a bit more careful about what whitespace it leaves around:
if the thing it is removing has leading and trailing whitespace already, this nukes
an extra space to avoid leaving double spaces or incorrectly indented results.  This
fixes <rdar://problem/21045509> Fixit deletes 'let' from non-binding 'if case let' statements, but leaves an extra space



Swift SVN r29419
2015-06-17 00:55:59 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
Chris Lattner
3e3f568179 By far, the most common use of Lexer::getLocForEndOfToken is in
conjunction with .fixItInsert().  As such, introduce a helper named
.fixItInsertAfter() that does what we all want.  Adopt this in various
places around the compiler.  NFC.



Swift SVN r26147
2015-03-15 05:30:04 +00:00
Chris Lattner
a9e69c0c36 Take a bozooka out to fix <rdar://problem/19932544> refine error for using @autoclosure and @noescape on the same decl
We didn't have a consistent way to utter attributes in diagnostics, sometimes saying the

'foo' attribute is not allowed
@foo attribute is not allowed
'foo' is not allowed
@foo is not allowed

etc.  Standardize on the last one, since it is clear (with the @ sign, with no quotes, with no
'attribute' word in the diagnostic) that we're talking about an attribute.  Move a bunch of
diagnostics inline with this.



Swift SVN r25524
2015-02-25 01:19:04 +00:00
Chris Willmore
b31eff245c Add transactional diagnostic support to DiagnosticEngine
Transactions may be opened by calling open() on a DiagnosticTransaction
instance. Any diagnostics recorded during an open transaction will be
saved until the transaction is either committed, at which point they
will be emitted as usual; or aborted, at which point they will be
discarded.

Swift SVN r25437
2015-02-20 22:06:34 +00:00
David Farler
51f8070abe Serialize local types
Local type declarations are saved in the source file during parsing,
now serialized as decls. Some of these may be defined in DeclContexts
which aren't Decls and previously weren't serialized. Create four new
record kinds:

* PatternBindingInitializer
* DefaultArgumentInitializer
* AbstractClosureExpr
* TopLevelCodeDecl

These new records are used to only preserve enough information for
remangling in the debugger, and parental context relationships.

Finally, provide a lookup API in the module to search by mangled name.
With the new remangling API, the debugging lifecycle for local types
should be complete.

The extra LOCAL_CONTEXT record will compressed back down in a
subsequent patch.

Swift SVN r24739
2015-01-27 01:49:54 +00:00
David Farler
cad9f99929 Revert "Serialize local types and provide a lookup API"
Changing the design of this to maintain more local context
information and changing the lookup API.

This reverts commit 4f2ff1819064dc61c20e31c7c308ae6b3e6615d0.

Swift SVN r24432
2015-01-15 00:33:10 +00:00
David Farler
fab3d491d9 Serialize local types and provide a lookup API
rdar://problem/18295292

Locally scoped type declarations were previously not serialized into the
module, which meant that the debugger couldn't reason about the
structure of instances of those types.

Introduce a new mangling for local types:
[file basename MD5][counter][identifier]
This allows the demangle node's data to be used directly for lookup
without having to backtrack in the debugger.

Local decls are now serialized into a LOCAL_TYPE_DECLS table in the
module, which acts as the backing hash table for looking up
[file basename MD5][counter][identifier] -> DeclID mappings.

New tests:
* swift-ide-test mode for testing the demangle/lookup/mangle lifecycle
of a module that contains local decls
* mangling
* module merging with local decls

Swift SVN r24426
2015-01-14 22:08:47 +00:00
Argyrios Kyrtzidis
feb15c0421 [Basic] Include the diagnostic ID in the DiagnosticInfo that the diagnostic consumer receives.
Swift SVN r21213
2014-08-14 18:35:06 +00:00
Doug Gregor
f52c6789db Track the minimum deployment target and use it for 'unavailable' computations.
Swift SVN r20955
2014-08-02 18:05:45 +00:00
Doug Gregor
5fc8ac7fd1 Require the 'override' keyword for initializers that override designated initializers.
Swift SVN r20490
2014-07-24 15:38:33 +00:00
Jordan Rose
a2af37a19b Split PrintOptions::printEverything into printEverything and printVerbose.
The former is for debugging, the latter is for detailed presentation to users.
swift -print-ast will continue using printEverything, as will swift-ide-test,
but all other features should use printVerbose.

Swift SVN r20432
2014-07-23 22:28:55 +00:00
Chris Lattner
d8e5c0fb67 don't print the @transparent attributewhen dumping out a candidate list
in diagnostics.  We don't want this exposed to users.  This resolves
rdar://17763062.



Swift SVN r20313
2014-07-22 16:33:30 +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
f746b8c6dd [Accessibility] Public variables cannot have private types.
This does not yet handle variables with inferred types, since those don't
have TypePatterns.

There is some nasty propagation of @public into the stdlib because of this
one, mainly because Foundation needs access to some of the implementation
details of Array and Dictionary. We may want to try to improve this later
(or just build Foundation with -disable-access-control if it comes to that).

Swift SVN r19432
2014-07-01 22:30:53 +00:00
Jordan Rose
727a7eb77a Attributes: Use class names in the DAK_* enum instead of attribute spellings.
This allows for single attributes that can be spelled multiple ways.
No functionality change.

Swift SVN r18993
2014-06-18 23:28:28 +00:00
Argyrios Kyrtzidis
a5eeb9617a [Parser] Create ParamDecls even for unnamed parameters.
This preserves more of source info (e.g. API name location) and simplifies things since
we don't have to construct ParamDecls for the unnamed parameters later on.

Swift SVN r17828
2014-05-10 18:23:47 +00:00
Doug Gregor
b12f3f8dea Add TypeBase::getWithoutParens(), which may be useful outside of diagnostics.
Swift SVN r17725
2014-05-08 23:20:46 +00:00
Doug Gregor
98da27fcd9 Strip extraneous parentheses from diagnostic output.
They're excessive, silly, and tend to differ under -strict-keyword-arguments.


Swift SVN r17681
2014-05-08 04:48:35 +00:00
Jordan Rose
4e7cee3932 Show notes immediately following a fatal diagnostic, but nothing else.
<rdar://problem/16844281>

Swift SVN r17650
2014-05-07 23:52:14 +00:00
Argyrios Kyrtzidis
9418fb9948 [DiagnosticEngine] Mark module import diagnostic errors as 'fatal' errors, and supress subsequent diagnostics
to avoid a cascade of errors that drown out the original failure.

Swift SVN r17141
2014-05-01 05:24:48 +00:00
Doug Gregor
3d4df3427a Pretty-print DeclNames with no keyword arguments by dropping the parenthsized bit.
Instead of printing "f(_:_:)", just print "f". 


Swift SVN r17078
2014-04-30 06:28:36 +00:00
Chris Lattner
3165077552 Expand checking for implicit uses of self in closures to include method calls, and add
a fallback to catch anything else that is missed.  This resolve the rest of:
<rdar://problem/16193162> Require specifying self for locations in code where strong reference cycles are likely



Swift SVN r16344
2014-04-15 00:00:05 +00:00
Doug Gregor
cd4ca76b6a Introduce the ObjCSelector class to store an Objective-C selector.
We have to work with selectors quite often, so provide an efficient
representation for them. Switch ObjCAttr over to this representation,
which has the nice property that it efficiently represents implicit
@objc attributes with names and allows us to overwrite the Objective-C
name without losing all source information. Addresses
<rdar://problem/16478678>, and sets us up for dealing with selectors
better.

Swift SVN r16327
2014-04-14 20:05:35 +00:00