summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/TextDiagnostic.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Frontend: Fix SourceColumnMap assertion failure on non-ascii characters.Logan Chien2015-01-081-9/+11
| | | | | | | | | | | | | | | | | | | | If there are some non-ascii character in the input source code, the column index might be smallar than the byte index. This will result in two possible assertion failures. This CL fixes the computation of the column index and byte index. 1. The assertion in startOfNextColumn() and startOfPreviousColumn() should not be raised when the byte index is greater than the column index since the non-ascii characters may use more than one bytes to store a character in a column. 2. The length of the caret line should be equal to the number of columns of source line, instead of the length of the source line. Otherwise, the assertion in selectInterestingSourceRegion will be raised because the removed columns plus the kept columns are not greater than the max column, which means that we should not remove any column at all. llvm-svn: 225442
* Frontend: Fix typo in comments.Logan Chien2014-12-201-2/+2
| | | | llvm-svn: 224680
* Driver: bifurcate extended and basic MSC versioningSaleem Abdulrasool2014-07-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | This restores the original behaviour of -fmsc-version. The older option remains as a mechanism for specifying the basic version information. A secondary option, -fms-compatibility-version permits the user to specify an extended version to the driver. The new version takes the value as a dot-separated value rather than the major * 100 + minor format that -fmsc-version format. This makes it easier to specify the value as well as a more flexible manner for specifying the value. Specifying both values is considered an error. The older parameter is left solely as a driver option, which is normalised into the newer parameter. This allows us to retain a single code path in the compiler itself whilst preserving the semantics of the old parameter as well as avoid having to determine which of two formats are being used by the invocation. The test changes are due to the fact that the compiler no longer supports the old option, and is a direct conversion to the new option. llvm-svn: 213119
* Track IntrusiveRefCntPtr::get() changes from LLVM r212366Alp Toker2014-07-051-1/+1
| | | | llvm-svn: 212369
* DiagnosticRenderer: emit basic notes as real diagnosticsAlp Toker2014-06-211-6/+0
| | | | | | | Fixes terminal column wrapping and vestigial 'note:' prefixes that would appear when using emitBasicNote(). llvm-svn: 211448
* TextDiagnostic: print remark level diagnostics in bold tooAlp Toker2014-06-211-19/+14
| | | | | | | | | | | The purpose of bolding these is to make them visually distinct from continuations (supplemental note diagnostics). Therefore, the bolding applies to all severities _including_ remarks -- it's not in any way an indicator of priority. Also simplify and comment. No tests. llvm-svn: 211447
* Driver: enhance MSC version compatibilitySaleem Abdulrasool2014-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The version information for Visual Studio is spread over multiple variables. The newer Windows SDK has started making use of some of the extended versioning variables that were previously undefined. Enhance our compatibility definitions for these cases. _MSC_VER is defined to be the Major * 100 + Minor. _MSC_FULL_VER is defined to be Major * 10000000 + Minor * 100000 + Build. And _MSC_BUILD is the build revision of the compiler. Extend the -fmsc-version option in a compatible manner. If the value is the previous form of MMmm, then we assume that the build number is 0. Otherwise, a specific build number may be passed by using the form MMmmbbbbb. Due to bitwidth limitations of the option, it is currently not possible to define a revision value. The version information can be passed as either the decimal encoded value (_MSC_FULL_VER or _MSC_VER) or as a dot-delimited value. The change to the TextDiagnostic is to deal with the updated encoding of the version information. llvm-svn: 211420
* The Visual Studio IDE changed behavior in VS2012. It used to be the case thatYunzhong Gao2014-03-071-1/+3
| | | | | | | | | | | | | | | | the clang diagnostic has to report a column number one less than the correct value in order for the IDE to move the cursor to the expected location. This behavior is changed in VS2012 and VS2013 so that the IDE is now expecting the column number to match the actual source location. Before: source(line, column-1): type: message After: source(line, column): type: message This patch changes -fdiagnostics-format=msvc to match the new VS2012 and VS2013 when fmsc-version is 1700 or greater. Differential Revision: http://llvm-reviews.chandlerc.com/D2949 llvm-svn: 203183
* [C++11] Replace verbose functors with succinct lambdasBenjamin Kramer2014-03-011-9/+1
| | | | | | No functionality change. llvm-svn: 202590
* Add 'remark' diagnostic type in 'clang'Tobias Grosser2014-02-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | A 'remark' is information that is not an error or a warning, but rather some additional information provided to the user. In contrast to a 'note' a 'remark' is an independent diagnostic, whereas a 'note' always depends on another diagnostic. A typical use case for remark nodes is information provided to the user, e.g. information provided by the vectorizer about loops that have been vectorized. This patch provides the initial implementation of 'remarks'. It includes the actual definiton of the remark nodes, their printing as well as basic parameter handling. We are reusing the existing diagnostic parameters which means a remark can be enabled with normal '-Wdiagnostic-name' flags and can be upgraded to an error using '-Werror=diagnostic-name'. '-Werror' alone does not upgrade remarks. This patch is by intention minimal in terms of parameter handling. More experience and more discussions will most likely lead to further enhancements in the parameter handling. llvm-svn: 202475
* Split FileEntry name vs. isValidBen Langmuir2014-02-271-1/+1
| | | | | | | This is a small bit of refactoring in preparation for FileEntry owning the storage for its own name. llvm-svn: 202412
* clang-cl: print diagnostics as "error(clang): foo" in /fallback modeHans Wennborg2013-09-241-6/+17
| | | | | | | | | | | | | | | 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
* Use llvm::sys::fs::UniqueID for windows and unix.Rafael Espindola2013-08-011-4/+1
| | | | | | | | | | | | | | | | | | | This unifies the unix and windows versions of FileManager::UniqueDirContainer and FileManager::UniqueFileContainer by using UniqueID. We cannot just replace "struct stat" with llvm::sys::fs::file_status, since we want to be able to construct fake ones, and file_status has different members on unix and windows. What the patch does is: * Record only the information that clang is actually using. * Use llvm::sys::fs::status instead of stat and fstat. * Use llvm::sys::fs::UniqueID * Delete the old windows versions of UniqueDirContainer and UniqueFileContainer since the "unix" one now works on windows too. llvm-svn: 187619
* Handle Unicode characters in fix-it replacement strings.Jordan Rose2013-06-071-19/+17
| | | | | | Patch by Sukolsak Sakshuwong! llvm-svn: 183535
* Make compares unsigned. The expression can't become negative anyways.Benjamin Kramer2013-04-231-2/+2
| | | | | | Silences a sign compare warning on 32 bit archs. llvm-svn: 180110
* Fix buffer underrun (invalid read) triggered during diagnostic rendering. ↵Ted Kremenek2013-03-151-1/+1
| | | | | | | | | | | | | The test would overflow when computing '0 - 1'. I don't have a good testcase for this that does not depend on system headers. It did not trigger with preprocessed output, and I had trouble reducing the example. Fixes <rdar://problem/13324594>. Thanks to Michael Greiner for reporting this issue. llvm-svn: 177201
* Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose2013-02-081-15/+12
| | | | | | | Nearly all of these changes are one-to-one replacements; the few that aren't have to do with custom identifier validation. llvm-svn: 174768
* TextDiagnostic.cpp: Suppress a warning to use ptrdiff_t on i686-clang. ↵NAKAMURA Takumi2013-02-051-1/+1
| | | | | | [-Wsign-compare] llvm-svn: 174353
* Diagnostics: Clarify name of line-length-limiting constant in r173976.Jordan Rose2013-01-301-3/+3
| | | | | | Thanks, Sean. llvm-svn: 173981
* Diagnostics: if a line is longer than 4096 characters, don't print it.Jordan Rose2013-01-301-1/+9
| | | | | | | | | | | | | 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> llvm-svn: 173976
* Move UTF conversion routines from clang/lib/Basic to llvm/lib/SupportDmitri Gribenko2013-01-301-1/+1
| | | | | | This is required to use them in TableGen. llvm-svn: 173924
* Be defensive when printing module import locations; the diagnostic printer ↵Douglas Gregor2012-12-181-1/+1
| | | | | | needs to be robust llvm-svn: 170466
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-6/+6
| | | | | | | | | | | | | 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 helper classes anonymous. Make helper functions static instead of ↵Benjamin Kramer2012-12-011-155/+156
| | | | | | | | private members so the anonymous class doesn't leak out. No functionality change. llvm-svn: 169099
* When we're emitting a diagnostic with a source location in an importedDouglas Gregor2012-11-301-0/+10
| | | | | | | | | | | | | | 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> llvm-svn: 169042
* When an error occurs while building a module on demand, provide "WhileDouglas Gregor2012-11-301-0/+11
| | | | | | | | | 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>. llvm-svn: 169021
* only truncate source lines in text diagnostics whenSeth Cantrell2012-11-031-2/+2
| | | | | | the ellipsis is shorter than the text it replaces llvm-svn: 167364
* don't step into the middle of multibyte sequencesSeth Cantrell2012-11-031-2/+2
| | | | llvm-svn: 167361
* fix bug in SourceColumnMap::startOfPreviousColumnSeth Cantrell2012-11-031-1/+1
| | | | llvm-svn: 167360
* Add a proper algorithm to compute accurate source ranges for diagnostics withEli Friedman2012-11-031-10/+2
| | | | | | | | | caret locations and source ranges in macros. Makes ranges more accurate in some cases, and fixes an assertion failure. Fixes <rdar://problem/12472249>. llvm-svn: 167353
* remove duplicate data arraySeth Cantrell2012-10-301-14/+1
| | | | llvm-svn: 167007
* fix calculation of end pointerSeth Cantrell2012-10-301-1/+1
| | | | llvm-svn: 167006
* Use a .def file for most of the diagnostic options.Douglas Gregor2012-10-231-3/+3
| | | | llvm-svn: 166520
* Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor2012-10-231-30/+30
| | | | | | | the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. llvm-svn: 166508
* Emit diagnostics in chunks even when we're trying to print colored template ↵Benjamin Kramer2012-10-181-12/+15
| | | | | | | | diffs. char-by-char is really slow on an unbuffered stream. llvm-svn: 166218
* Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. ↵Sylvestre Ledru2012-09-271-1/+1
| | | | | | See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164766 llvm-svn: 164769
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-271-1/+1
| | | | llvm-svn: 164766
* Make TextDiagnostic more robust against SourceLocations which point into theRichard Smith2012-09-131-25/+54
| | | | | | | 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. llvm-svn: 163820
* Add missing cctype includes.Joerg Sonnenberger2012-08-101-0/+1
| | | | llvm-svn: 161660
* Remove unused variables.Benjamin Kramer2012-08-081-7/+0
| | | | llvm-svn: 161483
* Fix a typo (the the => the)Sylvestre Ledru2012-07-231-1/+1
| | | | llvm-svn: 160622
* Re-apply r160319 "Don't crash when emitting fixits following Unicode chars"Jordan Rose2012-07-201-29/+29
| | | | | | | | | 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>) llvm-svn: 160561
* Revert r160319, it caused PR13417. Add a test for PR13417.Nico Weber2012-07-201-26/+27
| | | | llvm-svn: 160542
* Don't crash when emitting fixits following Unicode characters.Jordan Rose2012-07-161-27/+26
| | | | | | | | | | | | | | | 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> llvm-svn: 160319
* PR13312: Don't crash when printing a fixit that ends in a unicode character.Benjamin Kramer2012-07-121-1/+6
| | | | llvm-svn: 160112
* When applying a template diff highlighting to a diagnostic message, rememberRichard Trieu2012-06-281-10/+19
| | | | | | to reapply the bold formatting when needed. llvm-svn: 159386
* Fix template type diffing coloring (r159216) when forcing color output to a ↵David Blaikie2012-06-281-2/+5
| | | | | | | | file (not a terminal) Reviewed (over the shoulder) by Richard Trieu. llvm-svn: 159381
* Add template type diffing to Clang. This feature will provide a betterRichard Trieu2012-06-261-3/+25
| | | | | | | | | | | | 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. llvm-svn: 159216
* Documentation cleanup: escape \ characters in Doxygen comments as needed.James Dennett2012-06-221-2/+2
| | | | llvm-svn: 158968
* If fixits appear to overlap, move the second one over in the output.Jordan Rose2012-06-081-6/+14
| | | | | | | | 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. llvm-svn: 158229
OpenPOWER on IntegriCloud