Граф коммитов

57 Коммитов

Автор SHA1 Сообщение Дата
NAKAMURA Takumi 77163bc392 TextDiagnostic.cpp: Suppress a warning to use ptrdiff_t on i686-clang. [-Wsign-compare]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174353 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-05 07:37:07 +00:00
Jordan Rose 91165e74c8 Diagnostics: Clarify name of line-length-limiting constant in r173976.
Thanks, Sean.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173981 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30 22:14:15 +00:00
Jordan Rose f6e74a35e0 Diagnostics: if a line is longer than 4096 characters, don't print it.
Specifically, don't print snippets, caret diagnostics, or ranges for
lines over 4096 characters. We copy the line around a few times in our
diagnostics machinery, and we have to print a caret line that's just as
long. This uses a lot of memory just to create a poor user experience as
we print out a line much too long for anyone to read...or spend extra
energy trying to fit it to -fmessage-length.

<rdar://problem/13106850>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173976 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30 21:41:07 +00:00
Dmitri Gribenko cb5620c9b2 Move UTF conversion routines from clang/lib/Basic to llvm/lib/Support
This is required to use them in TableGen.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173924 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30 12:06:08 +00:00
Douglas Gregor 813bc7faa7 Be defensive when printing module import locations; the diagnostic printer needs to be robust
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170466 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-18 23:02:07 +00:00
Chandler Carruth 55fc873017 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 09:13:33 +00:00
Benjamin Kramer c2b914fb6f Make helper classes anonymous. Make helper functions static instead of private members so the anonymous class doesn't leak out.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169099 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 20:58:01 +00:00
Douglas Gregor 6c3254316d When we're emitting a diagnostic with a source location in an imported
module, provide a module import stack similar to what we would get for
an include stack, e.g.,

In module 'DependsOnModule' imported from build-fail-notes.m:4:
In module 'Module' imported from DependsOnModule.framework/Headers/DependsOnModule.h:1:
Inputs/Module.framework/Headers/Module.h:15:12: note: previous definition is here
@interface Module

<rdar://problem/12696425>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169042 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 21:58:49 +00:00
Douglas Gregor 830ea5b7c7 When an error occurs while building a module on demand, provide "While
building module 'Foo' imported from..." notes (the same we we provide
"In file included from..." notes) in the diagnostic, so that we know
how this module got included in the first place. This is part of
<rdar://problem/12696425>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169021 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 18:38:50 +00:00
Seth Cantrell 191db6dc0d only truncate source lines in text diagnostics when
the ellipsis is shorter than the text it replaces

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167364 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-03 23:56:43 +00:00
Seth Cantrell 9cffb4a9ae don't step into the middle of multibyte sequences
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167361 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-03 21:21:17 +00:00
Seth Cantrell eaa5a2b5e0 fix bug in SourceColumnMap::startOfPreviousColumn
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167360 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-03 21:21:14 +00:00
Eli Friedman 9cb1c3de9d Add a proper algorithm to compute accurate source ranges for diagnostics with
caret locations and source ranges in macros.  Makes ranges more accurate
in some cases, and fixes an assertion failure.

Fixes <rdar://problem/12472249>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167353 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-03 03:36:51 +00:00
Seth Cantrell 0d1e645bbf remove duplicate data array
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167007 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30 06:13:52 +00:00
Seth Cantrell c6a2f6e2dd fix calculation of end pointer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167006 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30 06:13:50 +00:00
Douglas Gregor dc7b641574 Use a .def file for most of the diagnostic options.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166520 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 23:11:23 +00:00
Douglas Gregor 02c23ebf41 Make DiagnosticOptions intrusively reference-counted, and make sure
the various stakeholders bump up the reference count. In particular,
the diagnostics engine now keeps the DiagnosticOptions object alive.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166508 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 22:26:28 +00:00
Benjamin Kramer 4ca3abd368 Emit diagnostics in chunks even when we're trying to print colored template diffs.
char-by-char is really slow on an unbuffered stream.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166218 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 20:09:54 +00:00
Sylvestre Ledru f3477c13ee Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164766
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164769 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-27 10:16:10 +00:00
Sylvestre Ledru 94ff8e1f57 Fix a typo 'iff' => 'if'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164766 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-27 09:57:10 +00:00
Richard Smith c7bb384d60 Make TextDiagnostic more robust against SourceLocations which point into the
middle of UTF-8 characters, and avoid walking to such positions when adjusting
column ranges for display. Fixes a couple of hangs when rendering diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163820 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13 18:37:50 +00:00
Joerg Sonnenberger 7094dee95f Add missing cctype includes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161660 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10 10:58:18 +00:00
Benjamin Kramer fbffb5f91e Remove unused variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161483 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-08 09:26:28 +00:00
Sylvestre Ledru bed28ac1d1 Fix a typo (the the => the)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160622 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 08:59:39 +00:00
Jordan Rose bbe0175255 Re-apply r160319 "Don't crash when emitting fixits following Unicode chars"
This time, make sure we don't try to print fixits with newline characters,
since they don't have a valid column width, and they don't look good anyway.

PR13417 (and originally <rdar://problem/11877454>)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160561 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 18:50:51 +00:00
Nico Weber 4397289861 Revert r160319, it caused PR13417. Add a test for PR13417.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160542 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 06:44:52 +00:00
Jordan Rose 6f977c3e79 Don't crash when emitting fixits following Unicode characters.
This code is very sensitive to the difference between "columns" as printed
and "bytes" (SourceManager columns). All variables are now named explicitly
and our assumptions are (hopefully) documented as both comment and assertion.

Whether parseable fixits should use byte offsets or Unicode character counts
is pending discussion on the mailing list; currently the implementation uses
bytes (and has no problems on lines containing multibyte characters).
This has been added to the user manual.

<rdar://problem/11877454>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160319 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16 20:52:12 +00:00
Benjamin Kramer af082c3b16 PR13312: Don't crash when printing a fixit that ends in a unicode character.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160112 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 08:20:49 +00:00
Richard Trieu b956e5a243 When applying a template diff highlighting to a diagnostic message, remember
to reapply the bold formatting when needed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159386 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-28 22:39:03 +00:00
David Blaikie 50badd523b Fix template type diffing coloring (r159216) when forcing color output to a file (not a terminal)
Reviewed (over the shoulder) by Richard Trieu.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159381 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-28 21:46:07 +00:00
Richard Trieu 246b6aa676 Add template type diffing to Clang. This feature will provide a better
comparison between two templated types when they both appear in a diagnostic.
Type elision will remove indentical template arguments, which can be disabled
with -fno-elide-type.  Cyan highlighting is applied to the differing types.

For more formatting, -fdiagnostic-show-template-tree will output the template
type as an indented text tree, with differences appearing inline. Template
tree works with or without type elision.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159216 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-26 18:18:47 +00:00
James Dennett 6b4f50662a Documentation cleanup: escape \ characters in Doxygen comments as needed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158968 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-22 05:33:23 +00:00
Jordan Rose 3772c9abf9 If fixits appear to overlap, move the second one over in the output.
This occurs when you have two insertions and the first one is so long that the
second fixit's column is before the first fixit ends. The edits themselves
don't actually overlap, but our command-line preview does.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158229 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08 21:14:19 +00:00
Seth Cantrell 4031a37627 ensure value passed to is space is representable as unsigned char
if the value isn't an unsigned char or EOF behavior is undefined
(and on Windows there's an assertion)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157445 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-25 00:03:29 +00:00
Seth Cantrell c5493d7d60 fix Bug 12924
http://llvm.org/bugs/show_bug.cgi?id=12924

This issue was that the source location was pointing to a
non-printable character and so CaretEnd was pointing one
_column_ past the caret but not one _character_ past the
caret. So the conversion between column and byte locations
wasn't working (because the conversion is only valid from
the first column or byte of a character).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157372 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-24 05:14:44 +00:00
Argyrios Kyrtzidis 16afdf76b6 Fix an assertion hit when the serialized diagnostics writer receive a diagnostic
from the frontend when the location is invalid and the SourceManager null.

Instead of keeping the SourceManager object in DiagnosticRenderer, propagate it
to the calls accordingly (as reference when it is expected to not be null, or pointer
when it may be null).
This effectively makes DiagnosticRenderer not tied to a specific SourceManager,
removing a hack from TextDiagnosticPrinter.

rdar://11386874

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156536 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-10 05:03:45 +00:00
Benjamin Kramer d1fda0393b Make some helper functions static.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155914 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 14:34:11 +00:00
Nico Weber 40d8e971a3 Revert r154981, because it caused PR12674.
Add a test for PR12674.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155666 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-26 21:39:46 +00:00
Matt Beaumont-Gay 0ddb097bb0 Suppress -Wunused-variable warning in -Asserts build
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155011 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-18 17:25:16 +00:00
Seth Cantrell 3acf764931 fix display of source lines with null characters
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154981 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-18 02:44:48 +00:00
Seth Cantrell 6749dd5086 Nicer display of unprintable source, and fix caret display for non-ascii text
Unprintable source in diagnostics is transformed to a printable form and then
displayed with reversed colors if possible. Unprintable characters are
displayed as <U+NNNN> while bytes that do not represent valid characters are
shown as <XX>.

Column adjustments to diagnostic carets, highlighted ranges, and fixups are
made both for characters escaped as above and for characters which are
printable but take up more than a single column.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154980 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-18 02:44:46 +00:00
Seth Cantrell 9591697707 Revert "Nicer display of unprintable source, and fix caret display for non-ascii text"
This reverts commit e9a3b76ba5.

Revert "fix display of source lines with null characters"

This reverts commit 70712b276e.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154950 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-17 20:59:59 +00:00
Seth Cantrell 70712b276e fix display of source lines with null characters
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154947 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-17 20:06:06 +00:00
Seth Cantrell e9a3b76ba5 Nicer display of unprintable source, and fix caret display for non-ascii text
Unprintable source in diagnostics is transformed to a printable form and then
displayed with reversed colors if possible. Unprintable characters are
displayed as <U+NNNN> while bytes that do not represent valid characters are
shown as <XX>.

Column adjustments to diagnostic carets, highlighted ranges, and fixups are
made both for characters escaped as above and for characters which are
printable but take up more than a single column.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154946 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-17 20:06:03 +00:00
Ted Kremenek 8be51eab5a Refactor DiagnosticRenderer and SDiagsRenderer to have some functionality
pulled into DiagnosticNoteRenderer, and common DiagnosticRenderer that
assumes that all custom diagnostic messages are notes.  Also extend
DiagnosticRenderer to work with StoredDiagnostics in preparation for
subsequent changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150455 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-14 02:46:00 +00:00
Dylan Noblesmith f7ccbad5d9 Basic: import SmallString<> into clang namespace
(I was going to fix the TODO about DenseMap too, but
that would break self-host right now. See PR11922.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149799 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-05 02:13:05 +00:00
Ted Kremenek 2898d4f764 Refactor 'TextDiagnostic' to have a parent class 'DiagnosticRenderer' which handles
the policy of how diagnostics are lowered/rendered, while TextDiagnostic handles
the actual pretty-printing.

This is a first part of reworking SerializedDiagnosticPrinter to use the same
inclusion-stack/macro-expansion logic as TextDiagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146819 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-17 05:26:04 +00:00
Chandler Carruth 9875c6020f Switch to a more natural formatting of the macro name printing.
Suggested by John McCall.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142836 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-24 18:51:08 +00:00
Chandler Carruth fe627b0e16 Hoist the logic I added to compute the macro name into a helper
function. No functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142128 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-16 09:39:09 +00:00
Chandler Carruth a47129e97b Now that macro expansion notes are real notes and go through the same
formatting as any other diagnostic, they will be properly line wrapped and
otherwise pretty printed. Let's take advantage of that and the new factoring to
add some helpful information to them (much like template backtrace notes and
other notes): the name of the macro whose expansion is being noted. This makes
a world of difference if caret diagnostics are disabled, making the expansion
notes actually useful in this case. It also helps ensure that in edge cases the
information the user needs is present. Consider:

% nl -ba t5.cc
     1  #define M(x, y, z) \
     2    y
     3
     4  M(
     5    1,
     6    2,
     7    3);

We now produce:
% ./bin/clang -fsyntax-only t5.cc
t5.cc:6:3: error: expected unqualified-id
  2,
  ^
t5.cc:2:3: note: expanded from macro: M
  y
  ^
1 error generated.

Without the added information in the note, the name of the macro being expanded
would never be shown.

This also deletes a FIXME to use the diagnostic formatting. It's not yet clear
to me that we *can* do this reasonably, and the production of this message was
my primary goal here anyways.

I'd love any comments or suggestions on improving these notes, their wording,
etc. Currently, I need to make them provide more helpful information in the
presence of a token-pasting buffer, and I'm pondering adding something along
the lines of "expanded from argument N of macro: ...".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142127 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-16 09:30:08 +00:00