summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/TextDiagnosticPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. 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 for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Revert "Revert "[NFC] Refactor DiagnosticRenderer to use FullSourceLoc""Christof Douma2017-06-271-4/+3
| | | | | | | | | | | | | | | | | | | | | | This reverts commit r305688 meaning it reintroduces r305684. To repeat: [NFC] Refactor DiagnosticRenderer to use FullSourceLoc Move the DiagnosticRenderer and its dependents to using FullSourceLocs instead of a SourceLocation and SourceManager pointer. The changeset is rather large but entirely mechanical. This is step one to allow DiagnosticRenderer to take either llvm::SMLocs or clang::SourceLocations. This breaks clang-tidy and clng-query which will be fixed in a commit soon after. Patch by Sanne Wouda Differential Revision: https://reviews.llvm.org/D31709 llvm-svn: 306384
* Revert "[NFC] Refactor DiagnosticRenderer to use FullSourceLoc"Christof Douma2017-06-191-3/+4
| | | | | | | This reverts commit 305684. This patch breaks extra/tools/clang-tidy llvm-svn: 305688
* [NFC] Refactor DiagnosticRenderer to use FullSourceLocChristof Douma2017-06-191-4/+3
| | | | | | | | | | | | | | | | Move the DiagnosticRenderer and its dependents to using FullSourceLocs instead of a SourceLocation and SourceManager pointer. The changeset is rather large but entirely mechanical. This is step one to allow DiagnosticRenderer to take either llvm::SMLocs or clang::SourceLocations. Patch by Sanne Wouda Review: https://reviews.llvm.org/D31709 Change-Id: If351a112cdf6718e2d3ef6721b8da9c6376b32dd llvm-svn: 305684
* [NFC] Header cleanupMehdi Amini2016-07-181-2/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ↵David Blaikie2014-07-191-1/+1
| | | | | | | | | | | ".reset()" It's also possible to just write "= nullptr", but there's some question of whether that's as readable, so I leave it up to authors to pick which they prefer for now. If we want to discuss standardizing on one or the other, we can do that at some point in the future. llvm-svn: 213439
* Simplify warning flag value handling from r206826Alp Toker2014-07-091-1/+1
| | | | | | Also give the field it a more appropriate name and improve the docs. llvm-svn: 212584
* TextDiagnosticPrinter: use the mapped level for remark flag computationAlp Toker2014-06-221-1/+1
| | | | | | | | | Custom diagnostics don't have a builtin class so this wouldn't have worked. Reduces surface area of remark-related changes. No test coverage. llvm-svn: 211462
* Remove limits on the number of fix-it hints and ranges in the DiagnosticsEngine.Alexander Kornienko2014-05-221-2/+1
| | | | | | | | | | | | | | | | | | | Summary: The limits on the number of fix-it hints and ranges attached to a diagnostic are arbitrary and don't apply universally to all users of the DiagnosticsEngine. The way the limits are enforced may lead to diagnostics generating invalid sets of fixes. I suggest removing the limits, which will also simplify the implementation. Reviewers: rsmith Reviewed By: rsmith Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D3879 llvm-svn: 209468
* [C++11] Use 'nullptr'. Frontend edition.Craig Topper2014-05-221-1/+1
| | | | llvm-svn: 209389
* Allow adding a value to a flag in diagnostics.Diego Novillo2014-04-211-0/+3
| | | | | | | | | | | | | | | | | Summary: This allows callers of Diags.Report() to append a value to the name of the flag associated with the diagnostic. This is useful in cases like the -Rpass flag, where we want the diagnostic to show the name of the pass that matched the pattern. Instead of showing "... [-Rpass]", this allows us to show "... [-Rpass=passname]". Reviewers: rsmith CC: cfe-commits Differential Revision: http://reviews.llvm.org/D3441 llvm-svn: 206826
* Add support for optimization reports.Diego Novillo2014-04-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds a new flag -Rpass=. The flag indicates the name of the optimization pass that should emit remarks stating when it made a transformation to the code. This implements the design I proposed in: https://docs.google.com/document/d/1FYUatSjZZO-zmFBxjOiuOzAy9mhHA8hqdvklZv68WuQ/edit?usp=sharing Other changes: - Add DiagnosticIDs::isRemark(). Use it in printDiagnosticOptions to print "-R" instead of "-W" in the diagnostic message. - In BackendConsumer::OptimizationRemarkHandler, get a SourceLocation object out of the file name, line and column number. Use that location in the call to Diags.Report(). - When -Rpass is used without debug info a note is emitted alerting the user that they need to use -gline-tables-only -gcolumn-info to get this information. CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3226 llvm-svn: 206401
* clang-cl: print diagnostics as "error(clang): foo" in /fallback modeHans Wennborg2013-09-241-1/+2
| | | | | | | | | | | | | | | This solves two problems: 1) MSBuild will not flag the build as unsuccessful just because we print an error in the output, since "error(clang):" doesn't seem to match the regex it's using. 2) It becomes more clear that the diagnostic is coming from clang as supposed to cl.exe. Differential Revision: http://llvm-reviews.chandlerc.com/D1735 llvm-svn: 191250
* Remove DiagnosticConsumer::clone(), a bad idea that is now unused.Douglas Gregor2013-05-031-5/+0
| | | | llvm-svn: 181070
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-2/+2
| | | | | | | | | | | | | 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. llvm-svn: 169237
* Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor2012-10-231-5/+5
| | | | | | | the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. llvm-svn: 166508
* Fix a typo (the the => the)Sylvestre Ledru2012-07-231-1/+1
| | | | llvm-svn: 160622
* Re-apply r159875 with fixes.Ted Kremenek2012-07-071-10/+0
| | | | | | | - Split pedantic driver flag test into separate test file, and XFAIL on cygwin,mingw32 - Fix bug in tablegen logic where a missing '{' caused errors to be included in -Wpedantic. llvm-svn: 159892
* Revert rr159875, "Implement -Wpedantic and --no-pedantic to complement ↵NAKAMURA Takumi2012-07-071-0/+10
| | | | | | | | | | -Weverything." It broke several builds. I suspect FileCheck might match assertion failure, even if clang/test/Misc/warning-flags.c passed the test. > 0. Program arguments: bin/./clang -### -pedantic -Wpedantic clang/test/Driver/warning-options.cpp llvm-svn: 159886
* Implement -Wpedantic and --no-pedantic to complement -Weverything.Ted Kremenek2012-07-061-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces some magic in tablegen to create a "Pedantic" diagnostic group which automagically includes all warnings that are extensions. This allows a user to suppress specific warnings traditionally under -pedantic used an ordinary warning flag. This also allows users to use #pragma to silence specific -pedantic warnings, or promote them to errors, within blocks of text (just like any other warning). -Wpedantic is NOT an alias for -pedantic. Instead, it provides another way to (a) activate -pedantic warnings and (b) disable them. Where they differ is that -pedantic changes the behavior of the preprocessor slightly, whereas -Wpedantic does not (it just turns on the warnings). The magic in the tablegen diagnostic emitter has to do with computing the minimal set of diagnostic groups and diagnostics that should go into -Wpedantic, as those diagnostics that already members of groups that themselves are (transitively) members of -Wpedantic do not need to be included in the Pedantic group directly. I went back and forth on whether or not to magically generate this group, and the invariant was that we always wanted extension warnings to be included in -Wpedantic "some how", but the bookkeeping would be very onerous to manage by hand. -no-pedantic (and --no-pedantic) is included for completeness, and matches many of the same kind of flags the compiler already supports. It does what it says: cancels out -pedantic. One discrepancy is that if one specifies --no-pedantic and -Weverything or -Wpedantic the pedantic warnings are still enabled (essentially the -W flags win). We can debate the correct behavior here. Along the way, this patch nukes some code in TextDiagnosticPrinter.cpp and CXStoredDiagnostic.cpp that determine whether to include the "-pedantic" flag in the warning output. This is no longer needed, as all extensions now have a -W flag. This patch also significantly reduces the number of warnings not under flags from 229 to 158 (all extension warnings). That's a 31% reduction. llvm-svn: 159875
* Fix an assertion hit when the serialized diagnostics writer receive a diagnosticArgyrios Kyrtzidis2012-05-101-12/+6
| | | | | | | | | | | | | | 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 llvm-svn: 156536
* 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
OpenPOWER on IntegriCloud