Commit Graph

169 Commits

Author SHA1 Message Date
Owen Voorhees
791312fb74 Turn Educational Notes On-By-Default (#30583)
* [Diagnostics] Turn educational notes on-by-default

* [Diagnostics] Only include educational notes in printed output if -print-educational-notes is passed

* Make -print-educational-notes a driver option

* [Diagnostics] Issue a printed remark if educational notes are available, but disabled

* [docs] Update educational notes documentation and add a contributing guide

* [Diagnostics] Cleanup PrintingDiagnosticConsumer handling of edu notes

* Revert "[Diagnostics] Issue a printed remark if educational notes are available, but disabled"
For now, don't notify users if edu notes are available but disabled. This decision can be reevaluated later.
2020-03-27 15:29:48 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Owen Voorhees
69b513afaf [Diagnostics] Updated (experimental) diagnostic printing style (#30027)
* [Diagnostics] Experimental diagnostic printing updates

This new style directly annotates small snippets of code with
error messages, highlights and fix-its. It also uses color more
effectively to highlight important segments.

* [Diagnostics] Stage educational notes and experimental formatting behind separate frontend flags

educational notes -> -enable-educational-notes
formatting -> -enable-experimental-diagnostic-formatting

* [Diagnostics] Refactor expensive line lookups in diag formatting

* [Diagnostics] Refactor some PrintingDiagnosticConsumer code into a flush method

* [Diag-Experimental-Formatting] Custom formatting for Xcode editor placeholders

* [Diag-Experimental-Formatting] Better and more consistent textual description of fix its

* [Diags-Experimental-Formatting] Handle lines with tab characters correctly when rendering highlights and messages

Tabs are converted to 2 spaces for display purposes.

* [Diag-Experimental-Formatting] Refactor byte-to-column mapping for efficiency

* [Diag-Experimental-Formatting] Fix line number indent calculation

* [Diag-Experimental-Formatting] Include indicators of insertions and deletions in the highlight line

Inserts are underlined by green '+' chars, deletions by red '-' chars.

* [Diag-Experimental-Formatting] Change color of indicator arrow for non-ASCII anchored messages
* [Diag-experimental-formatting] Make tests less sensitive to line numbering

* [Diag-Experimental-Formatting] Update tests to allow windows path separators

* [Diag-Experimental-Formatting] Bug fixes for the integrated REPL
2020-03-03 08:48:32 -08:00
Daniel Rodríguez Troitiño
6792e0bcfd Merge pull request #28170 from drodriguez/msc-alternative-to-array-designators
[Visual C++] Provide alternative to array designators.
2019-11-09 12:17:24 -08:00
Daniel Rodríguez Troitiño
eb7a26db09 [Visual C++] Provide alternative to array designators.
Even if they are supported in GCC and Clang, C99 array designators are
not part of the current C++ standard (they will be in C++20), so they
are not supported in Visual C++.

This commit provides an alternative for Visual C++ (which should work in
other compilers) which doesn't use array designators.

I think Clang 10 will start printing a warning about this incorrect
usage.
2019-11-09 08:55:09 -08:00
Brent Royal-Gordon
37d3ce7b95 Merge pull request #28177 from brentdax/diagnostics-in-your-diagnostics
[NFC] [DiagnosticEngine] Improve output for malformed diagnostic messages
2019-11-08 23:03:46 -08:00
Brent Royal-Gordon
4f8756d13a [NFC] [DiagnosticEngine] Improve output for malformed diagnostic messages
This is NFC as long as you assume there are no bad diagnostics.
2019-11-08 19:48:34 -08:00
Owen Voorhees
ac05a66938 [Diagnostics] Introduce "Educational Notes" for diagnostics
Educational notes are small pieces of documentation which explain a concept
relevant to some diagnostic message. If -enable-descriptive-diagnostics is
passed, they will be printed after a diagnostic message if available.

Educational notes can be found at /usr/share/doc/diagnostics in a
toolchain, and are associated with specific compiler diagnostics in
EducationalNotes.def.
2019-11-07 13:18:35 -08:00
Varun Gandhi
64401ac92c [NFC] Replace StringMap<char, A> with StringSet<A> (#27986) 2019-10-31 12:46:58 -07:00
Owen Voorhees
8a6711769e [Diagnostics] Refactor DiagnosticConsumer interface
DiagnosticInfo now holds all the information needed to consume
a diagnostic, so remove unneeded parameters from handleDiagnostic.
2019-10-29 13:52:12 -07:00
Jordan Rose
5f2695808d Merge pull request #26830 from owenv/diag_child_notes_refactor
[Diagnostics][NFC] Optionally add notes as explicit children of an error/warning
2019-10-02 14:34:33 -07:00
Slava Pestov
b1ffa19c7b AST: Refine recursive property checks on type alias types 2019-09-24 17:39:53 -04:00
Robert Widmann
38bde33067 Merge pull request #27172 from CodaFi/aliasing-artifacts-and-noise-reduction-techniques
Kill validateDeclForNameLookup Harder
2019-09-18 15:00:51 -07:00
Jordan Rose
8d7f1b7c5d [AST] Separate SourceFile from FileUnit.h
Like the last commit, SourceFile is used a lot by Parse and Sema, but
less so by the ClangImporter and (de)Serialization. Split it out to
cut down on recompilation times when something changes.

This commit does /not/ split the implementation of SourceFile out of
Module.cpp, which is where most of it lives. That might also be a
reasonable change, but the reason I was reluctant to is because a
number of SourceFile members correspond to the entry points in
ModuleDecl. Someone else can pick this up later if they decide it's a
good idea.

No functionality change.
2019-09-17 17:54:41 -07:00
Jordan Rose
853caa66d4 [AST] Split FileUnit and its subclasses out of Module.h
Most of AST, Parse, and Sema deal with FileUnits regularly, but SIL
and IRGen certainly don't. Split FileUnit out into its own header to
cut down on recompilation times when something changes.

No functionality change.
2019-09-17 17:54:41 -07:00
Robert Widmann
5e34169aca Separate computing interface types and underlying types
Computing the interface type of a typealias used to push validation forward and recompute the interface type on the fly.  This was fragile and inconsistent with the way interface types are computed in the rest of the decls.  Separate these two notions, and plumb through explicit interface type computations with the same "computeType" idiom.  This will better allow us to identify the places where we have to force an interface type computation.

Also remove access to the underlying type loc.  It's now just a cache location the underlying type request will use.  Push a type repr accessor to the places that need it, and push the underlying type accessor for everywhere else.  Getting the structural type is still preferred for pre-validated computations.

This required the resetting of a number of places where we were - in many cases tacitly - asking the question "does the interface type exist".  This enables the removal of validateDeclForNameLookup
2019-09-17 08:20:55 -07:00
Owen Voorhees
000294f5b1 [Diagnostics][NFC] Optionally add notes as explicit children of an error/warning
Add a new type of diagnostic transaction, CompoundDiagnosticTransaction.
The first diagnostic emitted inside the transaction will become the parent of the subsequent notes.
DiagnosticConsumers may opt in to consuming these child notes alongside the parent
diagnostic, or they can continue to consider them seperately.

Moved PrintingDiagnosticConsumer and a couple of diagnostics to the new
system as a proof of concept.
2019-09-16 17:33:40 -07:00
Jordan Rose
94f1d2c159 Merge pull request #26612 from owenv/formatted_fixits
[Diagnostics][NFCI] Introduce Structured fix-its
2019-09-05 17:51:42 -07:00
Owen Voorhees
68e6065c8e [Diagnostics][NFC] Introduce Structured fix-its
These are defined with macros like errors/warnings/notes, and
make use of format strings and diagnostic arguments. The intent
is to leverage diagnostic arguments in the future to disambiguate
ambiguously spelled types.

Ported a few miscellaneous fix-its to the new system
2019-09-05 10:43:25 -07:00
Rintaro Ishizaki
242699f933 [IDE] Disable constraint system diagnostics during code completion
It seems disabling diagnstics doesn't introduce any regression.

rdar://problem/50679428
2019-08-30 15:25:11 -07:00
Owen Voorhees
486c7b883d [Diagnostics][NFC] Add support for using the %select format specifier with StringRef args
Get rid of some redundant availability diagnostics as a result.
2019-08-26 11:37:29 -07:00
Owen Voorhees
e7a1a1cc3d Add -debug-diagnostic-names frontend flag
This flag adds diagnostic names to the end of their messages, e.g. 'error: cannot convert value of type '[Any]' to specified type '[Int]' [cannot_convert_initializer_value]'. It's intended to be used for debugging purposes when working on the compiler.
2019-08-05 18:54:21 -07:00
Pavel Yaskevich
b1e0980887 [AST] DiagnosticEngine: use references to replace string arguments 2019-07-24 18:14:17 -07:00
Pavel Yaskevich
eafa51d934 [AST] DiagnosticEngine: retain strings used in tentative diagnostic arguments
If diagnostics are produced as part of a transaction, let's copy
strings associated with arguments into a separate long(er) term
storage which is going to be cleaned up when diagnostic is actually
emit to the consumers.
2019-07-24 16:59:38 -07:00
Owen Voorhees
89eaa1e612 [Diagnostics] Desugar syntax sugared types if they have unresolved types
If a syntax sugared type like Array had an unresolved type, it used to print as `[_]` in diagnostics, which could be confusing.
Instead, desugar these unresolved types before printing, so Array, for example, prints as `Array<_>`.
Currently this only applies to Array, Dictionary, and Optional.
2019-07-03 08:11:31 -07:00
Jordan Rose
cb6d47ef24 Show 'some' type origins in diagnostics, like 'aka' for sugared types (#25624)
Currently only works for types that are /just/ a 'some' type, not in a
nested position. Also won't show them for opaque types with different
requirements, to avoid noise when it's not strictly necessary. This
does mean that 'some P' vs. 'some P & Q' won't get the origin part.

Part of rdar://problem/50346954
2019-06-28 20:42:47 -07:00
Owen Voorhees
9d07d06886 [Diagnostics]: Qualify Type arguments to diagnostics if there are name collisions
If a diagnostic argument list contains two or more types which are distinct but have the same name, make sure they are qualified when printed
2019-06-26 19:13:40 -07:00
Michael Gottesman
69335f02c3 [diagnostics] Add the llvm option swift-diagnostics-assert-on-warning to cause the diagnostics engine to assert upon triggering a warning.
This is an option only intending to help compiler developers triage/track down
why a warning is being emitted in a quick manner. It will only be in asserts
builds since it is an LLVM option.
2019-05-22 19:18:35 -07:00
David Ungar
aa0687a816 Typo and handle recursive RAII case. 2019-04-05 11:14:27 -07:00
David Ungar
c8cd0f3bc0 Move location lookup to RAII object. 2019-04-04 22:41:53 -07:00
David Ungar
9d99eb7f83 Fix typo 2019-04-04 16:22:39 -07:00
David Ungar
44daa88ebd Format 2019-04-03 12:53:31 -07:00
David Ungar
9cc3a4a9d8 Rename defaultDiagnosticLoc to bufferIndirectlyCausingDiagnostic. 2019-04-03 12:52:49 -07:00
David Ungar
b112f73780 Typos 2019-04-02 22:52:14 -07:00
David Ungar
c139c5909a Pass defaultDiagnosticLoc to handleDiagnostic, not currentPrimaryInput. 2019-04-02 22:27:55 -07:00
David Ungar
7a0e0ffc8a Store current primary in diagnostic engine, pass it down via handleDiagnostic. Unformmated. 2019-04-02 00:43:28 -07:00
David Zarzycki
f99124569b [Diag] Formalize SelfAccessKind printing 2019-03-25 15:40:26 -04:00
Robert Widmann
c5b7230d22 [NFC] Upgrade EnumElementDecl to a DeclContext
Pure plumbing for the sake of default arguments.
2019-01-16 18:39:30 -05:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Doug Gregor
7c10c61a92 [Type checker] Stop (ab)using TypeChecker::Diags to suppress diagnostics.
Take away the type checker constructor that allows one to provide a
diagnostic engine different from the one associated with the ASTContext. It
doesn’t actually work to suppress diagnostics. Switch all clients over to
the constructor that takes only an ASTContext.

Introduce the DiagnosticSuppression RAII class so clients that want to
suppress diagnostics can suppress *all* diagnostics. Use it where we
were previously suppressing diagnostics.
2018-10-09 21:33:31 -07:00
Jordan Rose
916e1e6e6c Constify DiagnosticEngine's lists of diagnostic info (#19335) 2018-09-17 11:27:23 -07:00
David Ungar
20d099d4ce Remove now-unneeded argument from finishProcessing. 2018-06-12 16:37:04 -07:00
David Ungar
524d88e921 Pass SM in finishProcessing 2018-05-12 19:40:09 -07:00
David Ungar
8baef6abd5 WIP backup 2018-05-11 17:28:39 -07:00
David Ungar
70aecfef36 Emit error diagnostic for a primary if all errors suppressed 2018-05-11 15:14:42 -07:00
David Zarzycki
e326954bd0 [Diag] QoI: Add ReferenceOwnership to DiagnosticArgumentKind
By formalizing ReferenceOwnership as a diagnostic argument kind, we get
less boilerplate, better type safety, better output consistency, and
last but not least: future proofing.
2018-04-20 08:32:43 -04:00
Doug Gregor
b2b69e8abf Rename BoundNameAliasType to NameAliasType.
NameAliasType is dead! Long live NameAliasType!
2018-03-25 21:35:17 -07:00
Doug Gregor
c43f96a855 [AST] Remove now-unused NameAliasType. 2018-03-25 21:35:16 -07:00
Doug Gregor
e82e7ee908 [Type checker] Use BoundNameAliasType for all typealiases.
Rather than relying on the NameAliasType we get by default for references
to non-generic typealiases, use BoundNameAliasType consistently to handle
references to typealiases that are formed by the type checker.
2018-03-25 21:35:16 -07:00