summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/TextDiagnosticPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove the unuseful -fdiagnostics-show-nameDavid Blaikie2012-02-151-12/+0
| | | | | | | | | | | | | | This option was added in r129614 and doesn't have any use case that I'm aware of. It's possible that external tools are using these names - and if that's the case we can certainly reassess the functionality, but for now it lets us shave out a few unneeded bits from clang. Move the "StaticDiagNameIndex" table into the only remaining consumer, diagtool. This removes the actual diagnostic name strings from clang entirely. Reviewed by Chris Lattner & Ted Kremenek. llvm-svn: 150612
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Persist the TextDiagnostic object across multiple diagnostics as long asChandler Carruth2011-10-161-18/+23
| | | | | | | | | the SourceManager doesn't change, and the source files don't change. This greatly simplifies the interfaces and interactions. The lifetime of the TextDiagnostic object forms the 'session' over which we attempt to condense and deduplicate information in diagnostics. llvm-svn: 142104
* Clean up the names of all the TextDiagnostic methods (and even a staticChandler Carruth2011-10-151-4/+4
| | | | | | | function) to agree with the coding conventions, and in one case have a bit more information in it. llvm-svn: 142088
* Graduate the TextDiagnostic interface to its own header and source file,Chandler Carruth2011-10-151-1155/+1
| | | | | | | | | | making it accessible to anyone from the Frontend library. Still a good bit of cleanup to do here, but its a good milestone. This ensures that *all* of the functionality needed to implement the DiagnosticConsumer is exposed via the generic interface in some form. No sneaky re-use of static functions. llvm-svn: 142086
* Move the message printing to a class-static function so that it can beChandler Carruth2011-10-151-28/+45
| | | | | | part of the TextDiagnostic interface without requiring a full instance. llvm-svn: 142085
* Move the diagnostic level printing into a class static helper. This willChandler Carruth2011-10-151-31/+38
| | | | | | | allow the TextDiagnosticPrinter to continue using it even if TextDiagnostic is implemented in a separate file. llvm-svn: 142084
* Rationalize the last bit of "arbitrary" state that is carried betweenChandler Carruth2011-10-151-9/+23
| | | | | | | | | | | | | diagnostics to control suppression of redundant information. It now follows the same model as all the other state, and has a bit more clear semantics. This is making the duality of the state a bit annoying, and I've added a FIXME to resolve it. The problem is that I need to lift the TextDiagnostic up into an externally visible layer before that can happen. llvm-svn: 142083
* Neither 'Warning' nor 'NonNote' was a good name for this location...Chandler Carruth2011-10-151-13/+14
| | | | | | | It's the last include-stack-root we tried to walk up. Use a better name and better doxyments for it. llvm-svn: 142071
* Nuke a bunch of FIXMEs that are now fixed. =] Also, remove the now-deadChandler Carruth2011-10-151-8/+3
| | | | | | | | | TextDiagnosticPrinter argument to the TextDiagnostic helper class. This cements the proper ordering of things: TextDiagnostic is now a viable stand-alone class for emitting pretty-printed textual diagnostics to a terminal. llvm-svn: 142070
* Sink the include stack printing into the generic text diagnosticChandler Carruth2011-10-151-52/+50
| | | | | | | | | | | | | | | utility. This is a particularly nice win because it removes a pile of parameters from these routines. Also name them a bit better. I'm trying to follow the pattern of 'emit' routines writing directly to what is expected to be the final output, while 'print' routines take a output stream argument and can be used to build up intermediate buffers, etc. Also, fix a bug I spotted by inspection from my last commit where 'LastLoc' and 'LastNonNoteLoc' were reversed. It's really scary that this didn't trigger a single test failure. Will be working on tests for more of this functionality now. llvm-svn: 142069
* Rationalize some of how the locations of prior diagnostics are trackedChandler Carruth2011-10-151-12/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | across emissions. 1) The include stack printing is conditioned on non-note diagnostics, not just on warning diagnostics. 2) Those should be full source locations as they're tied to a source manager. 3) We should pass in the prior state to the TextDiagnostic constructor, allow it to mutate as diagnostics are emitted, and then cache the final state before tearing it down. Some of this remains incomplete, specifically #3 isn't finished for the non-note location. That'll come when the include stack printing sinks down a level. This also highlights how *completely* bug-ridden this code is. For example, we currently do all these comparisons of a FullSourceLoc and a SourceLocation... which silently does a SourceLocation to SourceLocation comparison, completely disregarding the source manager from whence one of the arguments came. Oops! Good thing in practice this wasn't important, but it could in theory be suppressing caret diagnostics in a second TU on a single clang invocation. I'm hoping to hammer these bugs out as the refactorings occur, although for so many of them it's really unlikely I can dream up a test case that would show the potentially buggy behavior. llvm-svn: 142067
* Sink the EmitDiagnosticLoc method down to the generic TextDiagnosticChandler Carruth2011-10-151-110/+108
| | | | | | interface now that its only caller is there. llvm-svn: 142065
* Sink the non-caret diagnostic logic down and out of the diagnosticChandler Carruth2011-10-151-270/+276
| | | | | | | | | | | | | consumer. The TextDiagnostic interface now has a generic entry point for emitting a diagnostic which uses a minimal interface that should be compatible with StoredDiagnostics such as are available in libclang etc. Some unfortunate shuffling of static functions as things get relocated. Also some unfortunate public interface points added to TextDiagnosticPrinter, but those are the next bits to get moved so they won't last long. llvm-svn: 142064
* Simplify the interface of a helper method in the TextDiagnosticPrinterChandler Carruth2011-10-151-17/+18
| | | | | | | | | | | to operate directly on the source location and ranges associated with a diagnostic rather than digging them out of the diagnostic. This had a side benefit of cleaning up its code a tiny bit by using the ArrayRef interface. No functionality changed. llvm-svn: 142063
* Change 'Emit' to 'EmitCaret' which sums up what it *should* be doing.Chandler Carruth2011-10-151-6/+9
| | | | | | | | Also note that it is actually doing much more than it should. This paves the way for building a more generic 'Emit' routine that is the real entry point here. llvm-svn: 142035
* Basic/Diagnostics: Add an isDefaultMappingAsError method, and switch ↵Daniel Dunbar2011-09-291-9/+13
| | | | | | | | TextDiagnosticPrinter to use that instead of extracting the current mapping via getDiagnosticLevel, which fixes one class of corner cases w.r.t. printing the "-Werror" diagnostic option marker. - The TextDiagnosticPrinter code is still fragile as it is just "reverse engineering" what the diagnostic engine is doing. Not my current priority to fix though. llvm-svn: 140752
* Introduce a pure virtual clone() method to DiagnosticConsumer, so thatDouglas Gregor2011-09-291-0/+5
| | | | | | | | | we have the ability to create a new, distict diagnostic consumer when we go off and build a module. This avoids the currently horribleness where the same diagnostic consumer sees diagnostics for multiple translation units (and multiple SourceManagers!) causing all sorts of havok. llvm-svn: 140743
* Add back support for a manually formatted section of the diagnosticChandler Carruth2011-09-261-1/+4
| | | | | | | | | | | message. Specifically, we now only line-wrap the first line of te diagnostic message and assume the remainder is manually formatted. While adding it back, simplify the logic for doing this. Finally, add a test that ensures we actually preserve this feature. =D *Now* its not dead code. Thanks to Doug for the test case. llvm-svn: 140538
* Hoist and beef up the asserts about the level of infrastructure expectedChandler Carruth2011-09-261-5/+10
| | | | | | | | | | | | | | | | | when working with a diagnostic attached to a source location. Also comment more thoroughly why its important to handle non-location diagnostic messages separately. Finally, hoist the creation of the TextDiagnostic object up to the beginning of the location-based diagnostics. This paves the way for sinking more and more of the logic into this class. When everything below this constructor is sunk into the TextDiagnostic class it should be sufficiently "feature complete" to accomplish my two goals: 1) Have the printing of a macro expansion note use the exact same code as any other note. 2) Be able to implement clang_formatDiagnostic in terms of this class. llvm-svn: 140526
* Switch the emission of diagnostics without a source location toChandler Carruth2011-09-261-22/+32
| | | | | | | | | | | | | | | | | | | | | a dedicated path. The logic for such diagnostics is much simpler than for others. This begins to make an important separation in this routine. We expect most (and most interesting) textual diagnostics to be made in the presence of at least *some* source locations and a source manager. However the DiagnosticConsumer must be prepared to diagnose errors even when the source manager doesn't (yet) exist or when there is no location information at all. In order to sink more and more logic into the TextDiagnostic class while minimizing its complexity, my plan is to force the DiagnosticConsumer to special case diagnosing any locationless messages and then hand the rest to the TextDiagnostic class. I'd appreciate any comments on this design. It requires a bit of code duplication in order to keep interfaces simple. Alternatively, if we really need TextDiagnostic to be capable of handling diagnostics even in the absence of a viable SourceManager, then this split isn't necessary. llvm-svn: 140525
* Extract the actual printing of the message string into a helperChandler Carruth2011-09-261-32/+33
| | | | | | | | | function. Doing this conveniently requires moving the word wrapping to use a StringRef which seems generally an improvement. There is a lot that could be simplified in the word wrapping by using StringRef that I haven't looked at yet... llvm-svn: 140524
* Group the helpers for word wrapping with the primary routine. NoChandler Carruth2011-09-261-92/+92
| | | | | | functionality changed. llvm-svn: 140523
* Don't print a stray ] at the end of diagnostics.Benjamin Kramer2011-09-261-3/+4
| | | | | | Also remove an obsolete utostr call. llvm-svn: 140511
* Remove support for splitting word-wrapped diagnostic messages on newlineChandler Carruth2011-09-261-18/+2
| | | | | | | | | | | | characters. I could find no newline character in a diagnostic message, and adding an assert to this code never fires in the testsuite. I think this code is essentially dead, and was previously used for a different purpose. If I just don't understand how it is we can end up with a newline here please let me know (with a test case?) and I'll revert. llvm-svn: 140497
* Move the word wrapped printing routine down to all the other helperChandler Carruth2011-09-261-82/+77
| | | | | | | printing routines, clean up its doxyments and switch it to a camelCase name as well. No functionality changed here. llvm-svn: 140496
* Switch some of my recently added helper functions to use the properChandler Carruth2011-09-261-6/+19
| | | | | | style, and add doxyments. llvm-svn: 140495
* Rewrite the printing of diagnostic options, categories, etc to actuallyChandler Carruth2011-09-261-35/+29
| | | | | | use the ostream interface and avoid lots of temporary strings. llvm-svn: 140494
* Rename DiagnosticInfo to Diagnostic as per issue 5397David Blaikie2011-09-261-4/+4
| | | | llvm-svn: 140493
* Delete an extraneous line I missed.Chandler Carruth2011-09-261-1/+0
| | | | llvm-svn: 140491
* A direct extraction of the rest of the option printing into a helper.Chandler Carruth2011-09-261-51/+57
| | | | | | This needs to be cleaned up to better use the ostream object, WIP. llvm-svn: 140490
* Start a more correct pattern for factoring out the name printing. SlowlyChandler Carruth2011-09-261-7/+10
| | | | | | | I'm planning to switch a bunch of these over to use a raw_ostream instead of += on a string object. llvm-svn: 140488
* Revert r140484. That was *not* ready to be committed! Only halfway done,Chandler Carruth2011-09-261-39/+34
| | | | | | | | and completely broken at that. Sorry, must remember to stash rather than commit. =] llvm-svn: 140487
* Fix a formatting goof.Chandler Carruth2011-09-261-1/+1
| | | | llvm-svn: 140486
* Extract the diagnostic message formatting into a helper routine.Chandler Carruth2011-09-261-34/+39
| | | | llvm-svn: 140484
* Extract the logic for printing a colorful level name into a helperChandler Carruth2011-09-251-21/+28
| | | | | | function. llvm-svn: 140481
* Rename DiagnosticClient to DiagnosticConsumer as per issue 5397David Blaikie2011-09-251-1/+1
| | | | llvm-svn: 140479
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-21/+22
| | | | llvm-svn: 140478
* Inline this method now that its completely trivial, and prepare forChandler Carruth2011-09-251-18/+9
| | | | | | hoisting parts of the text diagnostic. llvm-svn: 140477
* Shuffle some names around. 'CaretDiagnostic' is inaccurate as this needsChandler Carruth2011-09-251-18/+21
| | | | | | | to handle non-caret diagnostics as well in order to be fully useful in libclang etc. Also sketch out some more of my plans on this refactoring. llvm-svn: 140476
* Actually remove the members of CaretDiagnostic no longer in use forChandler Carruth2011-09-251-10/+6
| | | | | | | | tracking the start and stop of macro expansion suppression. Also remove the Columns variable which was just a convenience variable based on DiagOpts. Instead we materialize it in the one piece of code that cared. llvm-svn: 140475
* Sink the logic for suppressing some macro expansion notes from theChandler Carruth2011-09-251-41/+29
| | | | | | | | | | | | | | | | TextDiagnosticPrinter into the CaretDiagnostic class. Several interesting results from this: - This removes a significant per-diagnostic bit of state from the CaretDiagnostic class, which should eventually allow us to re-use the object. - It removes a redundant recursive walk of the macro expansion stack just to compute the depth. We don't need the depth until we're unwinding anyways, so we can just mark when we reach it. - It also paves the way for several simplifications we can do to how we implement the suppression. llvm-svn: 140474
* Split the recursive macro expansion walk out from the routine whichChandler Carruth2011-09-251-58/+71
| | | | | | emits a source snippet and caret line. llvm-svn: 140467
* More missing header inclusions from llvm_unreachable migration.David Blaikie2011-09-231-0/+1
| | | | llvm-svn: 140369
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-2/+2
| | | | llvm-svn: 140367
* Extract the emission of the diagnostic's location into a separateChandler Carruth2011-09-071-103/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | function. This is really the beginning of the second phase of refactorings here. The end goal is to have (roughly) three interfaces: 1) Base class to format a single diagnostic suitable for display on the console. 2) Extension of the base class which also displays a caret diagnostic suitable for display on the console. 3) An adaptor that implements the DiagnosticClient by delegating to #1 and/or #2 as appropriate. Once we have these, things like libclang's formatDiagnostic can use #1 and #2 to provide really well formatted (and consistently formatted!) textual formatting of diagnostics. Getting there is going to be quite a bit of shuffling. I'm basically sketching out where the interface boundaries can be drawn for #1 and #2 within the existing classes. That lets me shuffle with a minimum of fuss and delta. Once that's done, and any of the related interfaces that need to change are updated, I'll hoist these into separate headers and re-implement libclang in terms of their interfaces. Long WIP, but comments at each step welcome. =D llvm-svn: 139228
* Move the HilightRange method from TextDiagnosticPrinter down toChandler Carruth2011-09-071-81/+79
| | | | | | | CaretDiagnostic. It's completely generic, with nothing to do with the diagnostic client or info APIs. llvm-svn: 139227
* Hoist the tab expansion into a helper function.Chandler Carruth2011-09-071-21/+25
| | | | llvm-svn: 139226
* Don't compute the same line number in two places, once inside a loop.Chandler Carruth2011-09-071-12/+8
| | | | llvm-svn: 139225
* Switch the CharSourceRange array to a small vector. The array wasChandler Carruth2011-09-071-39/+34
| | | | | | | | | | | | a stack array of a magical size with an assert() that we never overflowed it. That seems incredibly risky. We also have a very nice API for bundling up a vector we expect to usually have a small size without loss of functionality or security if the size is excessive. The fallout is to remove the last pointer+size parameter pair that are traced through the recursive caret diagnostic emission. llvm-svn: 139217
OpenPOWER on IntegriCloud