summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/TextDiagnosticPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename lib/Driver (etc) to lib/Frontend in prep for the *actual*Daniel Dunbar2009-03-021-315/+0
| | | | | | driver taking lib/Driver. llvm-svn: 65811
* Introduce code modification hints into the diagnostics system. When weDouglas Gregor2009-02-261-5/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | know how to recover from an error, we can attach a hint to the diagnostic that states how to modify the code, which can be one of: - Insert some new code (a text string) at a particular source location - Remove the code within a given range - Replace the code within a given range with some new code (a text string) Right now, we use these hints to annotate diagnostic information. For example, if one uses the '>>' in a template argument in C++98, as in this code: template<int I> class B { }; B<1000 >> 2> *b1; we'll warn that the behavior will change in C++0x. The fix is to insert parenthese, so we use code insertion annotations to illustrate where the parentheses go: test.cpp:10:10: warning: use of right-shift operator ('>>') in template argument will require parentheses in C++0x B<1000 >> 2> *b1; ^ ( ) Use of these annotations is partially implemented for HTML diagnostics, but it's not (yet) producing valid HTML, which may be related to PR2386, so it has been #if 0'd out. In this future, we could consider hooking this mechanism up to the rewriter to actually try to fix these problems during compilation (or, after a compilation whose only errors have fixes). For now, however, I suggest that we use these code modification hints whenever we can, so that we get better diagnostics now and will have better coverage when we find better ways to use this information. This also fixes PR3410 by placing the complaint about missing tokens just after the previous token (rather than at the location of the next token). llvm-svn: 65570
* map source ranges through macro expansions. Before:Chris Lattner2009-02-201-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float')) MAX(P, F); ^~~~~~~~~ t.m:1:78: note: instantiated from: #define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) ^ (no ranges on the second diagnostics) After: t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float')) MAX(P, F); ^~~~~~~~~ t.m:1:78: note: instantiated from: #define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) ~~~ ^ ~~~ (ranges!) llvm-svn: 65090
* refactor, pass ranges down instead of the whole Chris Lattner2009-02-201-9/+15
| | | | | | DiagnosticInfo. llvm-svn: 65088
* tidy upChris Lattner2009-02-181-3/+1
| | | | llvm-svn: 64934
* As an experimental hack, emit "instantiated from" information inChris Lattner2009-02-171-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostics. I'm not sure I want to keep this, but hey, it's easy and could be useful or something, even if guarded by a -fshow-me-tons-of-details option. A silly example is: #define A B #define C A #define D C int y = D; We now emit: t.c:11:9: error: use of undeclared identifier 'B' int y = D; ^ t.c:9:11: note: instantiated from: #define D C ^ t.c:8:11: note: instantiated from: #define C A ^ t.c:7:11: note: instantiated from: #define A B ^ A more useful example is from tgmath: t.c:4:9: error: no matching function for call to '__tg_acos' return acos(x); ^~~~~~~ /Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:51:17: note: instantiated from: #define acos(x) __tg_acos(x) ^ ... candidate set follows ... This does not yet print ranges in instantiation info, (e.g. highlighting the range "__tg_acos(x)" in the last example), but that could be added if we decide this is a good idea :). Thoughts and bug reports welcome! llvm-svn: 64761
* sink a call to getInstantiationLoc to eliminate an assertion.Chris Lattner2009-02-171-4/+5
| | | | llvm-svn: 64755
* break down EmitCaretDiagnostic to use more primitive calls.Chris Lattner2009-02-171-13/+27
| | | | llvm-svn: 64754
* split caret diagnostic printing out into its own function.Chris Lattner2009-02-171-59/+65
| | | | llvm-svn: 64751
* simplify some code.Chris Lattner2009-02-171-5/+5
| | | | llvm-svn: 64750
* If a source range comes through a function-like macro expansion,Chris Lattner2009-02-171-0/+8
| | | | | | | | | | | | | | | | | | highlight the arguments to the macro as well as the identifier. Before: t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are: return acos(x); ^~~~ after: t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are: return acos(x); ^~~~~~~ llvm-svn: 64743
* handle fatal errors, rely on warnings to point out missing cases.Chris Lattner2009-02-061-1/+2
| | | | llvm-svn: 63913
* lower the interface to getLineNumber like we did forChris Lattner2009-02-041-3/+4
| | | | | | | | getColumnNumber. This fixes a FIXME in SourceManager::getPresumedLoc because we now just decompose the sloc once. llvm-svn: 63701
* make SM::getColumnNumber take a predecomposed FileID/offset, whichChris Lattner2009-02-041-2/+2
| | | | | | | | makes it clear to clients that they have to pick an instantiation or spelling location before calling it and allows optimization based on that. llvm-svn: 63698
* " Attached is a patch for TextDiagnosticPrinter that adds an optionalChris Lattner2009-01-301-4/+6
| | | | | | | | | | parameter that allows users to omit the printing of the source location on a diagnostic. So basically it would omit the "abc.c:5:1: " at the beginning of the line." Patch by Alexei Svitkine! llvm-svn: 63396
* Fix TextDiagnosticPrinter::HandleDiagnostic to handle invalid FullSourceLocs ↵Ted Kremenek2009-01-281-15/+7
| | | | | | that do not have a SourceManager. llvm-svn: 63230
* Introduce a new PresumedLoc class to represent the concept of a locationChris Lattner2009-01-271-54/+64
| | | | | | | | | | | | | | | | | | | as reported to the user and as manipulated by #line. This is what __FILE__, __INCLUDE_LEVEL__, diagnostics and other things should follow (but not dependency generation!). This patch also includes several cleanups along the way: - SourceLocation now has a dump method, and several other places that did similar things now use it. - I cleaned up some code in AnalysisConsumer, but it should probably be simplified further now that NamedDecl is better. - TextDiagnosticPrinter is now simplified and cleaned up a bit. This patch is a prerequisite for #line, but does not actually provide any #line functionality. llvm-svn: 63098
* Rename SourceManager::getCanonicalFileID -> getFileID. There isChris Lattner2009-01-191-2/+2
| | | | | | no longer such thing as a non-canonical FileID. llvm-svn: 62499
* Rename SourceLocation::getFileID to getChunkID, because it returnsChris Lattner2009-01-171-7/+9
| | | | | | | | the chunk ID not the file ID. This exposes problems in TextDiagnosticPrinter where it should have been using the canonical file ID but wasn't. Fix these along the way. llvm-svn: 62427
* eliminate FullSourceLoc::getLocation() now that FullSourceLocChris Lattner2009-01-161-1/+1
| | | | | | *is* the location. This eliminates some weird X.getLocation().getLocation()'s. llvm-svn: 62376
* more SourceLocation lexicon change: instead of referring to theChris Lattner2009-01-161-13/+14
| | | | | | "logical" location, refer to the "instantiation" location. llvm-svn: 62316
* remove a dead enumChris Lattner2008-11-221-1/+0
| | | | llvm-svn: 59879
* switch TextDiagnosticPrinter to raw_ostream.Chris Lattner2008-11-191-6/+9
| | | | llvm-svn: 59597
* rewrite FormatDiagnostic to be less gross and a lot more efficient.Chris Lattner2008-11-191-4/+7
| | | | | | | This also makes it illegal to have bare '%'s in diagnostics. If you want a % in a diagnostic, use %%. llvm-svn: 59596
* This reworks some of the Diagnostic interfaces a bit to change how diagnosticsChris Lattner2008-11-181-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | are formed. In particular, a diagnostic with all its strings and ranges is now packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a ton of random stuff. This has the benefit of simplifying the interface, making it more extensible, and allowing us to do more checking for things like access past the end of the various arrays passed in. In addition to introducing DiagnosticInfo, this also substantially changes how Diagnostic::Report works. Instead of being passed in all of the info required to issue a diagnostic, Report now takes only the required info (a location and ID) and returns a fresh DiagnosticInfo *by value*. The caller is then free to stuff strings and ranges into the DiagnosticInfo with the << operator. When the dtor runs on the DiagnosticInfo object (which should happen at the end of the statement), the diagnostic is actually emitted with all of the accumulated information. This is a somewhat tricky dance, but it means that the accumulated DiagnosticInfo is allowed to keep pointers to other expression temporaries without those pointers getting invalidated. This is just the minimal change to get this stuff working, but this will allow us to eliminate the zillions of variant "Diag" methods scattered throughout (e.g.) sema. For example, instead of calling: Diag(BuiltinLoc, diag::err_overload_no_match, typeNames, SourceRange(BuiltinLoc, RParenLoc)); We will soon be able to just do: Diag(BuiltinLoc, diag::err_overload_no_match) << typeNames << SourceRange(BuiltinLoc, RParenLoc)); This scales better to support arbitrary types being passed in (not just strings) in a type-safe way. Go operator overloading?! llvm-svn: 59502
* Change the diagnostics interface to take an array of pointers to Chris Lattner2008-11-181-1/+1
| | | | | | | | strings instead of array of strings. This reduces string copying in some not-very-important cases, but paves the way for future improvements. llvm-svn: 59494
* More #include cleaningDaniel Dunbar2008-08-111-2/+0
| | | | | | | | | | | - Kill unnecessary #includes in .cpp files. This is an automatic sweep so some things removed are actually used, but happen to be included by a previous header. I tried to get rid of the obvious examples and this was the easiest way to trim the #includes in one fell swoop. - We now return to regularly scheduled development. llvm-svn: 54632
* * Remove isInSystemHeader() from DiagClient, move it to SourceManagerNico Weber2008-08-101-1/+0
| | | | | | | | | | | | | | | | * Move FormatError() from TextDiagnostic up to DiagClient, remove now empty class TextDiagnostic * Make DiagClient optional for Diagnostic This fixes the following problems: * -html-diags (and probably others) does now output the same set of warnings as console clang does * nothing crashes if one forgets to call setHeaderSearch() on TextDiagnostic * some code duplication is removed llvm-svn: 54620
* Expressive diagnostics-- worth their weight in gold?Gordon Henriksen2008-08-091-20/+20
| | | | | | (Fixing a spelling error.) llvm-svn: 54591
* add a libDriver, for now only move the text diangostics stuff from Driver to ↵Nico Weber2008-08-051-0/+203
there llvm-svn: 54383
OpenPOWER on IntegriCloud