summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Diagnostic.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Basic] Add a DiagnosticError llvm::ErrorInfo subclassAlex Lorenz2017-08-251-1/+4
| | | | | | | | | Clang's DiagnosticError is an llvm::Error payload that stores a partial diagnostic and its location. I'll be using it in the refactoring engine. Differential Revision: https://reviews.llvm.org/D36969 llvm-svn: 311778
* DiagnosticsEngine should clear DelayedDiagID before reporting theAlex Lorenz2017-05-041-5/+3
| | | | | | | | | | | | | | | | | | | | | delayed diagnostic This fix avoids an infinite recursion that was uncovered in one of our internal tests by r301992. The testcase is the most reduced version of that auto-generated test. This is an improved version of the reverted commit r302037. The previous fix actually managed to expose another subtle bug whereby `fatal_too_many_errors` error was reported twice, with the second report setting the `FatalErrorOccurred` flag. That prevented the notes that followed the diagnostic the caused `fatal_too_many_errors` to be emitted. This commit ensures that notes that follow `fatal_too_many_errors` but that belong to the diagnostic that caused `fatal_too_many_errors` won't be emitted by setting the `FatalErrorOccurred` when emitting `fatal_too_many_errors`. rdar://31962618 llvm-svn: 302151
* Revert r302037Alex Lorenz2017-05-031-2/+1
| | | | | | | | | The commit caused the following two buildbot failures: Clang :: Misc/error-limit-multiple-notes.cpp Clang :: Misc/error-limit.c llvm-svn: 302046
* DiagnosticsEngine should clear DelayedDiagID before reporting theAlex Lorenz2017-05-031-1/+2
| | | | | | | | | | | | delayed diagnostic This avoids an infinite loop that was uncovered in one of our internal tests by r301992. The testcase is the most reduced version of that auto-generated test. rdar://31962618 llvm-svn: 302037
* [modules] Round-trip -Werror flag through explicit module build.Richard Smith2017-05-031-9/+3
| | | | | | | | | | | | | | | The intent for an explicit module build is that the diagnostics produced within the module are those that were configured when the module was built, not those that are enabled within a user of the module. This includes diagnostics that don't actually show up until the module is used (for instance, diagnostics produced during template instantiation and weird cases like -Wpadded). We serialized and restored the diagnostic state for individual warning groups, but previously did not track the state for flags like -Werror and -Weverything, which are implemented as separate bits rather than as part of the diagnostics mapping information. llvm-svn: 301992
* Serialization: Simulate -Werror settings in implicit modulesDuncan P. N. Exon Smith2017-04-121-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r293123 started serializing diagnostic pragma state for modules. This makes the serialization work properly for implicit modules. An implicit module build (using Clang's internal build system) uses the same PCM file location for different `-Werror` levels. E.g., if a TU has `-Werror=format` and tries to load a PCM built without `-Werror=format`, a new PCM will be built in its place (and the new PCM should have the same signature, since r297655). In the other direction, if a TU does not have `-Werror=format` and tries to load a PCM built with `-Werror=format`, it should "just work". The idea is to evolve the PCM toward the strictest -Werror flags that anyone tries. r293123 started serializing the diagnostic pragma state for each PCM. Since this encodes the -Werror settings at module-build time, it breaks the implicit build model. This commit filters the diagnostic state in order to simulate the current compilation's diagnostic settings. Firstly, it ignores the module's serialized first diagnostic state, replacing it with the state from this compilation's command-line. Secondly, if a pragma warning was upgraded to error/fatal when generating the PCM (e.g., due to `-Werror` on the command-line), it checks whether it should still be upgraded in its current context. llvm-svn: 300025
* Remove and replace DiagStatePoint tracking and lookup data structure.Richard Smith2017-01-261-85/+100
| | | | | | | | | | | | | | | | | | | | | | | Rather than storing a single flat list of SourceLocations where the diagnostic state changes (in source order), we now store a separate list for each FileID in which there is a diagnostic state transition. (State for other files is built and cached lazily, on demand.) This has two consequences: 1) We can now sensibly support modules, and properly track the diagnostic state for modular headers (this matters when, for instance, triggering instantiation of a template defined within a module triggers diagnostics). 2) It's much faster than the old approach, since we can now just do a binary search on the offsets within the FileID rather than needing to call isBeforeInTranslationUnit to determine source order (which is surprisingly slow). For some pathological (but real world) files, this reduces total compilation time by more than 10%. For now, the diagnostic state points for modules are loaded eagerly. It seems feasible to defer this until diagnostic state information for one of the module's files is needed, but that's not part of this patch. llvm-svn: 293123
* [Basic] Remove source manager references from diag state points.Benjamin Kramer2017-01-181-10/+32
| | | | | | | | | This is just wasted space, we don't support state points from multiple source managers. Validate that there's no state when resetting the source manager and use the 'global' reference to the sourcemanager instead of the ones in the diag state. llvm-svn: 292402
* Add an assert to catch improperly constructed %diff sequences inChandler Carruth2016-12-231-1/+4
| | | | | | | | | | | diagnostics and fix one such diagnostic. Sadly, this assert doesn't catch this bug because we have no tests that emit this diagnostic! Doh! I'm following up on the commit that introduces it to get that fixed. Then this assert will help in a more direct way. llvm-svn: 290417
* [Diag] Fix idiom in comment: "on the lam", not "on the lamb".Justin Lebar2016-08-101-3/+3
| | | | llvm-svn: 278192
* Move some IntrusiveRefCntPtrs instead of copying.Benjamin Kramer2016-07-211-4/+6
| | | | | | No functionality change intended. llvm-svn: 276292
* Optionally demote fatal errors to non-fatal errors.Manuel Klimek2016-03-011-0/+1
| | | | | | | | | | | | | | | | | | This behavior is enabled when the new CXTranslationUnit_KeepGoing option is passed to clang_parseTranslationUnit{,2}. It is geared towards use by IDEs and similar consumers of the clang-c API where fatal errors may arise when parsing incomplete code mid-edit, or when include paths are not properly configured yet. In such situations one still wants to get as much information as possible about a TU. Previously, the semantic analysis would not instantiate templates or report additional fatal errors after the first fatal error was encountered. Fixes PR24268. Patch by Milian Wolff. llvm-svn: 262318
* [Diagnostics] Call setMapping on the correct diagnostic states in a few ↵Craig Topper2015-11-261-3/+3
| | | | | | | | | | | | places. GetCurDiagState() was being used when it shouldn't be. I spotted this by inspection in the for loop that wasn't using its iterator and was just acting on the current state repeatedly. This appears to have been introduced as a copy and paste bug in r140763 over 4 years ago. I have no idea how to test this. I just went back to the original commit and tried to use the variables it was using before that. llvm-svn: 254134
* Use range-based for loops. NFCCraig Topper2015-11-261-7/+7
| | | | llvm-svn: 254133
* Roll-back r250822.Angel Garcia Gomez2015-10-201-2/+2
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-2/+2
| | | | | | | | | | | | 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
* Wdeprecated: StoredDiagnostics are stored in a SmallVector, so make sure ↵David Blaikie2015-08-131-4/+0
| | | | | | | | | | | they're copy/movable Removing the no-op dtor makes these objects safely implicitly copyable/movable/etc. (& tidy up the ctor, while I'm here) llvm-svn: 244971
* Replace __double_underscored type nullability qualifiers with ↵Douglas Gregor2015-06-241-0/+21
| | | | | | | | | | | | | | | | _Uppercase_underscored Addresses a conflict with glibc's __nonnull macro by renaming the type nullability qualifiers as follows: __nonnull -> _Nonnull __nullable -> _Nullable __null_unspecified -> _Null_unspecified This is the major part of rdar://problem/21530726, but does not yet provide the Darwin-specific behavior for the old names. llvm-svn: 240596
* push_back() loop -> append() for random access iterators.Benjamin Kramer2015-06-121-10/+2
| | | | | | | append will resize the vector to the optimal size. No functional change intended. llvm-svn: 239607
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-291-1/+1
| | | | | | | | | | | | | | | | | | | | If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238601
* Prefer SmallVector::append/insert over push_back loops. Clang edition.Benjamin Kramer2015-02-171-8/+2
| | | | | | Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229508
* Clean up a string comparison with StringRef. Suggestion by David Majnemer.Richard Trieu2015-01-171-1/+2
| | | | llvm-svn: 226359
* When the diagnostic text is simply "%0", sanitize the string for anyRichard Trieu2015-01-081-0/+15
| | | | | | unprintable characters. Fixes PR22048. llvm-svn: 225423
* Destroy the diagnostic client first in ~DiagnosticEngineReid Kleckner2014-12-171-0/+6
| | | | | | | | | | | | Add a comment and a test to ~DiagnosticEngine about the ordering requirements on the teardown of DiagnosticConsumer. This could also be accomplished by rearranging the fields of ~DiagnosticEngine, but I felt that this was a better, more explicit solution. This fixes PR21911, an issue that occurred after the unique_ptr migration in r222193. llvm-svn: 224454
* Make DiagnosticsEngine::takeClient return std::unique_ptr<>Alexander Kornienko2014-11-171-15/+5
| | | | | | | | | | | | | | | | | | Summary: Make DiagnosticsEngine::takeClient return std::unique_ptr<>. Updated callers to store conditional ownership using a pair of pointer and unique_ptr instead of a pointer + bool. Updated code that temporarily registers clients to use the non-owning registration (+ removed extra calls to takeClient). Reviewers: dblaikie Reviewed By: dblaikie Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6294 llvm-svn: 222193
* Remove unused DiagnosticsEngine::NumErrorsSuppressed member.Rafael Espindola2014-10-221-1/+0
| | | | | | Patch by Brad King! llvm-svn: 220413
* Increase SmallVector<> size in DiagnosticsEngine::setSeverityForGroupHans Wennborg2014-08-111-3/+3
| | | | | | | | In a Clang bootstrap, this vector always held 129 elements. Also switch to a range-based for loop. llvm-svn: 215360
* Use -Rblah, not -Wblah, to control remark diagnostics. This was always theRichard Smith2014-08-071-8/+14
| | | | | | | | | | | | | | | | | | | | | | intent when we added remark support, but was never implemented in the general case, because the first -R flags didn't need it. (-Rpass= had special handling to accomodate its argument.) -Rno-foo, -Reverything, and -Rno-everything can be used to turn off a remark, or to turn on or off all remarks. Per discussion on cfe-commits, -Weverything does not affect remarks, and -Reverything does not affect warnings or errors. The only "real" -R flag we have right now is -Rmodule-build; that flag is effectively renamed from -Wmodule-build to -Rmodule-build by this change. -Wpass and -Wno-pass (and their friends) are also renamed to -Rpass and -Rno-pass by this change; it's not completely clear whether we intended to have a -Rpass (with no =pattern), but that is unchanged by this commit, other than the flag name. The default pattern is effectively one which matches no passes. In future, we may want to make the default pattern be .*, so that -Reverything works for -Rpass properly. llvm-svn: 215046
* DiagnosticIDs: use diagnostic severities to simplify extension handlingAlp Toker2014-06-221-1/+1
| | | | llvm-svn: 211479
* DiagnosticsEngine: update severity setters to new terminologyAlp Toker2014-06-121-12/+10
| | | | llvm-svn: 210764
* Complete the switch from mappings to declarative diagnostic severitiesAlp Toker2014-06-121-11/+11
| | | | | | | | | This begins to address cognitive dissonance caused by treating the Note diagnostic level as a severity in the diagnostic engine. No change in functionality. llvm-svn: 210758
* Use StringRef to simplify code. No functional change.Craig Topper2014-06-121-10/+9
| | | | llvm-svn: 210751
* Use ArrayRef in some function parameters instead of a pointer and count. No ↵Craig Topper2014-06-121-14/+12
| | | | | | functional change. llvm-svn: 210750
* Improve diagnostic mapping terminologyAlp Toker2014-06-101-25/+24
| | | | | | | | | | | | Diagnostic mappings are used to calculate the final severity of diagnostic instances. Detangle the implementation to reflect the terminology used in documentation and bindings. No change in functionality. llvm-svn: 210518
* Remove limits on the number of fix-it hints and ranges in the DiagnosticsEngine.Alexander Kornienko2014-05-221-9/+6
| | | | | | | | | | | | | | | | | | | 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'.Craig Topper2014-05-081-5/+5
| | | | llvm-svn: 208280
* Fix -Wreturn-type build failure on ASTMatchers, plus an intended assertAlp Toker2014-01-261-1/+1
| | | | llvm-svn: 200140
* Remove flawed diagnostic mapping functionsAlp Toker2014-01-261-35/+0
| | | | | | | These haven't been usable since the early return was accidentally removed some years ago causing all cases to fall through to the !Enabled condition. llvm-svn: 200123
* Bring back magic constants in the digraph diagnosticAlp Toker2014-01-071-2/+0
| | | | | | | | This backs out changes in commit r198605 and part of r198604, replacing the original tok::kw_template with a slightly more obvious placeholder tok::unknown. llvm-svn: 198666
* Support diagnostic formatting of keyword tokensAlp Toker2014-01-061-7/+13
| | | | | | | | | Implemented with a new getKeywordSpelling() accessor. Unlike getTokenName() the result of this function is stable and may be used in diagnostic output. Uses of this feature are split out into the subsequent commit. llvm-svn: 198604
* Rename getTokenSimpleSpelling() to getPunctuatorSpelling()Alp Toker2014-01-061-1/+1
| | | | | | | That's what it does, what the documentation says it does and what callers expect it to do. llvm-svn: 198603
* Teach the diagnostics engine about the Attr type to make reporting on ↵Aaron Ballman2013-12-261-0/+1
| | | | | | semantic attributes easier (and not require hard-coded strings). This requires a getSpelling() function on the Attr class, which is table-driven. Updates a handful of cases where a hard-coded string was being used to test the functionality out. Updating associated test cases for the improved quoting. llvm-svn: 198055
* Support and use token kinds as diagnostic argumentsAlp Toker2013-12-241-0/+29
| | | | | | | | | | | | | | | | | | | Introduce proper facilities to render token spellings using the diagnostic formatter. Replaces most of the hard-coded diagnostic messages related to expected tokens, which all shared the same semantics but had to be multiply defined due to variations in token order or quote marks. The associated parser changes are largely mechanical but they expose commonality in whole chunks of the parser that can now be factored away. This commit uses C++11 typed enums along with a speculative legacy fallback until the transition is complete. Requires corresponding changes in LLVM r197895. llvm-svn: 197972
* Revert r177218.Argyrios Kyrtzidis2013-05-031-1/+0
| | | | | | Per discussion in cfe-commits, asserting may be a better way than introducing a special test flag. llvm-svn: 181073
* Remove DiagnosticConsumer::clone(), a bad idea that is now unused.Douglas Gregor2013-05-031-5/+0
| | | | llvm-svn: 181070
* When building a module, forward diagnostics to the outer diagnostic consumer.Douglas Gregor2013-05-031-0/+22
| | | | | | | | | | | | | | | Previously, we would clone the current diagnostic consumer to produce a new diagnostic consumer to use when building a module. The problem here is that we end up losing diagnostics for important diagnostic consumers, such as serialized diagnostics (where we'd end up with two diagnostic consumers writing the same output file). With forwarding, the diagnostics from all of the different modules being built get forwarded to the one serialized-diagnostic consumer and are emitted in a sane way. Fixes <rdar://problem/13663996>. llvm-svn: 181067
* Initialize WarnOnSpellCheck.Rafael Espindola2013-05-031-0/+1
| | | | | | | | | Clang always calls setWarnOnSpellCheck, but we shouldn't require every client to do so. Issue noticed by Enea Zaffanella. llvm-svn: 181021
* Moving initialization into the initializer list and correcting ↵Aaron Ballman2013-02-241-4/+3
| | | | | | capitalization, as suggested by Chandler. llvm-svn: 176001
* Fixing a typo where FixIts was accidentally self-assigning instead of ↵Aaron Ballman2013-02-191-1/+1
| | | | | | assigning in the parameter Fixits. This fixes several failed assertions with MSVC debug builds. llvm-svn: 175483
* Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose2013-02-081-7/+7
| | | | | | | 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
OpenPOWER on IntegriCloud