Commit Graph

169 Commits

Author SHA1 Message Date
Doug Gregor
bde6401f5b Support BoundNameAliasType everywhere we support NameAliasType.
This doesn't have a specific effect now, because all of these places
are likely to only see NameAliasType, but it is refactoring with the
intent of eliminating NameAliasType entirely.
2018-03-25 20:46:07 -07:00
Doug Gregor
80eae200b6 [AST] Preserve type sugar for generic typealiases
Introduce a new Type node, BoundNameAliasType, which describes a
reference to a typealias that requires substitutions to produce the
underlying type. This new type node is used both for references to
generic typealiases and for references to (non-generic) typealiases
that occur within generic contexts, e.g., Array<Int>.Element.

At present, the new type node is mainly useful in preserving type
sugar for diagnostics purposes, as well as being reflected in other
tools (indexing, code completion, etc.). The intent is to completely
replace NameAliasType in the future.
2018-03-21 23:49:17 -07:00
Michael Gottesman
5d18bb86ba [sema] Add support for asserting on the first error that occurs.
This enables one to easily drop down into the debugger in such cases. This is
enabled by the option swift-diagnostics-assert-on-error and can only happen in
an asserts build.

rdar://34222540
2017-12-08 17:43:46 -08:00
Adam Nemet
9b9805420d Add optimization remarks
This allows reporting successful and unsuccessful optimizations similar to
clang/llvm.

This first patch adds support for the
options -Rpass=<pass-name-regex> -Rpass-missed=<pass-name-regex>.  These allow
reporting successful/unsuccessful optimization on the compiler output for passes
specified by the regex.  I've also added one missed and one passed remark type
to the inliner to test the infrastructure.

Clang also has the option of collecting these records in an external YAML data
file.  This will be added in a later patch.

A few notes:
* The goal is to use this facility for both user-lever "performance" warnings
and expert-level performance analysis.  There will probably be a flag in the
future differentiating the verbosity.

* The intent is match clang/llvm as much as it makes sense.  On the other hand I
did make some changes.  Unlike in llvm, the emitter is not a pass which
simplifies things.  Also the remark class hierarchy is greatly simplified since
we don't derive from DiagnosticInfo.  We also don't derive from Diagnostic to
support the streaming API for arbitrary named-value pairs.

* Currently function names are printed mangled which should be fixed.
2017-10-20 12:41:37 -07:00
Alex Hoppen
949968a182 Adjust printing to take into account special DeclNames
Print DeclBaseNames using a new userFacingStr() method to prepare for
DeclBaseNames that are not backed by Identifiers
2017-06-24 11:39:09 +02:00
Jordan Rose
e9e5abfce0 [Diagnostics] Fix localizable quotation marks for printing ValueDecls. (#10136)
Accidental mistake in rebasing the DeclBaseName patches.
2017-06-05 20:10:41 -07:00
Argyrios Kyrtzidis
eea9732e54 [frontend] Address feedback by Jordan 2017-05-05 18:31:21 -07:00
Argyrios Kyrtzidis
0bb299abc8 [frontend] Add 'finishProcessing()' method for DiagnosticConsumers to do their finalization (e.g. writing to a file)
Use this to avoid creating an empty serialized diagnostics file when the compiler crashes.
2017-05-05 18:25:02 -07:00
Slava Pestov
d07a3f821f Sema: Fix the 'aka AnyObject' thing some more 2017-05-02 01:16:47 -07:00
Slava Pestov
b57b4cfcb7 AST: Don't emit 'AnyObject' (aka 'AnyObject') for primitive AnyObject 2017-05-01 17:32:58 -07:00
Jordan Rose
dbc148bfb3 [ClangImporter] Tag compatibility aliases as such...
...so we can avoid showing an 'aka' for them...unless they are
themselves typealiases.
2017-04-26 13:07:03 -07:00
Jordan Rose
4b87bd93f9 Tweak DiagnosticEngine's 'aka' logic to only kick in for typealiases. (#9010)
Previously we had more ad hoc logic that tried to decide if it was
worth desugaring a type based on its structure. Now we instead look
for a typealias that might actually benefit from desugaring, and if
we don't find one we won't show the 'aka' note.
2017-04-25 19:37:22 -07:00
Maxwell Swadling
93d485e4f7 Changed handleDiagnostic to take a format string and format args instead of the formatted string
This allows diagnostic consumers to modify the way formatting of diagnostics is performed.
rdar://problem/31305854
2017-04-14 11:28:04 -07:00
Doug Gregor
d5d2db5185 [Diagnostics] Allow ValueDecl* diagnostic arguments.
Render these via their full names.
2017-03-06 16:32:29 -08:00
Roman Levenstein
2e58786705 Support layout constraints in diagnostics machinery. 2017-01-11 19:21:45 -08:00
Hugh Bellamy
7a5ef4bdd1 Support building swift/AST with MSVC on Windows 2017-01-09 09:05:06 +00:00
Slava Pestov
8d3516abfa Merge pull request #5871 from jtbandes/open-season
[Diagnostics] handle ‘open’ access control; introduce %error modifier
2017-01-09 00:54:31 -08:00
Slava Pestov
7731d4c6cb Sema: Remove some unnecessary calls to getCanonicalType() 2017-01-08 21:01:13 -08:00
Brian Gesiak
663b92ece9 [AST] Completely replace Module with ModuleDecl
The typedef `swift::Module` was a temporary solution that allowed
`swift::Module` to be renamed to `swift::ModuleDecl` without requiring
every single callsite to be modified.

Modify all the callsites, and get rid of the typedef.
2017-01-08 00:36:08 -05:00
Jacob Bandes-Storch
32635696bd [Diagnostics] handle ‘open’ access control; introduce %error modifier 2017-01-06 22:48:29 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Slava Pestov
f3c72d8941 AST: Remove SubstitutedType 2016-12-07 17:03:07 -08:00
Michael Gottesman
1af1cbfb76 [gardening] Add a bunch of end namespace comments found by clang-tidy. 2016-12-06 19:22:52 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift
4552fc8f88 [gardening] Use American English: "behaviour" → "behavior" 2016-11-05 20:33:57 +01:00
Slava Pestov
a1eef126ba AST: Don't print "aka <<desugared type>>" for generic function types
This was causing us to emit diagnostics talking about τ_m_n, which is
not helpful.

Now that generic function types print sanely, print them in a few
places where we were previously printing PolymorphicFunctionTypes.
2016-09-15 21:47:57 -07:00
Rintaro Ishizaki
96600fe97a [Diag] Factor-out some common logic 2016-08-26 02:39:08 +09:00
Rintaro Ishizaki
ba982bc01c [Diag] Make fixItReplace slightly smart
When replace something with a punctuator, we often prefer adding spaces around it.
For instance,

   func foo(): bar {}
   // fix it
   func foo() -> bar {}

In this case we want to add a space before '->', but not after that.

With this change, we can simply `fixItReplace(ColonLoc, " -> ")`.
`fixItReplace()` automatically adjust the spaces around it.
2016-08-25 13:51:55 +09:00
Rintaro Ishizaki
538c94f2ce [AST] Add fixItExchange method on InFlightDiagnostic
funcName(foo: 12, quux: 42)
         ~~~~~~~  ~~~~~~~~
         quux: 42 foo: 12
2016-06-29 11:47:57 +09:00
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