Граф коммитов

51 Коммитов

Автор SHA1 Сообщение Дата
Argyrios Kyrtzidis 389db16c63 Implement -working-directory.
When -working-directory is passed in command line, file paths are resolved relative to the specified directory.
This helps both when using libclang (where we can't require the user to actually change the working directory)
and to help reproduce test cases when the reproduction work comes along.

--FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains
 the working directory value if set).
--FileSystemOptions are passed around to various interfaces that perform file operations.
--Opening & reading the content of files should be done only through FileManager. This is useful in general since
 file operations will be abstracted in the future for the reproduction mechanism.

FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same
FileManager but with different FileSystemOptions.

Addresses rdar://8583824.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118203 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-03 22:45:23 +00:00
Argyrios Kyrtzidis 1b2ad2fd9e Revert r114316, -Wunused-value enabled by default was intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114318 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-19 23:03:35 +00:00
Argyrios Kyrtzidis 6dff2288a8 Make -Wunused-value off by default, matching GCC. Fixes rdar://7126194.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114316 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-19 21:21:44 +00:00
Daniel Dunbar c79f767941 tests: Use -ffreestanding when including stdint.h, to avoid platform dependencies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113301 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-07 22:54:28 +00:00
Chris Lattner 0c42bb653d 'const std::type_info*' instead of 'std::type_info const*'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113092 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-05 00:17:29 +00:00
Chris Lattner 66cf2d1290 print "const intptr_t" instead of "intptr_t const"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113091 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-05 00:07:29 +00:00
Daniel Dunbar 9fde9c424f tests: Use %clangxx when using driver for C++, in case C++ support is disabled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107153 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29 16:52:24 +00:00
Chandler Carruth 6614b2d27d Testcase for r103712.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103713 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-13 12:04:17 +00:00
Douglas Gregor 6c1cb9916e 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103014 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-04 17:13:42 +00:00
Chris Lattner 60909e1242 add regex support for -verify mode. You can now do things like
expected-error-re {{someregex}}

Patch by mike-m!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102516 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-28 20:02:30 +00:00
Douglas Gregor ce487ef6c1 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101426 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16 00:23:51 +00:00
Douglas Gregor 55b38842d1 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) {
        ^
          (     )



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101249 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14 16:09:52 +00:00
Douglas Gregor a69fa5fdcc Remove this test. It is causing problems has has relatively little value
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98730 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-17 16:04:04 +00:00
Douglas Gregor dbf8ee630e Entering the main source file in the preprocessor can fail if the
source file has been changed. Handle that failure more gracefully.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98727 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-17 15:44:30 +00:00
Chris Lattner a5c6c5814b 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96004 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 19:31:35 +00:00
Douglas Gregor e44433c29e Print fix-it hints properly around tabs, from Christian Adåker!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93750 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 19:28:01 +00:00
Chris Lattner c165f12f48 testcase for -ftabstop, patch by Christian Adaker!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93260 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 22:06:58 +00:00
Daniel Dunbar a5728872c7 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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 20:14:24 +00:00
Daniel Dunbar 2b48ed7e17 Switch this test to use clang-cc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90875 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-08 21:12:25 +00:00
Daniel Dunbar 7bd716557b Update test and CIndex to use -FOO BAR form for -{remap-file,code-completion-at}.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90416 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03 05:32:40 +00:00
Douglas Gregor 057e567f1b 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90329 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 18:12:28 +00:00
Douglas Gregor 716f0b3e2e 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90307 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 08:08:39 +00:00
Daniel Dunbar b1295dace2 Remove some redundant tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89069 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 08:57:06 +00:00
Daniel Dunbar 4fcfde4d5c Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86430 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 01:45:36 +00:00
Daniel Dunbar b3baceffe2 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?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85066 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 20:34:02 +00:00
Daniel Dunbar 06d10728b8 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?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84475 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 09:11:21 +00:00
Chris Lattner acfd65d0db convert this to FileCheck, PR5232
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84466 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 06:45:49 +00:00
Shantonu Sen b1d76bda73 PR4715
-Wno-error disables WarningsAsErrors instead of
mistakenly being treated like -Werror



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-14 04:07:15 +00:00
Eli Friedman a0978c2482 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72000 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 13:56:52 +00:00
Douglas Gregor c95bd4de80 When word-wrapping, be more defensive about a ridiculously small number of columns. Fixes <rdar://problem/6892178>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71870 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 18:05:24 +00:00
Chris Lattner c9c042c2a8 adjust this to bourne shell syntax
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71070 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-06 06:00:28 +00:00
Chris Lattner 037fb7f369 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71025 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 22:03:18 +00:00
Chris Lattner 67a16fe5d6 rename test
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71024 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 21:52:01 +00:00
Daniel Dunbar dcef78d007 Update test case... the location given for this error makes it look
rather odd when truncated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70866 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-04 15:18:44 +00:00
Daniel Dunbar 1ef29d217e 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).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70807 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 23:04:40 +00:00
Douglas Gregor 47f7177880 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! 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70597 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 23:32:58 +00:00
Douglas Gregor fffd93f383 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70578 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 21:53:04 +00:00
Chris Lattner 3936024941 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69770 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 03:42:19 +00:00
Chris Lattner 2b07d8fe9e arrange for -Wno-error=foo warnings to be immune to -Werror as
they are supposed to be.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69265 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 04:32:54 +00:00
Chris Lattner 3fbbfcfea8 add another sanity check for -Werror=xx
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69157 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 07:05:12 +00:00
Chris Lattner 17e681fe9c add a missing &&
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69156 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 07:03:57 +00:00
Chris Lattner 92af210410 fix a broken test, that passed for the wrong reason. Two wrongs make a right! :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69155 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 07:02:57 +00:00
Chris Lattner 27ceb9d77d 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69154 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 07:01:18 +00:00
Daniel Dunbar d7d5f0223b Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67602 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 02:24:46 +00:00
Chris Lattner 7c175fb196 fix PR3798 by ignoring all diagnostics generated while repreprocessing a file in rewrite macros.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66961 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 21:44:46 +00:00
Chris Lattner 2bc69bdb29 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66375 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-08 08:16:41 +00:00
Chris Lattner f0b26b1d9d Fix PR3635 by handling ## magically
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65374 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 05:29:33 +00:00
Chris Lattner 05db4278ec 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 19:33:24 +00:00
Chris Lattner 786e7a1b5c fix bogus run line.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54940 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-18 19:54:48 +00:00
Ted Kremenek 9f3d942e99 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42365 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-26 20:14:22 +00:00