summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/DiagnosticRenderer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix -Wnull-conversion for long macros.Richard Trieu2016-01-261-43/+2
| | | | | | | | | Move the function to get a macro name from DiagnosticRenderer.cpp to Lexer.cpp so that other files can use it. Lexer now has two functions to get the immediate macro name, the newly added one is better for diagnostic purposes. Make -Wnull-conversion use this function for better NULL macro detection. llvm-svn: 258778
* [diagnostics] Avoid crashes while printing macro backtracesReid Kleckner2015-12-081-19/+64
| | | | | | | | | | | | | | | | | | | When attempting to map a source into a given level of macro expansion, this code was ignoring the possibility that the start and end of the range might take wildly different paths through the tree of macro expansions. It was assuming that the begin spelling location would always precede the end spelling location, which is false. A macro can easily transpose its arguments. This also fixes a related issue where there are extra macro arguments between the begin location and the end location. In this situation, we now highlight the entire macro invocation. Pair programmed with Richard Smith. Fixes PR12818. llvm-svn: 254981
* 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
* Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren2015-10-031-3/+3
| | | | | | SourceLocation.isValid(). llvm-svn: 249228
* Improve the printing of ranges when macros are involved.Richard Trieu2015-09-241-28/+81
| | | | | | | | | | | | Trace the ranges through the macro backtrace better. This allows better range highlighting through all levels of the macro bracktrace. Also some improvements to backtrace printer for omitting different backtraces. Patch by Zhengkai Wu. Differential Revision: http://reviews.llvm.org/D12379 llvm-svn: 248454
* Fix macro backtrace printing.Richard Trieu2015-08-271-8/+14
| | | | | | | | Sometimes, a macro that expands to another macro name will not be printed in the macro backtrace. This patch finds the missed macro expansions and prints them. Fixes PR16799 llvm-svn: 246237
* Stop printing macro backtraces that don't help diagnostics.Richard Trieu2015-08-121-0/+39
| | | | | | | | | | | | | | | When displaying the macro backtrace, ignore some of the backtraces that do not provide extra information to the diagnostic. Typically, if the problem is entirely contained within a macro argument, the macro expansion is often not needed. Also take into account SourceRange's attached to the diagnostic when selecting which backtraces to ignore. Two previous test cases have also been updated. Patch by Zhengkai Wu, with minor formatting fixes. Differential Revision: http://reviews.llvm.org/D11778 llvm-svn: 244788
* [modules] Properly diagnose errors in module files for which we have noRichard Smith2015-08-111-6/+7
| | | | | | corresponding include location (those specified on the command line). llvm-svn: 244538
* Use an iterative method instead of recursion for printing macro backtraces.Richard Trieu2015-07-281-54/+63
| | | | | | | | | | | | Store the locations for a macro expansion in a vector, then iterate over them instead of using recursion. This simplifies the logic around the backtrace limit and gives easier access to the source locations. No functionality change. Patch by Zhengkai Wu. Differential Revision: http://reviews.llvm.org/D11542 llvm-svn: 243477
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-1/+1
| | | | | | just letting them be implicitly created. llvm-svn: 216528
* Add a missing close quote in "while building module 'Foo:" diagnostic.Jordan Rose2014-07-261-1/+1
| | | | | | | This isn't a real diagnostic kind, only a location note, and this form isn't even used if the SourceManager can provide a valid presumed location. But still. llvm-svn: 214002
* DiagnosticRenderer: emit basic notes as real diagnosticsAlp Toker2014-06-211-5/+6
| | | | | | | Fixes terminal column wrapping and vestigial 'note:' prefixes that would appear when using emitBasicNote(). llvm-svn: 211448
* [C++11] Use 'nullptr'. Frontend edition.Craig Topper2014-05-221-2/+2
| | | | llvm-svn: 209389
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-131-2/+2
| | | | | | class. llvm-svn: 203758
* When building a module from the command line via -emit-module, add an entry toRichard Smith2014-03-051-2/+5
| | | | | | | the module build stack for the module being built, so we can correctly detect recursive module builds. llvm-svn: 203006
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-3/+2
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-1/+1
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* DiagnosticRenderer.cpp: Prune one description in ↵NAKAMURA Takumi2012-12-241-1/+0
| | | | | | | | DiagnosticRenderer::emitMacroExpansions(). [-Wdocumentation] /// \param MacroSkipEnd The depth to stop skipping macro expansions. llvm-svn: 171012
* Simplify logic to use SourceManager::getFileLoc(), per Argyrios's feedback.Ted Kremenek2012-12-191-4/+2
| | | | llvm-svn: 170487
* More conservative fix for <rdar://problem/12847524> (a crash printing ↵Eli Friedman2012-12-181-0/+7
| | | | | | | | diagnostic ranges). I'm not really happy with this fix, but I'm confident it's correct. llvm-svn: 170397
* Revert 170049 because it fails with an assertion on one of the spec2000 ↵Nadav Rotem2012-12-131-72/+24
| | | | | | workloads. llvm-svn: 170143
* More hacking on mapDiagnosticRanges to make it handle more cases.Eli Friedman2012-12-131-24/+72
| | | | | | | | | | | | | | | | | | | | | | | | This still isn't quite right, but it fixes a crash. I factored out findCommonParent because we need it on the result of getImmediateExpansionRange: for a function macro, the beginning and end of an expansion range can come out of different macros/macro arguments, which means the resulting range is a complete mess to handle consistently. I also made some changes to how findCommonParent works; it works somewhat better in some cases, and somewhat worse in others, but I think overall it's a better balance. I'm coming to the conclusion that mapDiagnosticRanges isn't using the right algorithm, though: chasing the caret is fundamentally more complicated than any algorithm which only considers one FileID for the caret can handle because each SourceLocation doesn't really have a single parent. We need to follow the same path of choosing expansion locations and spelling locations which the caret used to come up with the correct range in the general case. Fixes <rdar://problem/12847524>. llvm-svn: 170049
* PR14049: Don't say "expanded from macro 'foo'" when 'foo' just happens to beRichard Smith2012-12-051-2/+10
| | | | | | | the LHS of a token paste. Use "expanded from here" instead when we're not sure it's actually a macro. llvm-svn: 169373
* Minor reorganization. No functionality change.Richard Smith2012-12-051-30/+30
| | | | llvm-svn: 169367
* Simplify slightly by seperating out the responsibility for emission of a caretRichard Smith2012-12-051-34/+42
| | | | | | | | diagnostic from the emission of macro backtraces. Incidentally, we now get the displayed source location for a diagnostic and the location for the caret from the same place, rather than computing them separately. No functionality change. llvm-svn: 169357
* Simplify diagnostic emission. No functionality change intended.Richard Smith2012-12-051-20/+19
| | | | llvm-svn: 169351
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-5/+5
| | | | | | | | | | | | | 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
* Rename ModuleBuildPath -> ModuleBuildStack. Thanks, Dmitri!Douglas Gregor2012-11-301-10/+10
| | | | llvm-svn: 169045
* When we're emitting a diagnostic with a source location in an importedDouglas Gregor2012-11-301-8/+74
| | | | | | | | | | | | | | 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-1/+32
| | | | | | | | | 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
* Fix the computation of highlight ranges so we produce something sane whenEli Friedman2012-11-301-10/+30
| | | | | | | the beginning and end of the range are in different macro arguments. PR14399. llvm-svn: 168984
* Add -cc1 option -fno-diagnostics-use-presumed-location, a handy mode forRichard Smith2012-11-141-2/+2
| | | | | | | | | working with preprocessed testcases. This causes source locations in diagnostics to point at the spelling location instead of the presumed location, while still keeping the semantic effects of the line directives (entering and leaving system-header mode, primarily). llvm-svn: 168004
* Add a proper algorithm to compute accurate source ranges for diagnostics withEli Friedman2012-11-031-16/+60
| | | | | | | | | 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
* Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor2012-10-231-9/+9
| | | | | | | the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. llvm-svn: 166508
* Move a few static functions from DiagnosticRenderer.cpp into SourceManager.Matt Beaumont-Gay2012-06-181-71/+6
| | | | | | | | This simplifies the code a little bit, since these functions all took a SourceManager parameter and called a bunch of methods on it, and makes the functions available to other users. llvm-svn: 158676
* Fix an assertion hit when the serialized diagnostics writer receive a diagnosticArgyrios Kyrtzidis2012-05-101-21/+31
| | | | | | | | | | | | | | from the frontend when the location is invalid and the SourceManager null. Instead of keeping the SourceManager object in DiagnosticRenderer, propagate it to the calls accordingly (as reference when it is expected to not be null, or pointer when it may be null). This effectively makes DiagnosticRenderer not tied to a specific SourceManager, removing a hack from TextDiagnosticPrinter. rdar://11386874 llvm-svn: 156536
* Add new code migrator support for migrating existing Objective-C code to useTed Kremenek2012-03-061-0/+57
| | | | | | | | | | | the new Objective-C NSArray/NSDictionary/NSNumber literal syntax. This introduces a new library, libEdit, which provides a new way to support migration of code that improves on the original ARC migrator. We now believe that most of its functionality can be refactored into the existing libraries, and thus this new library may shortly disappear. llvm-svn: 152141
* Refactor DiagnosticRenderer and SDiagsRenderer to have some functionalityTed Kremenek2012-02-141-4/+27
| | | | | | | | | pulled into DiagnosticNoteRenderer, and common DiagnosticRenderer that assumes that all custom diagnostic messages are notes. Also extend DiagnosticRenderer to work with StoredDiagnostics in preparation for subsequent changes. llvm-svn: 150455
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-2/+2
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Fix -fmacro-backtrace-limit=0 to show the entire macro backtrace.Ted Kremenek2012-01-251-1/+2
| | | | llvm-svn: 148930
* Improve Lexer::getImmediateMacroName to take into account inner macrosArgyrios Kyrtzidis2012-01-231-1/+38
| | | | | | | | | of macro arguments. For "MAC1( MAC2(foo) )" and location of 'foo' token it would return "MAC1" instead of "MAC2". llvm-svn: 148704
* Refactor: Pull getImmediateMacroName() out of DiagnosticRenderer andAnna Zaks2012-01-181-30/+1
| | | | | | into Lexer and Preprocessor; making it widely available. llvm-svn: 148410
* Refactor 'TextDiagnostic' to have a parent class 'DiagnosticRenderer' which ↵Ted Kremenek2011-12-171-0/+297
handles the policy of how diagnostics are lowered/rendered, while TextDiagnostic handles the actual pretty-printing. This is a first part of reworking SerializedDiagnosticPrinter to use the same inclusion-stack/macro-expansion logic as TextDiagnostic. llvm-svn: 146819
OpenPOWER on IntegriCloud