Commit Graph

197 Commits

Author SHA1 Message Date
David Blaikie 5fa05fc438 Make -Wshift-op-parentheses a subgroup of -Wparentheses
llvm-svn: 165653
2012-10-10 20:30:36 +00:00
Rafael Espindola fc3fc0c936 The clang driver has a fairly fancy support for executing gcc instead of
clang itself. This dates back to clang's early days and while it looks like
some of it is still used (for kext for example), other parts are probably dead.

Remove the -ccc-clang-archs option and associated code. I don't think there
is any remaining setup where clang doesn't support an architecture but it can
expect an working gcc cross compiler to be available.

A nice side effect is that tests no longer need to differentiate architectures
that are included in production builds of clang and those that are not.

llvm-svn: 165545
2012-10-09 20:46:28 +00:00
Ted Kremenek 40a69600af Add regression test to check if -Wenum-conversion is a subgroup of -Wconversion.
llvm-svn: 165459
2012-10-08 23:45:09 +00:00
Eli Friedman 68be1649ee Permanently end the whole "pragma got handled by the parser too early"
mess by handling all pragmas which the parser touches uniformly.
<rdar://problem/12248901>, etc.

llvm-svn: 165195
2012-10-04 02:36:51 +00:00
Richard Trieu b7243855d9 Update template type diffing to handle qualifiers. Differing qualifiers will
now be printed with highlighting.

llvm-svn: 164843
2012-09-28 20:32:51 +00:00
Richard Smith 6e0605d654 Teach Type::getAs<TemplateSpecializationType> that a TemplateSpecializationType
for a type alias template can appear as sugar at any level of desugaring, just
like a TypedefType.

llvm-svn: 164655
2012-09-26 02:18:13 +00:00
Richard Smith b6d516e7bd PR13881: Add -Wzero-length-array for zero length array extension, and move it into -Wgnu.
llvm-svn: 164272
2012-09-20 01:02:05 +00:00
Douglas Gregor 43bc036e8a Promote the warning about extra qualification on a declaration from a
warning to an error. C++ bans it, and both GCC and EDG diagnose it as
an error. Microsoft allows it, so we still warn in Microsoft
mode. Fixes <rdar://problem/11135644>.

llvm-svn: 163831
2012-09-13 20:16:20 +00:00
Richard Smith 659d38bcd5 Use a "better" unicode character, to avoid buildbot breakage on bots which can print some unicode characters.
llvm-svn: 163825
2012-09-13 19:10:51 +00:00
Richard Smith fab4b1a40c Make TextDiagnostic more robust against SourceLocations which point into the
middle of UTF-8 characters, and avoid walking to such positions when adjusting
column ranges for display. Fixes a couple of hangs when rendering diagnostics.

llvm-svn: 163820
2012-09-13 18:37:50 +00:00
Richard Smith 639b8d05dd When a bad UTF-8 encoding or bogus escape sequence is encountered in a
string literal, produce a diagnostic pointing at the erroneous character
range, not at the start of the literal.

llvm-svn: 163459
2012-09-08 07:16:20 +00:00
Aaron Ballman 3731b33009 Splitting the duplicated decl spec extension warning into two: one is an ExtWarn and the other a vanilla warning. This addresses PR13705, where const char const * wouldn't warn unless -pedantic was specified under the right conditions.
llvm-svn: 162793
2012-08-28 20:55:40 +00:00
Ted Kremenek 5d858cb916 Fix horrible regression in control of warnings caused by introduction of -Wpedantic.
While -Wpedantic was reasonable, -Wno-pedantic would turn off a bunch of warnings that
are on by default.  This counters the intention of this warning flag.

To fix this, -Wpedantic now includes extentions that are not on by default.  The
remaining warnings will manifest anyway, and won't accidentally get turned off
by -Wno-pedantic.

Fixes <rdar://problem/12076105>

llvm-svn: 161695
2012-08-10 20:50:00 +00:00
Richard Smith 403f76ee02 PR13529: Don't crash if the driver sees an unused input file when running as
'clang-cpp'.

For now, the test uses "REQUIRES: shell" to determine if the host system
supports "ln -s", which it uses to create a 'clang-cpp' symlink. This is a bit
hacky and should likely be directly supported by lit.cfg.

llvm-svn: 161317
2012-08-06 04:09:06 +00:00
Ted Kremenek 2b619662ee Promote warn_unknown_analyzer_checker to an error. Addresses <rdar://problem/10987863>.
llvm-svn: 160706
2012-07-25 07:12:13 +00:00
Richard Smith 87f5dc53b2 Add diagnostics for comma at end of enum and for extra semicolon at namespace
scope to -Wc++11-extensions. Move extra semicolon after member function
definition diagnostic out of -pedantic, since C++ allows a single semicolon
there. Keep it in -Wextra-semi, though, since it's still questionable.

llvm-svn: 160618
2012-07-23 05:45:25 +00:00
Tanya Lattner 72db6d04e1 Move a bunch of the attribute warnings under the IgnoreAttributes group. Cleaned up test case.
llvm-svn: 160190
2012-07-13 20:45:35 +00:00
NAKAMURA Takumi b59973e6cd clang/test/Misc/diag-template-diffing-color.cpp: Introduce the feature 'ansi-escape-sequences'.
llvm-svn: 160043
2012-07-11 11:44:00 +00:00
Tanya Lattner 724eaea271 TEMPORARY. I will fix this properly shortly.
Silence buildbot so I can figure out the right flag to put this warning under.

llvm-svn: 159967
2012-07-09 23:01:07 +00:00
Ted Kremenek 30105f67b4 Enhance 'diagtool list-warnings' to report number of diagnostics covered directly under -Wpedantic, and enhance warning-flags.c test to test that this set does not grow.
llvm-svn: 159893
2012-07-07 06:30:31 +00:00
Ted Kremenek b22ea2acea Re-apply r159875 with fixes.
- Split pedantic driver flag test into separate test file, and XFAIL on cygwin,mingw32
- Fix bug in tablegen logic where a missing '{' caused errors to be included in -Wpedantic.

llvm-svn: 159892
2012-07-07 05:53:30 +00:00
NAKAMURA Takumi eec53e4069 Revert rr159875, "Implement -Wpedantic and --no-pedantic to complement -Weverything." It broke several builds.
I suspect FileCheck might match assertion failure, even if clang/test/Misc/warning-flags.c passed the test.

> 0. Program arguments: bin/./clang -### -pedantic -Wpedantic clang/test/Driver/warning-options.cpp

llvm-svn: 159886
2012-07-07 02:48:02 +00:00
Ted Kremenek 9877f689f2 Implement -Wpedantic and --no-pedantic to complement -Weverything.
This patch introduces some magic in tablegen to create a "Pedantic" diagnostic
group which automagically includes all warnings that are extensions.  This
allows a user to suppress specific warnings traditionally under -pedantic used
an ordinary warning flag.  This also allows users to use #pragma to silence
specific -pedantic warnings, or promote them to errors, within blocks of text
(just like any other warning).

-Wpedantic is NOT an alias for -pedantic.  Instead, it provides another way
to (a) activate -pedantic warnings and (b) disable them.  Where they differ
is that -pedantic changes the behavior of the preprocessor slightly, whereas
-Wpedantic does not (it just turns on the warnings).

The magic in the tablegen diagnostic emitter has to do with computing the minimal
set of diagnostic groups and diagnostics that should go into -Wpedantic, as those
diagnostics that already members of groups that themselves are (transitively) members
of -Wpedantic do not need to be included in the Pedantic group directly.  I went
back and forth on whether or not to magically generate this group, and the invariant
was that we always wanted extension warnings to be included in -Wpedantic "some how",
but the bookkeeping would be very onerous to manage by hand.

-no-pedantic (and --no-pedantic) is included for completeness, and matches many of the
same kind of flags the compiler already supports.  It does what it says: cancels out
-pedantic.  One discrepancy is that if one specifies --no-pedantic and -Weverything or
-Wpedantic the pedantic warnings are still enabled (essentially the -W flags win).  We
can debate the correct behavior here.

Along the way, this patch nukes some code in TextDiagnosticPrinter.cpp and CXStoredDiagnostic.cpp
that determine whether to include the "-pedantic" flag in the warning output.  This is
no longer needed, as all extensions now have a -W flag.

This patch also significantly reduces the number of warnings not under flags from 229
to 158 (all extension warnings).  That's a 31% reduction.

llvm-svn: 159875
2012-07-06 23:07:31 +00:00
Matt Beaumont-Gay f019075271 Add a warning flag for "'extern' variable has an initializer".
llvm-svn: 159600
2012-07-02 21:58:14 +00:00
Richard Trieu db96a42eba Fix typos from r159463 and update tests. Added Matt Beaumont-Gay's suggestion
to improve wording of a diagnostic message.

llvm-svn: 159473
2012-06-29 23:11:10 +00:00
Richard Trieu c605844510 Update the %diff modifer to have an alternate string print when a template tree
is selected.  This will allow more flexibility when converting diagnostics to
use template type diffing.

Also updated the internal manual and test cases for correctly keeping the bold
attribute and for tree printing.

llvm-svn: 159463
2012-06-29 21:12:16 +00:00
NAKAMURA Takumi e791a7ae36 clang/test/Misc/diag-template-diffing-color.cpp: Remove XFAIL:cygwin. Cygwin has some terminal emulation of escape sequences.
llvm-svn: 159428
2012-06-29 14:14:25 +00:00
David Blaikie 9e55d74074 Fix template type diffing coloring (r159216) when forcing color output to a file (not a terminal)
Reviewed (over the shoulder) by Richard Trieu.

llvm-svn: 159381
2012-06-28 21:46:07 +00:00
Matt Beaumont-Gay 1571652af9 Only print a semicolon after "no known conversion for Nth argument" if there
is a following clause.

llvm-svn: 159369
2012-06-28 19:20:41 +00:00
Richard Smith 608c0b65d7 Add warning flag -Winvalid-pp-token for preprocessing-tokens which have
undefined behaviour, and move the diagnostic for '' from an Error into
an ExtWarn in this group. This is important for some users of the preprocessor,
and is necessary for gcc compatibility.

llvm-svn: 159335
2012-06-28 07:51:56 +00:00
Richard Trieu 9184423984 Add template type diffing to Clang. This feature will provide a better
comparison between two templated types when they both appear in a diagnostic.
Type elision will remove indentical template arguments, which can be disabled
with -fno-elide-type.  Cyan highlighting is applied to the differing types.

For more formatting, -fdiagnostic-show-template-tree will output the template
type as an indented text tree, with differences appearing inline. Template
tree works with or without type elision.

llvm-svn: 159216
2012-06-26 18:18:47 +00:00
Fariborz Jahanian 513b3681de objc: adds diagnostic group to several old objc warnings.
// rdar://11741435 pr13184

llvm-svn: 159213
2012-06-26 17:47:42 +00:00
Jordan Rose 473e877c43 [diagtool] Add a new "tree" command to shows warnings activated by a flag.
% diagtool tree -Wunused-value
-Wunused-value
  -Wunused-comparison
    warn_unused_comparison
  -Wunused-result
    warn_unused_result
  warn_unused_call
  warn_unused_container_subscript_expr
  warn_unused_expr
  warn_unused_property_expr
  warn_unused_voidptr

llvm-svn: 159093
2012-06-24 00:07:45 +00:00
Richard Smith 19b02cd7fc Minor improvements to some C99 variadic-macro-related diagnostics.
llvm-svn: 159054
2012-06-22 23:59:08 +00:00
Jordan Rose b820709144 [diagtool] Write to llvm::outs() by default instead of llvm::errs()
llvm-svn: 158954
2012-06-22 00:33:20 +00:00
Kaelyn Uhrain 9ea8f7e6c5 Improve the error message when a function overload candidate is rejected
because it expects a reference and receives a non-l-value.

For example, given:

  int foo(int &);
  template<int x> void b() { foo(x); }

clang will now print "expects an l-value for 1st argument" instead of
"no known conversion from 'int' to 'int &' for 1st argument". The change
in wording (and associated code to detect the case) was prompted by
comment #5 in PR3104, and should be the last bit of work needed for the
bug.

llvm-svn: 158691
2012-06-19 00:37:47 +00:00
Richard Trieu 5767093dce Add triples to keep make test work on Windows, where wchar_t is only 16
bits wide.

llvm-svn: 158425
2012-06-13 23:15:33 +00:00
Richard Trieu bc4b4ba5de Remove unnecessary output redirection in a test.
llvm-svn: 158424
2012-06-13 22:31:48 +00:00
Richard Trieu dc3559106b Moved the StringLiteral printing code from StmtPrinter into the StringLiteral
class and have StmtPrinter and StmtDumper refer to it.  This fixes an
assertion failure when dumping wchar string literals.

llvm-svn: 158417
2012-06-13 20:25:24 +00:00
Jordan Rose de1a29277e Disable _Pragma during HTML macro rewriting to keep from crashing.
The preprocessor's handling of diagnostic push/pops is stateful, so
encountering pragmas during a re-parse causes problems. HTMLRewrite
already filters out normal # directives including #pragma, so it's
clear it's not expected to be interpreting pragmas in this mode.

This fix adds a flag to Preprocessor to explicitly disable pragmas.
The "right" fix might be to separate pragma lexing from pragma
parsing so that we can throw away pragmas like we do preprocessor
directives, but right now it's important to get the fix in.

Note that this has nothing to do with the "hack" of re-using the
input preprocessor in HTMLRewrite. Even if we someday copy the
preprocessor instead of re-using it, the copy would (and should) include
the diagnostic level tables and have the same problems.

llvm-svn: 158214
2012-06-08 18:06:21 +00:00
Jordan Rose ccf43ca05c Add pedantic warning -Wempty-translation-unit (C11 6.9p1).
In standard C since C89, a 'translation-unit' is syntactically defined to have
at least one "external-declaration", which is either a decl or a function
definition. In Clang the latter gives us a declaration as well.

The tricky bit about this warning is that our predefines can contain external
declarations (__builtin_va_list and the 128-bit integer types). Therefore our
AST parser now makes sure we have at least one declaration that doesn't come
from the predefines buffer.

Also, remove bogus warning about empty source files. This doesn't catch source
files that only contain comments, and never fired anyway because of our
predefines.

PR12665 and <rdar://problem/9165548>

llvm-svn: 158085
2012-06-06 17:25:21 +00:00
Jordan Rose 2fe20dca2a [diagtool] Re-add show-enabled, minimizing the code pulled in from Frontend.
Now correctly builds with both GNU make and CMake.

llvm-svn: 157932
2012-06-04 16:57:50 +00:00
Nico Weber cdfb1ae7f7 Improve fixit for comparison operator on lhs of bitwise operator.
Before:
test.cc:2:18: note: place parentheses around the == expression to silence this warning
  if (0 == flags & 0xdd)
                 ^
                   (   )

Now:
test.cc:2:18: note: place parentheses around the == expression to silence this warning
  if (0 == flags & 0xdd)
                 ^
      (         )

llvm-svn: 157897
2012-06-03 07:07:00 +00:00
Jordan Rose 573649eb8b [diagtool] Pull show-enabled back out for now.
Need to figure out how to get Frontend's warning parsing without bringing
in all of Frontend.

llvm-svn: 157847
2012-06-01 22:23:02 +00:00
Jordan Rose d617e06997 [diagtool] Add 'show-enabled', which displays which warnings are enabled.
show-enabled uses the command line you give it to build a CompilerInstance,
so any flags you pass will be processed as if running clang proper.

llvm-svn: 157842
2012-06-01 21:23:17 +00:00
Richard Trieu 2f7dc46a58 Move the warnings for extra semi-colons under -Wextra-semi. Also, added
a warning for an extra semi-colon after function definitions.  Added logic
so that a block of semi-colons on a line will only get one warning instead
of a warning for each semi-colon.

llvm-svn: 156934
2012-05-16 19:04:59 +00:00
Argyrios Kyrtzidis b16ff5d1ce Fix an assertion hit when the serialized diagnostics writer receive a diagnostic
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
2012-05-10 05:03:45 +00:00
Rafael Espindola d8b1b908b5 Put the availability warnings in a group.
llvm-svn: 156261
2012-05-06 16:49:20 +00:00
Ted Kremenek 124066c5cb Place several uncovered warnings under warning flags, and tweak diagnostic output including the term "gc" (in lowercase).
llvm-svn: 155892
2012-05-01 05:56:02 +00:00
Douglas Gregor f4fc4dff7d Move warn_cxx0x_right_shift_in_template_arg to CXX11Compat group, from
Dmitri Gribenko!

llvm-svn: 155872
2012-05-01 01:32:13 +00:00