summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Diagnostic.cpp
Commit message (Collapse)AuthorAgeFilesLines
* introduce a new CharSourceRange class, and enhance the diagnostics routinesChris Lattner2010-06-181-6/+12
| | | | | | | | | | | | | | | 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
* Add an option -fshow-overloads=best|all to limit the number of overloadJeffrey Yasskin2010-06-111-0/+1
| | | | | | | candidates printed. We default to 'all'. At the moment, 'best' prints only the first 4 overloads, but we'll improve that over time. llvm-svn: 105815
* Update the types for warning option subgroup arrays to 'short', we have moreChandler Carruth2010-05-131-4/+4
| | | | | | | than 127 groups so this was already failing given -fsigned-char. A subsequent to commit to TableGen will generate shorts for the arrays themselves. llvm-svn: 103703
* When -fdiagnostics-print-source-range-info is specified,Chris Lattner2010-05-041-0/+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
* add the ability to associate 'category' names with diagnosticsChris Lattner2010-05-041-4/+6
| | | | | | | | | and diagnostic groups. This allows the compiler to group diagnostics together (e.g. "Logic Warning", "Format String Warning", etc) like the static analyzer does. This is not exposed through anything in the compiler yet. llvm-svn: 103051
* Introduce a limit on the depth of the template instantiation backtraceDouglas Gregor2010-04-201-1/+2
| | | | | | | | | | | | | | | | we will print with each error that occurs during template instantiation. When the backtrace is longer than that, we will print N/2 of the innermost backtrace entries and N/2 of the outermost backtrace entries, then skip the middle entries with a note such as: note: suppressed 2 template instantiation contexts; use -ftemplate-backtrace-limit=N to change the number of template instantiation entries shown This should eliminate some excessively long backtraces that aren't providing any value. llvm-svn: 101882
* Once we've emitted a fatal diagnostic, keep counting errors but with aDouglas Gregor2010-04-141-1/+8
| | | | | | | | | | | | | | separate count of "suppressed" errors. This way, semantic analysis bits that depend on the error count to determine whether problems occured (e.g., some template argument deduction failures, jump-scope checking) will not get confused. The actual problem here is that a missing #include (which is a fatal error) could cause the jump-scope checker to run on invalid code, which it is not prepared to do. Trivial fix for both <rdar://problem/7775941> and <rdar://problem/7775709>. llvm-svn: 101297
* fix PR6814 - Only print [-pedantic] on a diagnostic if -pedantic Chris Lattner2010-04-121-4/+11
| | | | | | | | 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
* Fix null dereference in 'WriteSourceLocation' when the FileEntry is null.Ted Kremenek2010-04-121-11/+18
| | | | llvm-svn: 101060
* add clang -cc1 level support for "-ferror-limit 42"Chris Lattner2010-04-071-2/+2
| | | | llvm-svn: 100687
* add capabilities to stop emitting errors after some limit.Chris Lattner2010-04-071-0/+7
| | | | | | Right now the limit is 0 (aka disabled) llvm-svn: 100684
* Instead of counting totally diagnostics, split the count into a countChris Lattner2010-04-071-2/+5
| | | | | | | | | | | | | | | of errors and warnings. This allows us to emit something like this: 2 warnings and 1 error generated. instead of: 3 diagnostics generated. This also stops counting 'notes' because they are just follow-on information about the previous diag, not a diagnostic in themselves. llvm-svn: 100675
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-5/+5
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-5/+5
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-5/+5
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Optimize PartialDiagnostic's memory-allocation behavior by placing aDouglas Gregor2010-03-291-0/+11
| | | | | | | | | | | | | | cache of PartialDiagnostic::Storage objects into an allocator within the ASTContext. This eliminates a significant amount of malloc traffic, for a 10% performance improvement in -fsyntax-only wall-clock time with 403.gcc's combine.c. Also, eliminate the RequireNonAbstractType hack I put in earlier, which was but a symptom of this larger problem. Fixes <rdar://problem/7806091>. llvm-svn: 99849
* Teach the diagnostic engine to provide more detailed information aboutDouglas Gregor2010-03-251-4/+14
| | | | | | | | | how to handle a diagnostic during template argument deduction, which may be "substitution failure", "suppress", or "report". This keeps us from, e.g., emitting warnings while performing template argument deduction. llvm-svn: 99560
* Fix a thinko and a typo in the delayed-diagnostic code.Douglas Gregor2010-03-221-3/+4
| | | | llvm-svn: 99178
* Introduce the notion of a single "delayed" diagnostic into theDouglas Gregor2010-03-221-0/+47
| | | | | | | | | | | | Diagnostic subsystem, which is used in the rare case where we find a serious problem (i.e., an inconsistency in the file system) while we're busy formatting another diagnostic. In this case, the delayed diagnostic will be emitted after we're done with the other diagnostic. This is only to be used for fatal conditions detected at very inconvenient times, where we can neither stop the current diagnostic in flight nor can we suppress the second error. llvm-svn: 99175
* Use a little binary header in serialized diagnostics to help the ↵Douglas Gregor2010-02-191-3/+26
| | | | | | deserializer skip over noise in the stream llvm-svn: 96641
* Re-apply my diagnostics-capture patch for CIndex, with some tweaks toDouglas Gregor2010-02-181-1/+1
| | | | | | try to address the msvc failures. llvm-svn: 96624
* Rework how CIndex handles diagnostics. Rather than using a callback,Douglas Gregor2010-02-181-142/+168
| | | | | | | | | | | | | | | | | | we attach diagnostics to translation units and code-completion results, so they can be queried at any time. To facilitate this, the new StoredDiagnostic class stores a diagnostic in a serializable/deserializable form, and ASTUnit knows how to capture diagnostics in this stored form. CIndex's CXDiagnostic is a thin wrapper around StoredDiagnostic, providing a C interface to stored or de-serialized diagnostics. I've XFAIL'd one test case temporarily, because currently we end up storing diagnostics in an ASTUnit that's never returned to the user (because it contains errors). I'll introduce a temporary fix for this soon; the real fix will be to allow us to return and query invalid ASTs. llvm-svn: 96592
* Suppress warnings if their instantiation location is in a system header, notJohn McCall2010-02-111-1/+1
| | | | | | | | | | | | | their spelling location. This prevents warnings from being swallowed just because the caret is on the first parenthesis in, say, NULL. This is an experiment; the risk is that there might be a substantial number of system headers which #define symbols to expressions which inherently cause warnings. My theory is that that's rare enough that it can be worked around case-by-case, and that producing useful warnings around NULL is worth it. But I'm willing to accept that I might be empirically wrong. llvm-svn: 95870
* Introduce serialization and deserialization of diagnostic informationDouglas Gregor2010-01-281-0/+217
| | | | | | | | | | | | | | | | | so that CIndex can report diagnostics through the normal mechanisms even when executing Clang in a separate process. This applies both when performing code completion and when using ASTs as an intermediary for clang_createTranslationUnitFromSourceFile(). The serialized format is not perfect at the moment, because it does not encapsulate macro-instantiation information. Instead, it maps all source locations back to the instantiation location. However, it does maintain source-range and fix-it information. To get perfect fidelity from the serialized format would require serializing a large chunk of the source manager; at present, it isn't clear if this code will live long enough for that to matter. llvm-svn: 94740
* Pre-emptive bugfixes in the diagnostics code: allow arbitrary punctuationJohn McCall2010-01-141-8/+35
| | | | | | | characters to be escaped and implement a scan-forward function which properly respects brace nesting. llvm-svn: 93447
* Add the %ordinal format modifier for turning '1' into '1st'. Hard-coded forJohn McCall2010-01-141-0/+35
| | | | | | | English right now; would not be impossible to grab a special format string from the diagnostic pool and localize that way. llvm-svn: 93390
* Perform format-expansion on %select results.John McCall2010-01-131-5/+13
| | | | llvm-svn: 93377
* implement -W[no-]fatal-errors, patch by Christian Adåker!Chris Lattner2009-12-221-0/+13
| | | | llvm-svn: 91938
* Remove 'LangOpts' from Diagnostic (added in ↵Steve Naroff2009-12-051-1/+0
| | | | | | | | | | http://llvm.org/viewvc/llvm-project?view=rev&revision=90642). Simply use the 'LangOpts' member already present in TextDiagnosticPrinter. Sorry for the confusion! llvm-svn: 90664
* Integrate the following from the 'objective-rewrite' branch:Steve Naroff2009-12-051-1/+2
| | | | | | | | | | | | http://llvm.org/viewvc/llvm-project?view=rev&revision=71086 Note - This commit only includes the fix for: <rdar://problem/6309338> slightly different error message format for Visual Studio. The fix for <rdar://problem/6845623> from protocol to template. is separate/forthcoming. llvm-svn: 90642
* Convert Diagnostic::getCustomDiagID to take a StringRef.Daniel Dunbar2009-12-011-2/+2
| | | | llvm-svn: 90244
* Fixed undefined behavior in pushMappings when the stack has to resize.John Thompson2009-10-231-0/+2
| | | | llvm-svn: 84924
* teach FormatDiagnostic to aggregate previously formatted arguments andChris Lattner2009-10-201-3/+25
| | | | | | | | | pass them down into the ArgToStringFn implementation. This allows redundancy across operands to a diagnostic to be eliminated. This isn't used yet, so no functionality change. llvm-svn: 84602
* PR5218: Replace IdentifierInfo::getName with StringRef version, now that clientsDaniel Dunbar2009-10-181-1/+1
| | | | | | are updated. llvm-svn: 84447
* Use raw_ostream for formatting integers, and use IdentifierInfo::getNameStrDaniel Dunbar2009-10-171-10/+4
| | | | | | | instead of getName. - -2 FIXMEs. llvm-svn: 84337
* increase helpfulness of assert message.Chris Lattner2009-10-161-1/+6
| | | | llvm-svn: 84240
* Unify our diagnostic printing for errors of the form, "we didn't likeDouglas Gregor2009-10-131-0/+1
| | | | | | | | | | what we found when we looked into <blah>", where <blah> is a DeclContext*. We can now format DeclContext*'s in nice ways, e.g., "namespace N", "the global namespace", "'class Foo'". This is part of PR3990, but we're not quite there yet. llvm-svn: 84028
* Initial implementation of a code-completion interface in Clang. InDouglas Gregor2009-09-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | essence, code completion is triggered by a magic "code completion" token produced by the lexer [*], which the parser recognizes at certain points in the grammar. The parser then calls into the Action object with the appropriate CodeCompletionXXX action. Sema implements the CodeCompletionXXX callbacks by performing minimal translation, then forwarding them to a CodeCompletionConsumer subclass, which uses the results of semantic analysis to provide code-completion results. At present, only a single, "printing" code completion consumer is available, for regression testing and debugging. However, the design is meant to permit other code-completion consumers. This initial commit contains two code-completion actions: one for member access, e.g., "x." or "p->", and one for nested-name-specifiers, e.g., "std::". More code-completion actions will follow, along with improved gathering of code-completion results for the various contexts. [*] In the current -code-completion-dump testing/debugging mode, the file is truncated at the completion point and EOF is translated into "code completion". llvm-svn: 82166
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-49/+49
| | | | llvm-svn: 81346
* Improve diagnostics and recovery when the nested-name-specifier of aDouglas Gregor2009-08-261-0/+1
| | | | | | | | | | | | qualified name does not actually refer into a class/class template/class template partial specialization. Improve printing of nested-name-specifiers to eliminate redudant qualifiers. Also, make it possible to output a nested-name-specifier through a DiagnosticBuilder, although there are relatively few places that will use this leeway. llvm-svn: 80056
* add push/pop semantics for diagnostics. Patch by Louis Gerbarg!Chris Lattner2009-07-121-1/+16
| | | | llvm-svn: 75431
* Base SFINAE error suppression counting on the class of an error, notDouglas Gregor2009-06-151-1/+1
| | | | | | its (possibly-remapped) diagnostics. Thanks, Chris! llvm-svn: 73390
* Update LLVM.Douglas Gregor2009-06-141-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Implement support for C++ Substitution Failure Is Not An Error (SFINAE), which says that errors that occur during template argument deduction do *not* produce diagnostics and do not necessarily make a program ill-formed. Instead, template argument deduction silently fails. This is currently implemented for template argument deduction during matching of class template partial specializations, although the mechanism will also apply to template argument deduction for function templates. The scheme is simple: - If we are in a template argument deduction context, any diagnostic that is considered a SFINAE error (or warning) will be suppressed. The error will be propagated up the call stack via the normal means. - By default, all warnings and errors are SFINAE errors. Add the NoSFINAE class to a diagnostic in the .td file to make it a hard error (e.g., for access-control violations). Note that, to make this fully work, every place in Sema that emits an error *and then immediately recovers* will need to check Sema::isSFINAEContext() to determine whether it must immediately return an error rather than recovering. llvm-svn: 73332
* when creating custom warning diagnostics, do not attempt to mapChris Lattner2009-05-021-5/+0
| | | | | | | | them with -Werror. Custom diags cannot be mapped, and this makes -Werror cause a determinstic crash for the checker and other clients of the custom diagnostics machinery. rdar://6816191 llvm-svn: 70639
* Don't crash in the diagnostic printer if we happen to get passed aDaniel Dunbar2009-04-201-0/+13
| | | | | | null string / identifier. llvm-svn: 69575
* move group twiddling options into Diagnostic.cpp instead ofChris Lattner2009-04-191-0/+58
| | | | | | | Warnings.cpp. Warnings.cpp now doesn't need to #include tblgen produced output directly. llvm-svn: 69559
* optimize and comment GetDiagInfo.Chris Lattner2009-04-161-6/+32
| | | | llvm-svn: 69273
* merge several scattered tables into StaticDiagInfo.Chris Lattner2009-04-161-144/+19
| | | | llvm-svn: 69272
* Implement Diagnostic::getWarningOptionForDiag with information from tblgen,Chris Lattner2009-04-161-10/+19
| | | | | | this implements -fdiagnostics-show-option in clang-cc. llvm-svn: 69271
* tblgen is now passing diagnostic group information in the .inc file, ignore ↵Chris Lattner2009-04-161-3/+4
| | | | | | it everywhere. llvm-svn: 69269
OpenPOWER on IntegriCloud