Commit Graph

60 Commits

Author SHA1 Message Date
Chris Lattner 2d49eed816 optimize and comment GetDiagInfo.
llvm-svn: 69273
2009-04-16 06:13:46 +00:00
Chris Lattner 6c440329f1 merge several scattered tables into StaticDiagInfo.
llvm-svn: 69272
2009-04-16 06:07:15 +00:00
Chris Lattner 6a64cc6776 Implement Diagnostic::getWarningOptionForDiag with information from tblgen,
this implements -fdiagnostics-show-option in clang-cc.

llvm-svn: 69271
2009-04-16 06:00:24 +00:00
Chris Lattner a538967177 tblgen is now passing diagnostic group information in the .inc file, ignore it everywhere.
llvm-svn: 69269
2009-04-16 05:52:14 +00:00
Chris Lattner 22cb818913 implement framework for -fdiagnostics-show-option, but tblgen isn't
passing down the right info yet.

llvm-svn: 69268
2009-04-16 05:44:38 +00:00
Chris Lattner b8e73158e1 move handling of -pedantic and -pedantic-errors into Diagnostics,
out of Warnings.cpp.  This simplifies warnings.cpp and makes it more
efficient.

llvm-svn: 69266
2009-04-16 05:04:32 +00:00
Chris Lattner f9150bac01 arrange for -Wno-error=foo warnings to be immune to -Werror as
they are supposed to be.

llvm-svn: 69265
2009-04-16 04:32:54 +00:00
Chris Lattner 411c0ffe5d change mappings to distinguish between "unset", "set by the user" and
"set to the default value".

llvm-svn: 69264
2009-04-16 04:12:40 +00:00
Chris Lattner d9ecb8e279 fix some out of bounds array access problems, which manifest particularly
spectacularly when built for x86-64.

llvm-svn: 69197
2009-04-15 18:48:23 +00:00
Chris Lattner 2fe292076e move {'s
llvm-svn: 69179
2009-04-15 17:13:42 +00:00
Chris Lattner e6c831deb2 Make diagnostic class explicit in the diag record instead of
implicit from its parenting.  Now that diag mapping is 
explicit, eliminate the fatal and extwarn classes.

llvm-svn: 69177
2009-04-15 16:56:26 +00:00
Chris Lattner 1b595624a8 Tblgen now passes the default mapping explicitly, instead of having it
be tied to the diag class.  This requires an LLVM tree update.

llvm-svn: 69175
2009-04-15 16:44:12 +00:00
Chris Lattner e007de3b9a Rejigger how -pedantic and -pedantic-errors work and their interaction
with other diagnostic mapping.  In the new scheme, -Wfoo or -Wno-foo or 
-Werror=foo all override the -pedantic options, and __extension__ 
robustly silences all extension diagnostics in their scope.

An added bonus of this change is that MAP_DEFAULT goes away, meaning that
per-diagnostic mapping information can now be stored in 2 bits, doubling
the density of the Diagnostic::DiagMapping array.  This also 
substantially simplifies Diagnostic::getDiagnosticLevel.

OTOH, this temporarily introduces some "macro intensive" code in 
Diagnostic.cpp.  This will be addressed in a later patch.

llvm-svn: 69154
2009-04-15 07:01:18 +00:00
Douglas Gregor da17bd34e7 Eliminate post-diagnostic hooks. Instead, implement a Sema-specific
variant of DiagnosticBuilder that emits the template instantiation
backtrace when needed.

llvm-svn: 67413
2009-03-20 22:48:49 +00:00
Sebastian Redl 90b6edda75 Bindir and Win32 builds work, so switch to .inc files. Leave the .def files in the tree for a day or so longer.
llvm-svn: 67346
2009-03-19 23:18:26 +00:00
Douglas Gregor 19367f54e2 Allow notes to be printed following a fatal error, then suppress any
diagnostics following those notes. 

Make exceeding the template instantiation depth a fatal error.

Thanks to Daniel for pointing out the problem!

llvm-svn: 67320
2009-03-19 18:55:06 +00:00
Sebastian Redl 4ae9b126fe Revert the switch to the tablegen diags. It fails for seperate objdir builds and cmake builds, and I have no clue what to do about it. Revisit this after someone with a clue about the build systems has looked at it.
llvm-svn: 67009
2009-03-14 15:58:54 +00:00
Sebastian Redl 51e037e3c4 Switch diagnostics from .def to tablegen files. Please validate the Windows build.
llvm-svn: 67007
2009-03-14 12:00:12 +00:00
Daniel Dunbar 4f495980c4 Add Diagnostic files for Frontend and move a couple errors over.
- Notably, clang now exits with an error if it can't find a
   file. This flushed out a bug in the CGColorSpace.c test case. :)

llvm-svn: 66789
2009-03-12 10:14:16 +00:00
Daniel Dunbar c0b3e95a1a Driver: Use standard Diagnostic interface for diagnostics.
llvm-svn: 66786
2009-03-12 08:55:43 +00:00
Douglas Gregor 4ea568f213 Add a notion of "post-diagnostic hooks", which are callbacks attached
to a diagnostic that will be invoked after the diagnostic (if it is
not suppressed). The hooks are allowed to produce additional
diagnostics (typically notes) that provide more information. We should
be able to use this to help diagnostic clients link notes back to the
diagnostic they clarify. Comments welcome; I'll write up documentation
and convert other clients (e.g., overload resolution failures) if
there are no screams of protest.

As the first client of post-diagnostic hooks, we now produce a
template instantiation backtrace when a failure occurs during template
instantiation. There's still more work to do to make this output
pretty, if that's even possible.

llvm-svn: 66557
2009-03-10 18:03:33 +00:00
Ted Kremenek 22988cf493 Revert my last couple patches until I can get them to not make the tests fail.
llvm-svn: 66317
2009-03-07 01:47:10 +00:00
Ted Kremenek a44b4f987c Teach Diagnostic about Selector.
llvm-svn: 66314
2009-03-07 01:36:13 +00:00
Chris Lattner cf868c458c replace a dirty hack with a clean solution. Too bad we can't
use Blocks for our callbacks ;-)

llvm-svn: 65083
2009-02-19 23:53:20 +00:00
Chris Lattner 810d330cd3 Fix a long standard problem with clang retaining "too much" sugar
information about types.  We often print diagnostics where we say 
"foo_t" is bad, but the user doesn't know how foo_t is declared 
(because it is a typedef).  Fix this by expanding sugar when present
in a diagnostic (and not one of a few special cases, like vectors).

Before:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' and 'typeof(F)')
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                             ^

After:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                             ^

llvm-svn: 65081
2009-02-19 23:45:49 +00:00
Chris Lattner 9ee10ea535 fix a minor bug with my previous patch
llvm-svn: 64747
2009-02-17 06:52:20 +00:00
Chris Lattner d2a2c13474 fix notes so that they are always filtered with the same logic
as the last non-note diagnostic that preceeded them.  This ensures
that diagnostics in main files which have notes with locations in 
system headers get all the bits and pieces emitted or not in a 
unit.  This fixes PR3215.

llvm-svn: 64746
2009-02-17 06:49:55 +00:00
Chris Lattner 9e03119446 don't emit any diagnostics after a fatal one.
llvm-svn: 63914
2009-02-06 04:16:02 +00:00
Chris Lattner fbe2272fc8 add support to the diagnostics machinery for mapping warnings and
errors to 'fatal' error severity.

llvm-svn: 63894
2009-02-05 22:47:05 +00:00
Douglas Gregor 2ada048975 Some name-lookup-related fixes, from Piotr Rak!
- Changes Lookup*Name functions to return NamedDecls, instead of
Decls. Unfortunately my recent statement that it will simplify lot of
code, was not quite right, but it simplifies some...
- Makes MergeLookupResult SmallPtrSet instead of vector, following
Douglas suggestions.
- Adds %qN format for printing qualified names to Diagnostic.
- Avoids searching for using-directives in Scopes, which are not
DeclScope, during unqualified name lookup.

llvm-svn: 63739
2009-02-04 17:27:36 +00:00
Chris Lattner 4b6713ef20 next round of diagnostics cleanups, moving some
diags around, eliminating #defines, etc.  Patch by
Anders Johnsen!

llvm-svn: 63318
2009-01-29 17:46:13 +00:00
Chris Lattner 36790cf29a Fix -Wimplicit-function-declaration, which required some refactoring and
changes in various diagnostics code.

llvm-svn: 63282
2009-01-29 06:55:46 +00:00
Chris Lattner 7368d581c1 Split the single monolithic DiagnosticKinds.def file into one
.def file for each library.  This means that adding a diagnostic
to sema doesn't require all the other libraries to be rebuilt.

Patch by Anders Johnsen!

llvm-svn: 63111
2009-01-27 18:30:58 +00:00
Ted Kremenek ea06ec1cad Added virtual method DiagnosticClient::IncludeInDiagnosticCounts(). This is used by Diagnostics to determine if a diagnostic sent to a given DiagnosticClient should be included in the count of diagnostics. The default implementation of this method returns 'true'.
Implemented DiagCollector::IncludeInDiagnosticCounts() to return 'false' so that the batching of diagnostics for use with BugReporter doesn't mess up the count of real diagnostics.

llvm-svn: 62873
2009-01-23 20:28:53 +00:00
Chris Lattner 53e384f633 Change some terminology in SourceLocation: instead of referring to
the "physical" location of tokens, refer to the "spelling" location.
This is more concrete and useful, tokens aren't really physical objects!

llvm-svn: 62309
2009-01-16 07:00:02 +00:00
Sebastian Redl 3ceaf62240 Fix order of evaluation.
llvm-svn: 60160
2008-11-27 07:28:14 +00:00
Chris Lattner e3d20d9545 Convert IdentifierInfo's to be printed the same as DeclarationNames
with implicit quotes around them.  This has a bunch of follow-on 
effects and requires tweaking to a whole lot of code.  This causes
a regression in two tests (xfailed) by causing it to emit things like:

  Line 10: duplicate interface declaration for category 'MyClass1' ('Category1')

instead of:

  Line 10: duplicate interface declaration for category 'MyClass1(Category1)'

I will fix this in a follow-up commit.

As part of this, I had to start switching stuff to use ->getDeclName() instead
of Decl::getName() for consistency.  This is good, but I was planning to do this
as an independent patch.  There will be several follow-on patches
to clean up some of the mess, but this patch is already too big.

llvm-svn: 59917
2008-11-23 21:45:46 +00:00
Chris Lattner f7e69d5a77 add support for inserting a DeclarationName into a diagnostic directly
without calling getAsString().  This implicitly puts quotes around the
name, so diagnostics need to be tweaked to accommodate this.

llvm-svn: 59916
2008-11-23 20:28:15 +00:00
Chris Lattner 63ecc509e3 Genericize the qualtype formating callback to support any diag argument.
No functionality change.

llvm-svn: 59908
2008-11-23 09:21:17 +00:00
Chris Lattner 6a2ed6f6dc Add support for sending QualType's directly into diags and convert two
diags over to use this.  QualTypes implicitly print single quotes around 
them for uniformity and future extension.

Doing this requires a little function pointer dance to prevent libbasic
from depending on libast.

llvm-svn: 59907
2008-11-23 09:13:29 +00:00
Sebastian Redl 15b02d2e62 Implement a %plural modifier for complex plural forms in diagnostics. Use it in the overload diagnostics.
llvm-svn: 59871
2008-11-22 13:44:36 +00:00
Chris Lattner 427c9c1763 Split the DiagnosticInfo class into two disjoint classes:
one for building up the diagnostic that is in flight (DiagnosticBuilder)
and one for pulling structured information out of the diagnostic when
formatting and presenting it.

There is no functionality change with this patch.

llvm-svn: 59849
2008-11-22 00:59:29 +00:00
Chris Lattner 2b78690a9c Add the concept of "modifiers" to the clang diagnostic format
strings.  This allows us to have considerable flexibility in how
these things are displayed and provides extra information that
allows us to merge away diagnostics that are very similar.

Diagnostic modifiers are a string of characters with the regex
[-a-z]+ that occur between the % and digit.  They may 
optionally have an argument that can parameterize them.

For now, I've added two example modifiers.  One is a very useful
tool that allows you to factor commonality across diagnostics
that need single words or phrases combined.  Basically you can
use %select{a|b|c}4 with with an integer argument that selects
either a/b/c based on an integer value in the range [0..3).

The second modifier is also an integer modifier, aimed to help
English diagnostics handle plurality.  "%s3" prints to 's' if 
integer argument #3 is not 1, otherwise it prints to nothing.
I'm fully aware that 's' is an English concept and doesn't
apply to all situations (mouse vs mice).  However, this is very
useful and we can add other crazy modifiers once we add support
for polish! ;-)

I converted a couple C++ diagnostics over to use this as an
example, I'd appreciate it if others could merge the other
likely candiates.  If you have other modifiers that you want,
lets talk on cfe-dev.

llvm-svn: 59803
2008-11-21 07:50:02 +00:00
Chris Lattner b91fd17b7d Allow sending IdentifierInfo*'s into Diagnostics without turning them into strings
first.  This should allow removal of a bunch of II->getName() calls.

llvm-svn: 59601
2008-11-19 07:32:16 +00:00
Chris Lattner 91aea716c6 add direct support for signed and unsigned integer arguments to diagnostics.
llvm-svn: 59598
2008-11-19 07:22:31 +00:00
Chris Lattner 23be067407 rewrite FormatDiagnostic to be less gross and a lot more efficient.
This also makes it illegal to have bare '%'s in diagnostics.  If you
want a % in a diagnostic, use %%.

llvm-svn: 59596
2008-11-19 06:51:40 +00:00
Chris Lattner 8d5bec4c7d implement a transparent optimization with the diagnostics stuff:
const char*'s are now not converted to std::strings when the diagnostic
is formed, we just hold onto their pointer and format as needed.

This commit makes DiagnosticClient::FormatDiagnostic even more of a 
mess, I'll fix it in the next commit.

llvm-svn: 59593
2008-11-19 06:04:55 +00:00
Chris Lattner 8488c8297c This reworks some of the Diagnostic interfaces a bit to change how diagnostics
are formed.  In particular, a diagnostic with all its strings and ranges is now
packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a 
ton of random stuff.  This has the benefit of simplifying the interface, making
it more extensible, and allowing us to do more checking for things like access
past the end of the various arrays passed in.

In addition to introducing DiagnosticInfo, this also substantially changes how 
Diagnostic::Report works.  Instead of being passed in all of the info required
to issue a diagnostic, Report now takes only the required info (a location and 
ID) and returns a fresh DiagnosticInfo *by value*.  The caller is then free to
stuff strings and ranges into the DiagnosticInfo with the << operator.  When
the dtor runs on the DiagnosticInfo object (which should happen at the end of
the statement), the diagnostic is actually emitted with all of the accumulated
information.  This is a somewhat tricky dance, but it means that the 
accumulated DiagnosticInfo is allowed to keep pointers to other expression 
temporaries without those pointers getting invalidated.

This is just the minimal change to get this stuff working, but this will allow
us to eliminate the zillions of variant "Diag" methods scattered throughout
(e.g.) sema.  For example, instead of calling:

  Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
       SourceRange(BuiltinLoc, RParenLoc));

We will soon be able to just do:

  Diag(BuiltinLoc, diag::err_overload_no_match)
      << typeNames << SourceRange(BuiltinLoc, RParenLoc));

This scales better to support arbitrary types being passed in (not just 
strings) in a type-safe way.  Go operator overloading?!

llvm-svn: 59502
2008-11-18 07:04:44 +00:00
Chris Lattner 16ba91396a Change the diagnostics interface to take an array of pointers to
strings instead of array of strings.  This reduces string copying
in some not-very-important cases, but paves the way for future 
improvements.

llvm-svn: 59494
2008-11-18 04:56:44 +00:00
Chris Lattner e6de6252c2 Fix PR3077: tokens that come from macro expansions whose macro was
defined in a system header should be treated as system header tokens
even if they are instantiated in a different place.

llvm-svn: 59418
2008-11-16 18:36:34 +00:00