Commit Graph

81 Commits

Author SHA1 Message Date
Alp Toker c726c367f4 Improve diagnostic mapping terminology
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
2014-06-10 09:31:37 +00:00
Alp Toker ed2c033b9b Show -Wdate-time in system headers
Anyone enabling this warning would expect to hear about all occurrences
including those in system headers that can cause non-reproducible builds.

To achieve this, rework ShowInSystemHeader to remove broken unused mapping code
that didn't make sense with a simpler and correct scheme.

llvm-svn: 210512
2014-06-10 06:09:00 +00:00
Craig Topper f1186c5a8f [C++11] Use 'nullptr'.
llvm-svn: 208280
2014-05-08 06:41:40 +00:00
Diego Novillo 829b170048 Add support for optimization reports.
Summary:
This patch adds a new flag -Rpass=. The flag indicates the name
of the optimization pass that should emit remarks stating when it
made a transformation to the code.

This implements the design I proposed in:

https://docs.google.com/document/d/1FYUatSjZZO-zmFBxjOiuOzAy9mhHA8hqdvklZv68WuQ/edit?usp=sharing

Other changes:
- Add DiagnosticIDs::isRemark(). Use it in printDiagnosticOptions to
  print "-R" instead of "-W" in the diagnostic message.

- In BackendConsumer::OptimizationRemarkHandler, get a SourceLocation
  object out of the file name, line and column number. Use that location
  in the call to Diags.Report().

- When -Rpass is used without debug info a note is emitted alerting
  the user that they need to use -gline-tables-only -gcolumn-info to
  get this information.

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3226

llvm-svn: 206401
2014-04-16 16:54:24 +00:00
Tobias Grosser 741602461d Add 'remark' diagnostic type in 'clang'
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-28 09:11:08 +00:00
Alp Toker 9e6d27d037 Update docstrings following the param name change in r200132
llvm-svn: 200137
2014-01-26 06:41:58 +00:00
Chandler Carruth 5553d0d4ca Sort all the #include lines with LLVM's utils/sort_includes.py which
encodes the canonical rules for LLVM's style. I noticed this had drifted
quite a bit when cleaning up LLVM, so wanted to clean up Clang as well.

llvm-svn: 198686
2014-01-07 11:51:46 +00:00
Alp Toker 61d41af46b Document the Message parameter of getCustomDiagID()
A lot of callers have been using this facility incorrectly.

llvm-svn: 197920
2013-12-23 21:00:35 +00:00
Alp Toker f6a24ce40f Fix a tranche of comment, test and doc typos
llvm-svn: 196510
2013-12-05 16:25:25 +00:00
Richard Smith adf3018125 Remove C++11ism.
llvm-svn: 194446
2013-11-12 02:58:11 +00:00
Richard Smith 16e1b07597 Rather than duplicating extension diagnostics to allow them to cause a
substitution failure, allow a flag to be set on the Diagnostic object,
to mark it as 'causes substitution failure'.

Refactor Diagnostic.td and the tablegen to use an enum for SFINAE behavior
rather than a bunch of flags.

llvm-svn: 194444
2013-11-12 02:41:45 +00:00
Craig Topper b78e9d9b2f Make getDiagnosticsInGroup helper method a static function in the cpp file and move the WarningOption struct into an anonymous namespace instead of clang namespace since it no longer needs to be forward declared in the header.
llvm-svn: 189569
2013-08-29 06:06:18 +00:00
Craig Topper da7cf8ab2b Move individual group name strings from the OptionTable into one big char array. Then only store offsets into it in the OptionTable. Saves about 4K from the clang binary and removes 400 relocation entries from DiagnosticIDs.o.
llvm-svn: 189568
2013-08-29 05:18:04 +00:00
Craig Topper a3891a7568 Reorder and shrink size of NameLen field in diagnostic group table. Shaves ~4K from clang binary.
llvm-svn: 189445
2013-08-28 06:01:10 +00:00
Craig Topper d80c17e060 Merge diagnostic group tables to reduce data size and relocation entries.
The individual group and subgroups tables are now two large tables. The option table stores an index into these two tables instead of pointers. This reduces the size of the options tabe since it doesn't need to store pointers. It also reduces the number of relocations needed.

My build shows this reducing DiagnosticsIDs.o and the clang binary by ~20.5K. It also removes ~400 relocation entries from DiagnosticIDs.o.

llvm-svn: 189438
2013-08-28 04:02:50 +00:00
Craig Topper ea6caba325 Replace 'unsigned short' with 'uint16_t' in a packed data structure for consistency with other fields and to be explicit about bit count.
llvm-svn: 186796
2013-07-21 21:56:18 +00:00
Craig Topper 31e71a3997 Revert r186649 because it wasn't unnecessary and add a comment.
llvm-svn: 186795
2013-07-21 18:58:40 +00:00
David Majnemer 38af2a2158 DiagnosticIDs: Forbid Diag ID from being valid
Diag ID is used throughout clang as a sentinel id meaning "this is an
invalid diagnostic id."  Confusingly, Diag ID maps to a valid, usable,
diagnostic id.  Instead, start diagnostic ids at ID one.

Incidently, remove an unused element from StaticDiagInfo.

llvm-svn: 186760
2013-07-20 07:15:15 +00:00
Craig Topper ed1236d041 Remove unnecessary IsFirst variable from debug codde in GetDiagInfo.
llvm-svn: 186649
2013-07-19 03:59:51 +00:00
Craig Topper e5ce831c7c Use llvm::array_lengthof to replace sizeof(array)/sizeof(array[0]).
llvm-svn: 186300
2013-07-15 03:38:40 +00:00
Stefanus Du Toit b331850194 Fix typos: [Dd]iagnosic -> [Dd]iagnostic
These all appear in comments or (ironically) diagnostics output.

llvm-svn: 176383
2013-03-01 21:41:22 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
Argyrios Kyrtzidis f86e8cced6 DiagnosticIds: Fix offset/ID calculation, no impact outside this code.
Patch by Will Dietz:

Minor touchup so the values of Offset/ID reflect their intention.
Previously, the sum (Offset+ID) was correct, but Offset/ID
individually were wrong.

Caught by investigating unsigned overflow reported by -fsanitize=integer.

llvm-svn: 171421
2013-01-02 22:26:07 +00:00
Benjamin Kramer 256f1dd0fc Speed up looking up static diagnostic infos.
Instead of doing a binary search over the whole diagnostic table (which weighs
a whopping 48k on x86_64), use the existing enums to compute the index in the
table. This avoids loading any unneeded data from the table and avoids littering
CPU caches with it. This code is in a hot path for code with many diagnostics.

1% speedup on -fsyntax-only gcc.c, which emits a lot of warnings.

llvm-svn: 169890
2012-12-11 18:00:22 +00:00
DeLesley Hutchins 8ecd491e75 Fix analysis based warnings so that all warnings are emitted when compiling
with -Werror.  Previously, compiling with -Werror would emit only the first
warning in a compilation unit, because clang assumes that once an error occurs,
further analysis is unlikely to return valid results.  However, warnings that
have been upgraded to errors should not be treated as "errors" in this sense.

llvm-svn: 169649
2012-12-07 22:53:48 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
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-04 09:13:33 +00:00
Daniel Jasper d2e6f65b1b Set Diag.ErrorOccurred even if a DiagnosticConsumer does not want it in
diagnostic count.

If a DiagnosticConsumer sub-class overwrites IncludeInDiagnosticCounts,
this should change diagnostic counts. However, it currently also
influences Diag.ErrorOccurred, which in turn influences the behavior of
parsing and semantic analysis (in a way that can make it crash).

llvm-svn: 164824
2012-09-28 15:45:07 +00:00
Dmitri Gribenko f26054f0fb Enable comment parsing and semantic analysis to emit diagnostics. A few
diagnostics implemented -- see testcases.

I created a new TableGen file for comment diagnostics,
DiagnosticCommentKinds.td, because comment diagnostics don't logically
fit into AST diagnostics file.  But I don't feel strongly about it.

This also implements support for self-closing HTML tags in comment
lexer and parser (for example, <br />).

In order to issue precise diagnostics CommentSema needs to know the
declaration the comment is attached to.  There is no easy way to find a decl by 
comment, so we match comments and decls in lockstep: after parsing one
declgroup we check if we have any new, not yet attached comments.  If we do --
then we do the usual comment-finding process.

It is interesting that this automatically handles trailing comments.
We pick up not only comments that precede the declaration, but also
comments that *follow* the declaration -- thanks to the lookahead in
the lexer: after parsing the declgroup we've consumed the semicolon
and looked ahead through comments.

Added -Wdocumentation-html flag for semantic HTML errors to allow the user to 
disable only HTML warnings (but not HTML parse errors, which we emit as
warnings in -Wdocumentation).

llvm-svn: 160078
2012-07-11 21:38:39 +00:00
Jordan Rose 6f524ac9f0 Emit -verify diagnostics even when we have a fatal error.
Previously we'd halt at the fatal error as expected, but not actually emit
any -verify-related diagnostics. This lets us catch cases that emit a
/different/ fatal error from the one we expected.

This is implemented by adding a "force emit" mode to DiagnosticBuilder, which
will cause diagnostics to immediately be emitted regardless of current
suppression. Needless to say this should probably be used /very/ sparingly.

Patch by Andy Gibbs! Tests for all of Andy's -verify patches coming soon.

llvm-svn: 160053
2012-07-11 16:50:36 +00:00
Ted Kremenek f7639e1b4a Add new code migrator support for migrating existing Objective-C code to use
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
2012-03-06 20:06:33 +00:00
David Blaikie af90ec11e1 Provide common include for all diagnostic headers.
Reviewed by Ted Kremenek.

llvm-svn: 150616
2012-02-15 21:58:34 +00:00
Benjamin Kramer a8cafe23e3 Store the warning option corresponding to a diagnostics as an index into the option table instead of storing the name.
Another 8 bytes + relocation removed from every diagnostic on x86_64.

llvm-svn: 150615
2012-02-15 20:57:03 +00:00
David Blaikie 040a3a28f1 Remove the unuseful -fdiagnostics-show-name
This option was added in r129614 and doesn't have any use case that I'm aware
of. It's possible that external tools are using these names - and if that's
the case we can certainly reassess the functionality, but for now it lets us
shave out a few unneeded bits from clang.

Move the "StaticDiagNameIndex" table into the only remaining consumer, diagtool.
This removes the actual diagnostic name strings from clang entirely.

Reviewed by Chris Lattner & Ted Kremenek.

llvm-svn: 150612
2012-02-15 19:45:34 +00:00
Benjamin Kramer 3edb3b4ac5 Kill the brief and full explanation fields from StaticDiagInfoRec. They were unused and wasted space for nothing.
- per PR11952.

llvm-svn: 150199
2012-02-09 19:38:26 +00:00
Argyrios Kyrtzidis de044e5bb8 Change the fixed array of FixitHints to a SmallVector to lift off
the limit on the number of fixits.

llvm-svn: 149676
2012-02-03 05:58:22 +00:00
Argyrios Kyrtzidis 9ffada97ce Due to a bug, -Wno-everything works like -Weverything. Fix the bug by having
-Wno-everything remap all warnings to ignored.

We can now use "-Wno-everything -W<warning>" to ignore all warnings except
specific ones.

llvm-svn: 149121
2012-01-27 06:15:43 +00:00
David Blaikie f47fa304a4 Remove unnecessary default cases in switches over enums.
This allows -Wswitch-enum to find switches that need updating when these enums are modified.

llvm-svn: 148281
2012-01-17 02:30:50 +00:00
Chandler Carruth 22a11b7248 Separate the serialization library's diagnostics from the frontend's
diagnostics. Conflating them was highly confusing and makes it harder to
establish a firm layering separation between these two libraries.

llvm-svn: 146207
2011-12-09 00:02:23 +00:00
Daniel Dunbar 787032b88e Fix some possible gcc-4.2 may be used uninitialized warnings.
llvm-svn: 145293
2011-11-28 22:19:36 +00:00
Benjamin Kramer 176a5cb38a Warning option typo correction: When two options have the same edit_distance don't display either.
Also add a maximum edit distance threshold, so we don't correct "-Wx" to "-W#pragma-messages".

llvm-svn: 144644
2011-11-15 12:26:39 +00:00
Benjamin Kramer 116d8879e6 Print a typo correction hint for unknown warning flags.
$ clang -Wololo t.c
warning: unknown warning option '-Wololo'; did you mean '-Wall'? [-Wunknown-warning-option]

llvm-svn: 144591
2011-11-14 23:30:34 +00:00
Ted Kremenek 337c5b880c Further refine the diagnostic categories for ARC diagnostics. Addresses <rdar://problem/10245086>.
llvm-svn: 142571
2011-10-20 05:07:47 +00:00
Bob Wilson 73a4deb33d Change __extension__ to disable only diagnostics controlled by -pedantic.
This changes clang to match GCC's behavior for __extension__, which temporarily
disables the -pedantic flag.  Warnings that are enabled without -pedantic
are not affected.  Besides the general goodness of matching GCC's precedent,
my motivation for this is that macros in the arm_neon.h header need to use
__extension__ to avoid pedantic complaints about their use of statement
expressions, yet we still want to warn about incompatible pointer arguments
for those macros.

llvm-svn: 141804
2011-10-12 19:55:31 +00:00
Daniel Dunbar 866fcd34a6 Basic/Diagnostic: Kill off a few unnecessary functions now that refactoring is done, and add a note that the new setDiagnosticGroup{...} methods only operate on the current diagnostic state.
llvm-svn: 140771
2011-09-29 02:03:01 +00:00
Daniel Dunbar 58d0af6c5f Basic/Diagnostics: Rewrite DiagnosticIDs::getDiagnosticLevel completely to be straighter line code, use the new DiagnosticMappingInfo flags, and eliminate the odd MAP_WARNING_NO_WERROR and friend mappings.
- This fixes a host of obscure bugs with regards to how warning mapping options composed with one another, and I believe makes the code substantially easier to read and reason about.

llvm-svn: 140770
2011-09-29 01:58:05 +00:00
Daniel Dunbar fffcf21cf2 Basic/Diagnostics: Add three explicit bits to DiagnosticMappingInfo to track "no-warning-as-error", "no-error-as-fatal", and "show-in-system-header", and update DiagnosticsEngine::setDiagnosticGroup{WarningAsError,ErrorAsFatal} and GetDefaultDiagMappingInfo to set them appropriately.
- No actual functionality change for now, we still also use the diag::Mapping::{MAP_WARNING_NO_ERROR,MAP_ERROR_NO_FATAL,MAP_WARNING_SHOW_IN_SYSTEM_HEADER} for a little while longer.

llvm-svn: 140768
2011-09-29 01:52:06 +00:00
Daniel Dunbar d908c12db8 Basic/Diagnostics: Add a DiagnosticIDs::getDiagnosticsInGroup method, and use
that in DiagnosticEngine instead of the convoluted calling into DiagnosticIDs
which then calls back into the DiagnosticsEngine.

llvm-svn: 140766
2011-09-29 01:47:16 +00:00
Daniel Dunbar e8c12a2979 Basic/Diagnostic: Add a DiagSate::getOrAddMappingInfo method.
- Also, spell const_iterator as const_iterator.

llvm-svn: 140765
2011-09-29 01:42:25 +00:00
Daniel Dunbar a3637e6894 Basic/Diagnostics: Add a DiagnosticMappingInfo helper class, and switch to
storing mappings with that instead of straying some magic constants about the
source.

llvm-svn: 140760
2011-09-29 01:30:00 +00:00
Daniel Dunbar 9c78496d51 Basic/Diagnostics: Eliminate getDiagnosticMappingInfo method, which wasn't worth methodizing.
llvm-svn: 140759
2011-09-29 01:25:14 +00:00