Commit Graph

45 Commits

Author SHA1 Message Date
Daniel Dunbar 8452ef0798 tests: Use %clangxx when using driver for C++, in case C++ support is disabled.
llvm-svn: 107153
2010-06-29 16:52:24 +00:00
Chandler Carruth 5cb1abc6db Testcase for r103712.
llvm-svn: 103713
2010-05-13 12:04:17 +00:00
Douglas Gregor cd121fb013 Introduce a limit on the depth of the macro instantiation backtrace
printed in a diagnostic, similar to the limit we already have on the
depth of the template instantiation backtrace. The macro instantiation
backtrace is limited to 10 "instantiated from:" diagnostics; when it's
longer than that, we'll show the first half, then say how many were
suppressed, then show the second half. The limit can be changed with
-fmacro-instantiation-limit=N, and turned off with N=0.

This eliminates a lot of note spew with libraries making use of the
Boost.Preprocess library.

llvm-svn: 103014
2010-05-04 17:13:42 +00:00
Chris Lattner e82411b47f add regex support for -verify mode. You can now do things like
expected-error-re {{someregex}}

Patch by mike-m!

llvm-svn: 102516
2010-04-28 20:02:30 +00:00
Douglas Gregor aef0022925 Fix a bug in caret-line-pruning logic that only happens when we have a
source line wider than the terminal where the associated fix-it line
is longer than the caret line. Previously, we would crash in this
case, which was rather unfortunate. Fixes <rdar://problem/7856226>.

llvm-svn: 101426
2010-04-16 00:23:51 +00:00
Douglas Gregor 2bf2d3d016 When diagnosing suspicious precedence or assignments, move the fix-it
that adds parentheses from the main diagnostic down to a new
note. This way, when the fix-it represents a choice between two
options, each of the options is associted with a note. There is no
default option in such cases. For example:

/Users/dgregor/t.c:2:9: warning: & has lower precedence than ==; ==
will be
      evaluated first [-Wparentheses]
  if (x & y == 0) {
        ^~~~~~~~
/Users/dgregor/t.c:2:9: note: place parentheses around the &
expression to
      evaluate it first
  if (x & y == 0) {
        ^
      (    )
/Users/dgregor/t.c:2:9: note: place parentheses around the ==
expression to
      silence this warning
  if (x & y == 0) {
        ^
          (     )

llvm-svn: 101249
2010-04-14 16:09:52 +00:00
Douglas Gregor f475990d86 Remove this test. It is causing problems has has relatively little value
llvm-svn: 98730
2010-03-17 16:04:04 +00:00
Douglas Gregor 4ad3da2843 Entering the main source file in the preprocessor can fail if the
source file has been changed. Handle that failure more gracefully.

llvm-svn: 98727
2010-03-17 15:44:30 +00:00
Chris Lattner 5647d3192c fix a bug in SourceManager::getInstantiationLocSlowCase, where
we'd add an offset from the spelling location space to the 
instantiation location, which doesn't make sense and would
lead up to the text diagnostics crashing when presented with
non-sensical locations.

This fixes rdar://7597492, a crash on 255.vortex.

llvm-svn: 96004
2010-02-12 19:31:35 +00:00
Douglas Gregor 9a48db1659 Print fix-it hints properly around tabs, from Christian Adåker!
llvm-svn: 93750
2010-01-18 19:28:01 +00:00
Chris Lattner 0c523e513a testcase for -ftabstop, patch by Christian Adaker!
llvm-svn: 93260
2010-01-12 22:06:58 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Daniel Dunbar 6059021edc Switch this test to use clang-cc.
llvm-svn: 90875
2009-12-08 21:12:25 +00:00
Daniel Dunbar 3eff927255 Update test and CIndex to use -FOO BAR form for -{remap-file,code-completion-at}.
llvm-svn: 90416
2009-12-03 05:32:40 +00:00
Douglas Gregor 407e2124bf Extend -remap-file=from;to to permit mapping from a non-existent
file. This is accomplished by introducing the notion of a "virtual"
file into the file manager, which provides a FileEntry* for a named
file whose size and modification time are known but which may not
exist on disk.

Added a cute little test that remaps both a .c file and a .h file it
includes to alternative files.

llvm-svn: 90329
2009-12-02 18:12:28 +00:00
Douglas Gregor d062bff7ee Introduce a new clang-cc option
-remap-file=from;to

which takes the file "from" and transparently replaces its contents
with the contents of the file "to" from the source manager's
perspective. This is the moral equivalent of

  cp from saved
  cp to from
  <call clang>
  cp saved from
  rm saved

without all of the pesky file copying.

llvm-svn: 90307
2009-12-02 08:08:39 +00:00
Daniel Dunbar f85fabec35 Remove some redundant tests.
llvm-svn: 89069
2009-11-17 08:57:06 +00:00
Daniel Dunbar 8b57697954 Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Daniel Dunbar fb049eef8f Tweak test, with -strict-whitespace $ won't match on Windows because the buffer
will have \r\n.
 - Perhaps we should make FileCheck normalize line-endings, even in
   strict-whitespace mode?

llvm-svn: 85066
2009-10-25 20:34:02 +00:00
Daniel Dunbar 28a24fdbbc Workaround a bug exposed by the FileCheckify of message-length.c, the caret end
column computation isn't correct and could exceed the line length, which
resulted in a buffer overflow later.
 - Chris, is there a better way for this code to compute the final column used
   by the caret?

llvm-svn: 84475
2009-10-19 09:11:21 +00:00
Chris Lattner 2c02111000 convert this to FileCheck, PR5232
llvm-svn: 84466
2009-10-19 06:45:49 +00:00
Shantonu Sen 4a7b937c4b PR4715
-Wno-error disables WarningsAsErrors instead of
mistakenly being treated like -Werror

llvm-svn: 78987
2009-08-14 04:07:15 +00:00
Eli Friedman e6eb2edb50 Fix for PR2386: distinguish between insertion and replacements in the
delta tree.

The issue is roughly a conflict in ReplaceText between two kinds of 
uses. One, it should be possible to replace a replacement: for example, the
ObjC rewriter calls ReplaceStmt for an expression, then replaces the resulting
expression with another expression.  Two, it should be possible to 
replace text that already has text inserted before it: for example, the 
HTML rewriter inserts a bunch of tags at the beginning of the line, then 
tries to escape the first character on the line.  This patch 
distinguishes the two cases by storing the deltas separately; 
essentially, replacements and insertions no longer interfere with 
each other.

Another possibility would be to add some sort of flag to ReplaceText, but
this seems a bit more intuitive and flexible.

There are a few downsides to the current solution: one is that there isn't
any way to remove/replace an insertion without touching additional
surrounding text; if such an operation turns out to be useful, an
additional method or flag can be added.  Another is that an insertion 
and replacing a string of length zero are distinct operations; I'm not 
sure how to resolve this, or whether it will be confusing in practice.

This is relatively sensitive code, so please test and tell me if 
anything breaks.

llvm-svn: 72000
2009-05-18 13:56:52 +00:00
Douglas Gregor 12c3a5cedf When word-wrapping, be more defensive about a ridiculously small number of columns. Fixes <rdar://problem/6892178>
llvm-svn: 71870
2009-05-15 18:05:24 +00:00
Chris Lattner 51f57a4195 adjust this to bourne shell syntax
llvm-svn: 71070
2009-05-06 06:00:28 +00:00
Chris Lattner c45529b17b Fix rdar://6849429 - -Wunused-value with deeply nested macro expansion generates untraceable warnings
The "instantiated from" messages coming from the caret diagnostics system are 
basically walking the macro expansion tree, emitting each level as it goes.  However, it was
skipping certain leaves in the tree by skipping up the entire instantiation arm every time
it went up one spelling arm.  This caused it to miss some things.  For example, in this
testcase:

#define M1(x) x
#define M2 1;

void foo() {
 M1(M2)
}

we now print:

/Users/sabre/Desktop/clang-unused-value-macro.c:6:2: warning: expression result unused

 M1(M2)
 ^~~~~~
/Users/sabre/Desktop/clang-unused-value-macro.c:6:5: note: instantiated from:

 M1(M2)
    ^~
/Users/sabre/Desktop/clang-unused-value-macro.c:3:12: note: instantiated from:

#define M2 1;
           ^

Previously we didn't print the last line, so we never emitted the caret pointing to the 1!

Incidentally, the spaces between the lines is really noisy, I think we should reconsider
this heuristic (which adds them when the printed code starts too close to the start of the
line).

The regression test can't use -verify, because -verify doesn't catch notes for macro
instantiation history.

llvm-svn: 71025
2009-05-05 22:03:18 +00:00
Chris Lattner 882abeb2f8 rename test
llvm-svn: 71024
2009-05-05 21:52:01 +00:00
Daniel Dunbar c1fd2284c1 Update test case... the location given for this error makes it look
rather odd when truncated.

llvm-svn: 70866
2009-05-04 15:18:44 +00:00
Daniel Dunbar 6f9499188c Fix an infinite loop in diagnostic printing.
- The diagnostic is still poor, however. Doug, can you investigate?

 - Improved the test case to not depend on the file name, now it can
   be extended to actually check the formatting of the diagnostics
   (I'm hoping grep -A is portable here).

llvm-svn: 70807
2009-05-03 23:04:40 +00:00
Douglas Gregor cf7b2afc62 When printing a source line as part of a diagnostic, the source line
might be wider than we're supposed to print. In this case, we try to
select the "important" subregion of the source line, which contains
everything that we want to show (e.g., with underlining and the caret
itself) and tries to also contain some of the context. 

From the fantastically long line in the test case, we get an error
message that slices down to this:

message-length.c:18:120: warning: comparison of distinct pointer types
      ('int *' and 'float *')
  a_func_to_call(ip == FloatPointer, ip[ALongIndexName], 
                 ~~ ^  ~~~~~~~~~~~~

There are a bunch of gee-it-sounds-good heuristics in here, which seem
to do well on the various simple tests I've thrown at it. However,
we're going to need to look at a bunch more diagnostics to tweak these
heuristics.

This is the second part of <rdar://problem/6711348>. Almost there! 

llvm-svn: 70597
2009-05-01 23:32:58 +00:00
Douglas Gregor 4818553abd Implement -fmessage-length=N, which word-wraps diagnostics to N columns.
Also, put a line of whitespace between the diagnostic and the source
code/caret line when the start of the actual source code text lines up
(or nearly lines up) with the most recent line of the diagnostic. For
example, here it's okay for the last line of the diagnostic to be
(vertically) next to the source line, because there is horizontal
whitespace to separate them:

decl-expr-ambiguity.cpp:12:16: error: function-style cast to a builtin
      type can only take one argument
  typeof(int)(a,5)<<a;

However, here is a case where we need the vertical separation (since
there is no horizontal separation):

message-length.c:10:46: warning: incompatible pointer types initializing 'void
      (int, float, char, float)', expected 'int (*)(int, float, short,
      float)'

      int (*fp1)(int, float, short, float) = f;

This is part one of <rdar://problem/6711348>.

llvm-svn: 70578
2009-05-01 21:53:04 +00:00
Chris Lattner ed462a8d44 Fix rdar://6814950 - stdint.h isn't "-pedantic -std=c89" clean,
by marking the predefines buffer as a system header.  The problem 
with stdint is that it was getting problems like this:

/Volumes/Projects/cvs/llvm/Debug/lib/clang/1.0/include/stdint.h:43:9: warning: 'long long' is an extension when C99 mode is not enabled
typedef __INT64_TYPE__ int64_t;
        ^
<built-in>:73:29: note: instantiated from:
#define __INT64_TYPE__ long long
                            ^

We correctly silence warnings in system headers, but only if the 
spelling location of the token came from the system header.  This is
designed so that if you use a system macro in your code that you don't
get punished for its definition.  This is all cool except that the 
predefines buffer wasn't considered a system header.

llvm-svn: 69770
2009-04-22 03:42:19 +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 f5f049b548 add another sanity check for -Werror=xx
llvm-svn: 69157
2009-04-15 07:05:12 +00:00
Chris Lattner 5ea5dc8a3a add a missing &&
llvm-svn: 69156
2009-04-15 07:03:57 +00:00
Chris Lattner e9dba48684 fix a broken test, that passed for the wrong reason. Two wrongs make a right! :)
llvm-svn: 69155
2009-04-15 07:02:57 +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
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Chris Lattner e07ea35817 fix PR3798 by ignoring all diagnostics generated while repreprocessing a file in rewrite macros.
llvm-svn: 66961
2009-03-13 21:44:46 +00:00
Chris Lattner 7253991f9d add \n characters to the scratch buffer *before* returned tokens.
This prevents caret diagnostics from the scratch buffer from 
including other tokens in the scratch buffer that occurred beforei
them.

llvm-svn: 66375
2009-03-08 08:16:41 +00:00
Chris Lattner 59da739613 Fix PR3635 by handling ## magically
llvm-svn: 65374
2009-02-24 05:29:33 +00:00
Chris Lattner 9ef847be12 Fix rdar://6562329, a static analyzer crash Ted noticed on
wine sources.  This was happening because HighlightMacros was 
calling EnterMainFile multiple times on the same preprocessor
object and getting an assert due to the new #line stuff (the
file in question was bison output with #line directives).

The fix for this is to not reenter the file.  Instead, 
relex the tokens in raw mode, swizzle them a bit and repreprocess
the token stream.  An added bonus of this is that rewrite macros
will now hilight the macro definition as well as its uses.  Woo.

llvm-svn: 64480
2009-02-13 19:33:24 +00:00
Chris Lattner 7f33544cc7 fix bogus run line.
llvm-svn: 54940
2008-08-18 19:54:48 +00:00
Ted Kremenek 0883fd5817 Removed option "-parse-ast-check" from clang driver. This is now implemented
using "-parse-ast -verify".

Updated all test cases (using a sed script) that invoked -parse-ast-check to
now use -parse-ast -verify.

Fixed a bug where using "-verify" instead of "-parse-ast-check" would not
correctly create the DiagClient needed to accumulate diagnostics.

llvm-svn: 42365
2007-09-26 20:14:22 +00:00
Chris Lattner ac9823bc5d Build ASTs before relexing the file. This avoids having comment finding mutate the
preprocessor state, causing bogus diagnostics when the file is parsed for real.  This
implements Misc/diag-checker.c.  Thanks to Ted for noticing this.

llvm-svn: 41000
2007-08-10 18:27:41 +00:00