aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/TextDiagnostic.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-06-27Revert "Revert "[NFC] Refactor DiagnosticRenderer to use FullSourceLoc""Christof Douma1-48/+37
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
2017-06-19Revert "[NFC] Refactor DiagnosticRenderer to use FullSourceLoc"Christof Douma1-37/+48
This reverts commit 305684. This patch breaks extra/tools/clang-tidy llvm-svn: 305688
2017-06-19[NFC] Refactor DiagnosticRenderer to use FullSourceLocChristof Douma1-48/+37
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
2017-05-26Make helper functions static. NFC.Benjamin Kramer1-3/+3
llvm-svn: 304028
2017-05-23[Frontend] Don't index into an empty string.Benjamin Kramer1-1/+1
Found by msan! llvm-svn: 303686
2017-05-22Add option to include multiple lines in snippets.Richard Smith1-86/+156
When a diagnostic includes a highlighted range spanning multiple lines, clang now supports printing out multiple lines of context if necessary to show the highlighted ranges. This is not yet exposed in the driver, but can be enabled by "-Xclang -fcaret-diagnostics-max-lines -Xclang N". This is experimental until we can find out whether it works well in practice, and if so, what a good default for the maximum number of lines is. llvm-svn: 303589
2016-09-30Move UTF functions into namespace llvm.Justin Lebar1-7/+8
Summary: This lets people link against LLVM and their own version of the UTF library. I determined this only affects llvm, clang, lld, and lldb by running $ git grep -wl 'UTF[0-9]\+\|\bConvertUTF\bisLegalUTF\|getNumBytesFor' | cut -f 1 -d '/' | sort | uniq clang lld lldb llvm Tested with ninja lldb ninja check-clang check-llvm check-lld (ninja check-lldb doesn't complete for me with or without this patch.) Reviewers: rnk Subscribers: klimek, beanz, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D24996 llvm-svn: 282822
2016-08-26Add support for -fdiagnostics-absolute-paths: printing absolute paths in ↵Hans Wennborg1-2/+19
diagnostics Differential Revision: https://reviews.llvm.org/D23816 llvm-svn: 279827
2016-07-18[NFC] Header cleanupMehdi Amini1-1/+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
2016-04-28Fix use of uninitialized value exposed by r267802. Accessors of an invalidRichard Smith1-3/+3
PresumedLoc should not be called. llvm-svn: 267914
2016-03-23clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.Nico Weber1-1/+9
Remove tests that have neither a triple nor an explicit -fmsc-version flag, since in the absence of an -fmsc-version flag, the implicit value of the flag is 17 (MSVC2013) with MSVC triples but 0 (not set) for other triples, and the default triple is platform dependent. This relands r263974 with a test fix. llvm-svn: 264210
2016-03-21Revert r263974, "clang-cl: With -fmsc-version=1900, use MSVS2015 diag ↵NAKAMURA Takumi1-9/+1
formatting." It seems the test wouldn't expect if default target is *-win32. llvm-svn: 264007
2016-03-21clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.Nico Weber1-1/+9
llvm-svn: 263974
2016-02-17Don't crash w/ a diagnostic range containing a null byteDavid Majnemer1-3/+11
We prematurely ended the line at the null byte which caused us to crash down stream because we tried to reason about columns beyond the end of the line. llvm-svn: 261171
2015-10-20Roll-back r250822.Angel Garcia Gomez1-1/+1
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-1/+1
Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
2015-10-03Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren1-1/+1
+couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
2015-10-03Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren1-1/+1
SourceLocation.isValid(). llvm-svn: 249228
2015-08-11[modules] Properly diagnose errors in module files for which we have noRichard Smith1-3/+3
corresponding include location (those specified on the command line). llvm-svn: 244538
2015-05-11Give isCompatibleWithMSVC a better interfaceDavid Majnemer1-1/+1
We now use an enum which maps the marketing name (almost always a year) to the major version number. llvm-svn: 236967
2015-02-02The prefix 'Ms-' should be 'MS-'David Majnemer1-3/+3
Clang is otherwise consistent that Microsoft be abbreviated as MS, not Ms. llvm-svn: 227842
2015-01-08Frontend: Fix SourceColumnMap assertion failure on non-ascii characters.Logan Chien1-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
2014-12-20Frontend: Fix typo in comments.Logan Chien1-2/+2
llvm-svn: 224680
2014-07-16Driver: bifurcate extended and basic MSC versioningSaleem Abdulrasool1-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
2014-07-05Track IntrusiveRefCntPtr::get() changes from LLVM r212366Alp Toker1-1/+1
llvm-svn: 212369
2014-06-21DiagnosticRenderer: emit basic notes as real diagnosticsAlp Toker1-6/+0
Fixes terminal column wrapping and vestigial 'note:' prefixes that would appear when using emitBasicNote(). llvm-svn: 211448
2014-06-21TextDiagnostic: print remark level diagnostics in bold tooAlp Toker1-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
2014-06-20Driver: enhance MSC version compatibilitySaleem Abdulrasool1-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
2014-03-07The Visual Studio IDE changed behavior in VS2012. It used to be the case thatYunzhong Gao1-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
2014-03-01[C++11] Replace verbose functors with succinct lambdasBenjamin Kramer1-9/+1
No functionality change. llvm-svn: 202590
2014-02-28Add 'remark' diagnostic type in 'clang'Tobias Grosser1-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
2014-02-27Split FileEntry name vs. isValidBen Langmuir1-1/+1
This is a small bit of refactoring in preparation for FileEntry owning the storage for its own name. llvm-svn: 202412
2013-09-24clang-cl: print diagnostics as "error(clang): foo" in /fallback modeHans Wennborg1-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
2013-08-01Use llvm::sys::fs::UniqueID for windows and unix.Rafael Espindola1-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
2013-06-07Handle Unicode characters in fix-it replacement strings.Jordan Rose1-19/+17
Patch by Sukolsak Sakshuwong! llvm-svn: 183535
2013-04-23Make compares unsigned. The expression can't become negative anyways.Benjamin Kramer1-2/+2
Silences a sign compare warning on 32 bit archs. llvm-svn: 180110
2013-03-15Fix buffer underrun (invalid read) triggered during diagnostic rendering. ↵Ted Kremenek1-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
2013-02-08Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose1-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
2013-02-05TextDiagnostic.cpp: Suppress a warning to use ptrdiff_t on i686-clang. ↵NAKAMURA Takumi1-1/+1
[-Wsign-compare] llvm-svn: 174353
2013-01-30Diagnostics: Clarify name of line-length-limiting constant in r173976.Jordan Rose1-3/+3
Thanks, Sean. llvm-svn: 173981
2013-01-30Diagnostics: if a line is longer than 4096 characters, don't print it.Jordan Rose1-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
2013-01-30Move UTF conversion routines from clang/lib/Basic to llvm/lib/SupportDmitri Gribenko1-1/+1
This is required to use them in TableGen. llvm-svn: 173924
2012-12-18Be defensive when printing module import locations; the diagnostic printer ↵Douglas Gregor1-1/+1
needs to be robust llvm-svn: 170466
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-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
2012-12-01Make helper classes anonymous. Make helper functions static instead of ↵Benjamin Kramer1-155/+156
private members so the anonymous class doesn't leak out. No functionality change. llvm-svn: 169099
2012-11-30When we're emitting a diagnostic with a source location in an importedDouglas Gregor1-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
2012-11-30When an error occurs while building a module on demand, provide "WhileDouglas Gregor1-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
2012-11-03only truncate source lines in text diagnostics whenSeth Cantrell1-2/+2
the ellipsis is shorter than the text it replaces llvm-svn: 167364
2012-11-03don't step into the middle of multibyte sequencesSeth Cantrell1-2/+2
llvm-svn: 167361
2012-11-03fix bug in SourceColumnMap::startOfPreviousColumnSeth Cantrell1-1/+1
llvm-svn: 167360