summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/TextDiagnosticPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Since multiple diagnostics can share one diagnostic client, have the client ↵Argyrios Kyrtzidis2010-11-181-0/+3
| | | | | | | | keeping track of the total number of warnings/errors reported. llvm-svn: 119731
* Refactoring of Diagnostic class.Argyrios Kyrtzidis2010-11-181-6/+8
| | | | | | | | | | | -Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class. -DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units. -The rest of the state in Diagnostic object is considered related and tied to one translation unit. -Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a SourceLocation instead of a FullSourceLoc. -Reflect the changes to various interfaces. llvm-svn: 119730
* Make sure to always check the result ofDouglas Gregor2010-11-121-2/+13
| | | | | | | SourceManager::getPresumedLoc(), so that we don't try to make use of an invalid presumed location. Doing so can cause crashes. llvm-svn: 118885
* Teach SourceManager::getPresumedLoc() how to fail gracefully if ↵Douglas Gregor2010-11-021-1/+1
| | | | | | getLineNumber/getColumnNumber fail llvm-svn: 117990
* Eliminate some extraneous whitespace in the machine-parseable Fix-It output.Douglas Gregor2010-08-201-2/+2
| | | | llvm-svn: 111610
* Add machine-parseable Fix-It output as part of diagnostics, under theDouglas Gregor2010-08-191-0/+42
| | | | | | flag -fdiagnostics-parseable-fixits, from Eelis van der Weegen! llvm-svn: 111557
* Simplify FixItHint by eliminated the unnecessary InsertionLocDouglas Gregor2010-08-181-2/+2
| | | | | | location. Patch by Eelis van der Weegen! llvm-svn: 111362
* Bug 7377: printf checking fails to flag some undefined behavior Tom Care2010-06-211-15/+18
| | | | | | | | | | | | | | | | | http://llvm.org/bugs/show_bug.cgi?id=7377 Updated format string highlighting and fixits to take advantage of the new CharSourceRange class. - Change HighlightRange to allow highlighting whitespace only in a CharSourceRange (for warnings about the ' ' (space) flag) - Change format specifier range helper function to allow for half-open ranges (+1 to end) - Enabled previously failing tests (FIXMEs/XFAILs removed) - Small fixes and additions to format string test cases M test/Sema/format-strings.c M test/Sema/format-strings-fixit.c M lib/Frontend/TextDiagnosticPrinter.cpp M lib/Sema/SemaChecking.cpp llvm-svn: 106480
* introduce a new CharSourceRange class, and enhance the diagnostics routinesChris Lattner2010-06-181-12/+18
| | | | | | | | | | | | | | | to use them instead of SourceRange. CharSourceRange is just a SourceRange plus a bool that indicates whether the range has the end character resolved or whether the end location is the start of the end token. While most of the compiler wants to think of ranges that have ends that are the start of the end token, the printf diagnostic stuff wants to highlight ranges within tokens. This is transparent to the diagnostic stuff. To start taking advantage of the new capabilities, you can do something like this: Diag(..) << CharSourceRange::getCharRange(Begin,End) llvm-svn: 106338
* when too many errors are emitted, and we produce:Chris Lattner2010-05-241-0/+2
| | | | | | | | fatal error: too many errors emitted, stopping now [-ferror-limit=] Tell the user that this is controlled with -ferror-limit=, like above. llvm-svn: 104528
* add a new -fdiagnostics-show-category=none/id/name option, giving controlChris Lattner2010-05-041-2/+7
| | | | | | | | | | | | over choice of: t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat] t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1] t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,Format String] dox to come. llvm-svn: 103056
* When -fdiagnostics-print-source-range-info is specified,Chris Lattner2010-05-041-4/+29
| | | | | | | | | | | | | | | | | | | | | | | print the diagnostic category number in the [] at the end of the line. For example: $ cat t.c #include <stdio.h> void foo() { printf("%s", 4); } $ clang t.c -fsyntax-only -fdiagnostics-print-source-range-info t.c:3:11:{3:10-3:12}{3:15-3:16}: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1] printf("%s", 4); ~^ ~ 1 warning generated. Clients that want category information can now pick the number out of the output, rdar://7928231. More coming. llvm-svn: 103053
* Introduce a limit on the depth of the macro instantiation backtraceDouglas Gregor2010-05-041-21/+61
| | | | | | | | | | | | | | printed in a diagnostic, similar to the limit we already have on the depth of the template instantiation backtrace. The macro instantiation backtrace is limited to 10 "instantiated from:" diagnostics; when it's longer than that, we'll show the first half, then say how many were suppressed, then show the second half. The limit can be changed with -fmacro-instantiation-limit=N, and turned off with N=0. This eliminates a lot of note spew with libraries making use of the Boost.Preprocess library. llvm-svn: 103014
* change FullSourceLoc to have a *const* SourceManager&, eliminatingChris Lattner2010-04-201-1/+1
| | | | | | a const_cast. llvm-svn: 101940
* Fix a bug in caret-line-pruning logic that only happens when we have aDouglas Gregor2010-04-161-3/+10
| | | | | | | | source line wider than the terminal where the associated fix-it line is longer than the caret line. Previously, we would crash in this case, which was rather unfortunate. Fixes <rdar://problem/7856226>. llvm-svn: 101426
* fix PR6814 - Only print [-pedantic] on a diagnostic if -pedantic Chris Lattner2010-04-121-2/+7
| | | | | | | | actually turned it on. If a diag is produced by a warning which is an extension but defaults to on, and has no warning group, don't print any option info. llvm-svn: 101071
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-7/+7
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-7/+7
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-7/+7
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Let SourceManager::getBufferData return StringRef instead of a pair of two ↵Benjamin Kramer2010-03-161-5/+2
| | | | | | const char*. llvm-svn: 98630
* Give SourceManager a Diagnostic object with which to report errors,Douglas Gregor2010-03-161-6/+5
| | | | | | and start simplifying the interfaces in SourceManager that can fail. llvm-svn: 98594
* Introduce a new BufferResult class to act as the return type ofDouglas Gregor2010-03-151-2/+8
| | | | | | | | | | | | | | SourceManager's getBuffer() (and similar) operations. This abstract can be used to force callers to cope with errors in getBuffer(), such as missing files and changed files. Fix a bunch of callers to use the new interface. Add some very basic checks for file consistency (file size, modification time) into ContentCache::getBuffer(), although these checks don't help much until we've updated the main callers (e.g., SourceManager::getSpelling()). llvm-svn: 98585
* Use SmallString instead of SmallVectorKovarththanan Rajaratnam2010-03-131-7/+7
| | | | llvm-svn: 98436
* Add TextDiagnosticPrinter::setPrefix, for adding a string to prefix diagnosticDaniel Dunbar2010-02-251-1/+4
| | | | | | messages with. llvm-svn: 97101
* when a diagnostic is an extension and has no other -W flag, Chris Lattner2010-02-161-1/+4
| | | | | | | | | | | | indicate that it was enabled with -pedantic so people know why they're getting them: $ printf "int x;" | clang -xc - -pedantic <stdin>:1:7: warning: no newline at end of file [-pedantic] int x; ^ llvm-svn: 96365
* restructure code a bit: there are two potential issuesChris Lattner2010-02-121-11/+15
| | | | | | | | | | | | worth asserting about in this code: 1) if the source range is bogus (begin loc after end loc), and 2) if the client is trying to highlight a range that is purely whitespace. It is possible to just silently ignore #2, but it seems like it is always a bug, so lets keep asserting on this condition, but with a better assert message. llvm-svn: 95998
* Print fix-it hints properly around tabs, from Christian Adåker!Douglas Gregor2010-01-181-0/+36
| | | | llvm-svn: 93750
* diagnose invalid values of -ftabstop, patch by Christian Adaker!Chris Lattner2010-01-131-2/+4
| | | | llvm-svn: 93288
* implement -ftabstop=width, patch by Christian AdåkerChris Lattner2010-01-091-2/+3
| | | | llvm-svn: 93078
* Fix an off by one in findEndOfWord, which could scan past the end of the ↵Daniel Dunbar2009-12-061-4/+9
| | | | | | string in a corner case. llvm-svn: 90703
* Remove 'LangOpts' from Diagnostic (added in ↵Steve Naroff2009-12-051-3/+1
| | | | | | | | | | http://llvm.org/viewvc/llvm-project?view=rev&revision=90642). Simply use the 'LangOpts' member already present in TextDiagnosticPrinter. Sorry for the confusion! llvm-svn: 90664
* Integrate the following from the 'objective-rewrite' branch:Steve Naroff2009-12-051-5/+13
| | | | | | | | | | | | http://llvm.org/viewvc/llvm-project?view=rev&revision=71086 Note - This commit only includes the fix for: <rdar://problem/6309338> slightly different error message format for Visual Studio. The fix for <rdar://problem/6845623> from protocol to template. is separate/forthcoming. llvm-svn: 90642
* Use PresumedLoc when emitting the 'included from' diagnostics. For a malformedChris Lattner2009-12-041-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test like this: #line 4 "foo" #define XX ? #if XX #endif We now emit: In file included from t.c:7: foo:7:5: error: invalid token at start of a preprocessor expression #if XX ^ foo:5:12: note: instantiated from: #define XX ? ^ instead of: In file included from t.c:7: foo:7:5: error: invalid token at start of a preprocessor expression #if XX ^ ./t.h:6:12: note: instantiated from: #define XX ? ^ (where the note doesn't obey #line or print the include stack when needed). This fixes PR5617 llvm-svn: 90554
* Allow TextDiagnosticPrinter to have optional ownership of its output stream.Daniel Dunbar2009-11-111-2/+9
| | | | llvm-svn: 86823
* Replace DiagnosticClient::setLangOptions with {Begin,End}SourceFile, and clarifyDaniel Dunbar2009-11-051-0/+1
| | | | | | | invariants (diagnostics with source informations must occur between {Begin,End}SourceFile). llvm-svn: 86113
* Factor out a diagnostic options class.Daniel Dunbar2009-11-041-24/+31
| | | | llvm-svn: 86010
* Workaround a bug exposed by the FileCheckify of message-length.c, the caret endDaniel Dunbar2009-10-191-0/+6
| | | | | | | | | column computation isn't correct and could exceed the line length, which resulted in a buffer overflow later. - Chris, is there a better way for this code to compute the final column used by the caret? llvm-svn: 84475
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-2/+2
| | | | llvm-svn: 81346
* Remove trailing whitespace.Daniel Dunbar2009-09-071-68/+68
| | | | llvm-svn: 81169
* Minor tweak to -fdiagnostics-print-source-range-info to make it printChris Lattner2009-06-151-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ranges more similar to the console output. Consider: #define FOO(X, Y) X/ Y void foo(int *P, int *Q) { FOO(P, Q); } Before we emitted: t.c:4:3:{4:3-4:6}{4:3-4:6}: error: invalid operands to binary expression ('int *' and 'int *') FOO(P, Q); ^~~~~~~~~ ... Note that while we underline the macro args that the range info just includes FOO without its macros. This change teaches the printed ranges to include macro args also so that we get: t.c:4:3:{4:3-4:12}{4:3-4:12}: error: invalid operands to binary expression ('int *' and 'int *') FOO(P, Q); ^~~~~~~~~ ... This fixes rdar://6939599 llvm-svn: 73378
* Add ANSI color support for clang.Torok Edwin2009-06-041-1/+55
| | | | llvm-svn: 72855
* "This patch fixes an obvious buffer overrun inDouglas Gregor2009-05-181-2/+2
| | | | | | SelectInterestingSourceRegion()," from Jay Foad! llvm-svn: 72049
* When word-wrapping, be more defensive about a ridiculously small number of ↵Douglas Gregor2009-05-151-2/+4
| | | | | | columns. Fixes <rdar://problem/6892178> llvm-svn: 71870
* Eliminate extra vertical space in Clang diagnosticsDouglas Gregor2009-05-061-21/+3
| | | | llvm-svn: 71066
* Fix rdar://6849429 - -Wunused-value with deeply nested macro expansion ↵Chris Lattner2009-05-051-14/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | generates untraceable warnings The "instantiated from" messages coming from the caret diagnostics system are basically walking the macro expansion tree, emitting each level as it goes. However, it was skipping certain leaves in the tree by skipping up the entire instantiation arm every time it went up one spelling arm. This caused it to miss some things. For example, in this testcase: #define M1(x) x #define M2 1; void foo() { M1(M2) } we now print: /Users/sabre/Desktop/clang-unused-value-macro.c:6:2: warning: expression result unused M1(M2) ^~~~~~ /Users/sabre/Desktop/clang-unused-value-macro.c:6:5: note: instantiated from: M1(M2) ^~ /Users/sabre/Desktop/clang-unused-value-macro.c:3:12: note: instantiated from: #define M2 1; ^ Previously we didn't print the last line, so we never emitted the caret pointing to the 1! Incidentally, the spaces between the lines is really noisy, I think we should reconsider this heuristic (which adds them when the printed code starts too close to the start of the line). The regression test can't use -verify, because -verify doesn't catch notes for macro instantiation history. llvm-svn: 71025
* Simplify the interesting-region code by assimmilating blocks of ↵Douglas Gregor2009-05-041-57/+18
| | | | | | non-whitespace text with each expansion step. It's easier and seems to have better results. llvm-svn: 70833
* Tweak the extraction of the "interesting" part of a source range in two ways: Douglas Gregor2009-05-041-4/+19
| | | | | | | | | 1) First of all, we treat _ as part of an identifier and not as punctuation (oops). 2) Second of all, always make sure that the token that the ^ is pointing at is fully within the "interesting" part of the range. llvm-svn: 70831
* Fix an infinite loop in diagnostic printing.Daniel Dunbar2009-05-031-7/+5
| | | | | | | | | | - The diagnostic is still poor, however. Doug, can you investigate? - Improved the test case to not depend on the file name, now it can be extended to actually check the formatting of the diagnostics (I'm hoping grep -A is portable here). llvm-svn: 70807
* Fix crash in source-line truncation code for diagnosticDouglas Gregor2009-05-031-2/+3
| | | | | | | printing. Also, when we only need to truncate the line at the end, make sure there is room for the ellipsis. llvm-svn: 70781
* temporary hack to work around PR4128Chris Lattner2009-05-031-1/+1
| | | | llvm-svn: 70681
OpenPOWER on IntegriCloud