summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/TextDiagnosticPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove the doxyment for this now defunct parameter.Chandler Carruth2011-09-061-1/+0
| | | | llvm-svn: 139197
* Don't recompute the presumed loc twice in 5 lines of code... Spotted byChandler Carruth2011-09-061-1/+1
| | | | | | inspection. llvm-svn: 139196
* Use ArrayRef for the fixit hint array rather than a pointer and a size.Chandler Carruth2011-09-061-35/+34
| | | | | | | Clean up loops over the hints to use the more idiomatic iterator form in LLVM and Clang. llvm-svn: 139195
* Hoist the construction of the FixItHint line into a member function withChandler Carruth2011-09-061-64/+79
| | | | | | | | | | | | a defined interface. This isn't as nice as the previous one, but should get better as I push through better data types in all these functions. Also, I'm hoping to pull some aspects of this out into a common routine (such as tab expansion). Again, WIP, comments welcome as I'm going through. llvm-svn: 139190
* Hoist the emission of parseable fixits into a helper method, simplifyingChandler Carruth2011-09-021-38/+38
| | | | | | and reducing indentation through the clever use of early exits. ;] llvm-svn: 139001
* Create a CaretDiagnostic class to hold the logic for emittingChandler Carruth2011-08-311-263/+331
| | | | | | | | | | | | | | (unsurprisingly) caret diagnostics. This is designed to bring some organization to the monstrous EmitCaretDiagnostic function, and allow factoring it more easily and with less mindless parameter passing. Currently this just lifts the existing function into a method, and splits off the obviously invariant arguments to be class members. No functionality is changed, and there are still lots of warts to let existing code continue functioning as-is. Definitely WIP, more cleanups to follow. llvm-svn: 138921
* Sink all of the include stack printing logic into its member function.Chandler Carruth2011-08-311-18/+39
| | | | llvm-svn: 138920
* Rename SourceManager (and InstantiationInfo) isMacroArgInstantiation APIChandler Carruth2011-07-261-3/+3
| | | | | | to isMacroArgExpansion. llvm-svn: 136053
* Rename getInstantiationLineNumber to getExpansionLineNumber in bothChandler Carruth2011-07-251-2/+2
| | | | | | SourceManager and FullSourceLoc. llvm-svn: 135969
* Rename getInstantiationColumnNumber to getExpansionColumnNumber in bothChandler Carruth2011-07-251-2/+2
| | | | | | SourceManager and FullSourceLoc. llvm-svn: 135965
* Rename getDecomposedInstantiationLoc to getDecomposedExpansionLoc.Chandler Carruth2011-07-251-1/+1
| | | | llvm-svn: 135962
* Rename SourceManager::getImmediateInstantiationRange toChandler Carruth2011-07-251-2/+2
| | | | | | getImmediateExpansionRange. llvm-svn: 135960
* Rename SourceManager::getInstantiationRange to getExpansionRange.Chandler Carruth2011-07-251-2/+2
| | | | llvm-svn: 135915
* Mechanically rename SourceManager::getInstantiationLoc andChandler Carruth2011-07-251-5/+5
| | | | | | | | FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part of the API and documentation update from 'instantiation' as the term for macros to 'expansion'. llvm-svn: 135914
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-18/+18
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Switch all local code and comments from '[Ii]nstantiat(ion|ed)' toChandler Carruth2011-07-141-14/+14
| | | | | | | | '[Ee]xpan(sion|ded)' in the TextDiagnosticPrinter. No functionality changed. llvm-svn: 135136
* Switch the diagnostic messages about macros to use the terms 'expanded'Chandler Carruth2011-07-141-2/+2
| | | | | | | | | and 'expansions' rather than 'instantiated' and 'contexts'. This is the first of several patches migrating Clang's terminology surrounding macros from 'instantiation' to 'expansion'. llvm-svn: 135135
* Keep track of which source locations are part of a macro argumentChandler Carruth2011-07-071-13/+83
| | | | | | | | | | | | | | | | | | | | instantiation and improve diagnostics which are stem from macro arguments to trace the argument itself back through the layers of macro expansion. This requires some tricky handling of the source locations, as the argument appears to be expanded in the opposite direction from the surrounding macro. This patch provides helper routines that encapsulate the logic and explain the reasoning behind how we step through macros during diagnostic printing. This fixes the rest of the test cases originially in PR9279, and later split out into PR10214 and PR10215. There is still some more work we can do here to improve the macro backtrace, but those will follow as separate patches. llvm-svn: 134660
* Fix PR9279 - Macro expansion stack trace seriously broken with ↵Chris Lattner2011-06-281-7/+9
| | | | | | | | | | | | | | function-style macros, by not recursively printing notes for other 'instantiated from' notes. This is a one line fix here: + // Don't print recursive instantiation notes from an instantiation note. + Loc = SM.getSpellingLoc(Loc); While here, fix the testcase to be more precise (it got filecheck'ized brutally), and fix EmitCaretDiagnostic to be private and to not pass down the unused 'Level' argument. llvm-svn: 133993
* In TextDiagnosticPrinter::EmitCaretDiagnostic, don't always drop fixits if ↵Argyrios Kyrtzidis2011-06-241-2/+3
| | | | | | | | the caret location points to a macro instantiation. llvm-svn: 133802
* Change the include stack of "instantiated from" notes to fall under the ↵Richard Trieu2011-05-261-1/+1
| | | | | | control of f/fno-diagnostics-show-note-include-stack flags. This should help with reducing diagnostic spew from macros instantiations. llvm-svn: 132143
* A StringRef-ication of the DiagnosticIDs API and internals.Argyrios Kyrtzidis2011-05-251-2/+2
| | | | | | | | | Patch by Matthieu Monrocq with tweaks by me to avoid StringRefs in the static diagnostic data structures, which resulted in a huge global-var-init function. Depends on llvm commit r132046. llvm-svn: 132047
* Introduce the -fdiagnostics-format=xxx option to control how ClangDouglas Gregor2011-05-211-9/+21
| | | | | | | | | | | | prints the file, line, and column of a diagnostic. We currently support Clang's normal format, MSVC, and Vi formats. Note that we no longer change the diagnostic format based on -fms-extensions. Patch by Andrew Fish! llvm-svn: 131794
* Initial work to improve documentation for Clang's diagnostics, from Matthieu ↵Douglas Gregor2011-04-151-0/+7
| | | | | | Monrocq llvm-svn: 129614
* Remove a redundant isValid() checkMatt Beaumont-Gay2011-03-311-1/+1
| | | | llvm-svn: 128606
* Add an option to suppress include stack printing on note diagnostics.Chandler Carruth2011-03-271-10/+15
| | | | | | | | | | | | | | | | | | These stacks are often less important than those on primary diagnostics. As the number of notes grows, this becomes increasingly important. The include stack printing is clever and doesn't print stacks for adjacent diagnostics from the same file, but when a note is in between a sequence of errors in a header file, and the notes all refer to some other file, we end up getting a worst-case ping-pong of include stacks that take up a great deal of vertical space. Still, for now, the default behavior isn't changed. We can evaluate user feedback with the flag. Patch by Richard Trieu, a couple of style tweaks from me. llvm-svn: 128371
* Teach TextDiagnosticPrinter to print out '-Werror' in addition to the ↵Ted Kremenek2011-02-251-1/+13
| | | | | | | | | | warning flag for a warning mapped to an error. For example: t.c:7:9: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses] llvm-svn: 126466
* TextDiagnosticPrinter.cpp: Show diagnostics as far as possible even with ↵Axel Naumann2011-01-271-71/+89
| | | | | | | | | | | | | | invalid PresomedLoc, instead of just silencing it. FileManager.cpp: Allow virtual files in nonexistent directories. FileManager.cpp: Close FileDescriptor for virtual files that correspond to actual files. FileManager.cpp: Enable virtual files to be created even for files that were flagged as NON_EXISTENT_FILE, e.g. by a prior (unsuccessful) addFile(). ASTReader.cpp: Read a PCH even if the original source files cannot be found. Add a test for reading a PCH of a file that has been removed and diagnostics referencing that file. llvm-svn: 124374
* Since multiple diagnostics can share one diagnostic client, have the client ↵Argyrios Kyrtzidis2010-11-181-0/+3
| | | | | | | | keeping track of the total number of warnings/errors reported. llvm-svn: 119731
* Refactoring of Diagnostic class.Argyrios Kyrtzidis2010-11-181-6/+8
| | | | | | | | | | | -Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class. -DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units. -The rest of the state in Diagnostic object is considered related and tied to one translation unit. -Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a SourceLocation instead of a FullSourceLoc. -Reflect the changes to various interfaces. llvm-svn: 119730
* Make sure to always check the result ofDouglas Gregor2010-11-121-2/+13
| | | | | | | SourceManager::getPresumedLoc(), so that we don't try to make use of an invalid presumed location. Doing so can cause crashes. llvm-svn: 118885
* Teach SourceManager::getPresumedLoc() how to fail gracefully if ↵Douglas Gregor2010-11-021-1/+1
| | | | | | getLineNumber/getColumnNumber fail llvm-svn: 117990
* Eliminate some extraneous whitespace in the machine-parseable Fix-It output.Douglas Gregor2010-08-201-2/+2
| | | | llvm-svn: 111610
* Add machine-parseable Fix-It output as part of diagnostics, under theDouglas Gregor2010-08-191-0/+42
| | | | | | flag -fdiagnostics-parseable-fixits, from Eelis van der Weegen! llvm-svn: 111557
* Simplify FixItHint by eliminated the unnecessary InsertionLocDouglas Gregor2010-08-181-2/+2
| | | | | | location. Patch by Eelis van der Weegen! llvm-svn: 111362
* Bug 7377: printf checking fails to flag some undefined behavior Tom Care2010-06-211-15/+18
| | | | | | | | | | | | | | | | | http://llvm.org/bugs/show_bug.cgi?id=7377 Updated format string highlighting and fixits to take advantage of the new CharSourceRange class. - Change HighlightRange to allow highlighting whitespace only in a CharSourceRange (for warnings about the ' ' (space) flag) - Change format specifier range helper function to allow for half-open ranges (+1 to end) - Enabled previously failing tests (FIXMEs/XFAILs removed) - Small fixes and additions to format string test cases M test/Sema/format-strings.c M test/Sema/format-strings-fixit.c M lib/Frontend/TextDiagnosticPrinter.cpp M lib/Sema/SemaChecking.cpp llvm-svn: 106480
* introduce a new CharSourceRange class, and enhance the diagnostics routinesChris Lattner2010-06-181-12/+18
| | | | | | | | | | | | | | | to use them instead of SourceRange. CharSourceRange is just a SourceRange plus a bool that indicates whether the range has the end character resolved or whether the end location is the start of the end token. While most of the compiler wants to think of ranges that have ends that are the start of the end token, the printf diagnostic stuff wants to highlight ranges within tokens. This is transparent to the diagnostic stuff. To start taking advantage of the new capabilities, you can do something like this: Diag(..) << CharSourceRange::getCharRange(Begin,End) llvm-svn: 106338
* when too many errors are emitted, and we produce:Chris Lattner2010-05-241-0/+2
| | | | | | | | fatal error: too many errors emitted, stopping now [-ferror-limit=] Tell the user that this is controlled with -ferror-limit=, like above. llvm-svn: 104528
* add a new -fdiagnostics-show-category=none/id/name option, giving controlChris Lattner2010-05-041-2/+7
| | | | | | | | | | | | over choice of: t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat] t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1] t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,Format String] dox to come. llvm-svn: 103056
* When -fdiagnostics-print-source-range-info is specified,Chris Lattner2010-05-041-4/+29
| | | | | | | | | | | | | | | | | | | | | | | print the diagnostic category number in the [] at the end of the line. For example: $ cat t.c #include <stdio.h> void foo() { printf("%s", 4); } $ clang t.c -fsyntax-only -fdiagnostics-print-source-range-info t.c:3:11:{3:10-3:12}{3:15-3:16}: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1] printf("%s", 4); ~^ ~ 1 warning generated. Clients that want category information can now pick the number out of the output, rdar://7928231. More coming. llvm-svn: 103053
* Introduce a limit on the depth of the macro instantiation backtraceDouglas Gregor2010-05-041-21/+61
| | | | | | | | | | | | | | printed in a diagnostic, similar to the limit we already have on the depth of the template instantiation backtrace. The macro instantiation backtrace is limited to 10 "instantiated from:" diagnostics; when it's longer than that, we'll show the first half, then say how many were suppressed, then show the second half. The limit can be changed with -fmacro-instantiation-limit=N, and turned off with N=0. This eliminates a lot of note spew with libraries making use of the Boost.Preprocess library. llvm-svn: 103014
* change FullSourceLoc to have a *const* SourceManager&, eliminatingChris Lattner2010-04-201-1/+1
| | | | | | a const_cast. llvm-svn: 101940
* Fix a bug in caret-line-pruning logic that only happens when we have aDouglas Gregor2010-04-161-3/+10
| | | | | | | | source line wider than the terminal where the associated fix-it line is longer than the caret line. Previously, we would crash in this case, which was rather unfortunate. Fixes <rdar://problem/7856226>. llvm-svn: 101426
* fix PR6814 - Only print [-pedantic] on a diagnostic if -pedantic Chris Lattner2010-04-121-2/+7
| | | | | | | | actually turned it on. If a diag is produced by a warning which is an extension but defaults to on, and has no warning group, don't print any option info. llvm-svn: 101071
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-7/+7
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-7/+7
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-7/+7
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Let SourceManager::getBufferData return StringRef instead of a pair of two ↵Benjamin Kramer2010-03-161-5/+2
| | | | | | const char*. llvm-svn: 98630
* Give SourceManager a Diagnostic object with which to report errors,Douglas Gregor2010-03-161-6/+5
| | | | | | and start simplifying the interfaces in SourceManager that can fail. llvm-svn: 98594
* Introduce a new BufferResult class to act as the return type ofDouglas Gregor2010-03-151-2/+8
| | | | | | | | | | | | | | SourceManager's getBuffer() (and similar) operations. This abstract can be used to force callers to cope with errors in getBuffer(), such as missing files and changed files. Fix a bunch of callers to use the new interface. Add some very basic checks for file consistency (file size, modification time) into ContentCache::getBuffer(), although these checks don't help much until we've updated the main callers (e.g., SourceManager::getSpelling()). llvm-svn: 98585
OpenPOWER on IntegriCloud